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