12 |
|
|
13 |
#----------------------------------------------------------------------------- |
#----------------------------------------------------------------------------- |
14 |
# $Log$ |
# $Log$ |
15 |
|
# Revision 1.7 2004/08/31 09:34:10 joko |
16 |
|
# + def query_remote: don't do "getTopicById" here anymore |
17 |
|
# |
18 |
|
# Revision 1.6 2004/08/31 02:23:07 joko |
19 |
|
# U changes to (dummy) topics metadata (FraggleXml) |
20 |
|
# + def query_remote: wrapper for making remote xmlrpc call |
21 |
|
# |
22 |
# Revision 1.5 2004/08/30 13:03:13 joko |
# Revision 1.5 2004/08/30 13:03:13 joko |
23 |
# - def getDefaultDir now in fraggleCtlPreferences |
# - def getDefaultDir now in fraggleCtlPreferences |
24 |
# + def getTopicById |
# + def getTopicById |
65 |
# v1 - demo |
# v1 - demo |
66 |
self.topics = [ |
self.topics = [ |
67 |
{ |
{ |
68 |
'name': 'iNFO-Test-ViaXMLRPC', |
'name': 'iNFO-Page:Test-ViaXMLRPC', |
69 |
'mode': 'pull', |
'mode': 'pull', |
70 |
|
'result': 'item', |
71 |
'target': { |
'target': { |
72 |
'url': 'http://netfrag.org/nfo/netfraggle.php', |
'url': 'http://netfrag.org/nfo/netfraggle.php', |
73 |
'method': 'nfo.getContent', |
'method': 'nfo.getContent', |
74 |
'arguments': ['Test'], |
'arguments': 'Test', |
75 |
'type': 'XMLRPC', |
'type': 'XMLRPC', |
76 |
} |
} |
77 |
}, |
}, |
78 |
{ |
{ |
79 |
'name': 'iNFO-Home-ViaXMLRPC', |
'name': 'iNFO-Page:Home-ViaXMLRPC', |
80 |
'mode': 'pull', |
'mode': 'pull', |
81 |
|
'result': 'item', |
82 |
'target': { |
'target': { |
83 |
'url': 'http://netfrag.org/nfo/netfraggle.php', |
'url': 'http://netfrag.org/nfo/netfraggle.php', |
84 |
'method': 'nfo.getContent', |
'method': 'nfo.getContent', |
85 |
'arguments': ['Home'], |
'arguments': 'Home', |
86 |
|
'type': 'XMLRPC', |
87 |
|
} |
88 |
|
}, |
89 |
|
{ |
90 |
|
'name': 'iNFO-PageIndex', |
91 |
|
'mode': 'pull', |
92 |
|
'result': 'list', |
93 |
|
'target': { |
94 |
|
'url': 'http://netfrag.org/nfo/netfraggle.php', |
95 |
|
'method': 'nfo.listTopics', |
96 |
|
'arguments': ['xmlpage'], |
97 |
'type': 'XMLRPC', |
'type': 'XMLRPC', |
98 |
} |
} |
99 |
}, |
}, |
131 |
def getTopicById(self, id): |
def getTopicById(self, id): |
132 |
return self.topics[id] |
return self.topics[id] |
133 |
|
|
134 |
|
def query_remote(self, topicmeta): |
135 |
|
|
136 |
|
if topicmeta['target']['type'] == 'XMLRPC': |
137 |
|
# TODO: make FraggleXMLRPC do all stuff |
138 |
|
# (call methods dynamically) |
139 |
|
from xmlrpclib import Server, Error |
140 |
|
rpc = Server(topicmeta['target']['url']) |
141 |
|
#try: |
142 |
|
if topicmeta['result'] == 'item': |
143 |
|
topicdata = {} |
144 |
|
try: |
145 |
|
#topicdata = rpc.getContent('Home') |
146 |
|
#topicdata = rpc.getContent(tuple(topicmeta['target']['arguments'])) |
147 |
|
topicdata = rpc.getContent(topicmeta['target']['arguments']) |
148 |
|
#print topicdata |
149 |
|
except Error, v: |
150 |
|
print "ERROR", v |
151 |
|
elif topicmeta['result'] == 'list': |
152 |
|
topicdata = [] |
153 |
|
try: |
154 |
|
arg = {'type': 'xmlpage'} |
155 |
|
topicdata = rpc.listTopics(arg) |
156 |
|
#print topicdata |
157 |
|
#self.styledTextContent.SetText(repr(topicdata)) |
158 |
|
except Error, v: |
159 |
|
print "ERROR", v |
160 |
|
return topicdata |
161 |
|
|
162 |
class urlOpener(object): |
class urlOpener(object): |
163 |
"""Opens urls.""" |
"""Opens urls.""" |
164 |
def __init__(self): |
def __init__(self): |