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