12 |
|
|
13 |
#----------------------------------------------------------------------------- |
#----------------------------------------------------------------------------- |
14 |
# $Log$ |
# $Log$ |
15 |
|
# Revision 1.11 2004/09/15 22:27:06 xabbu |
16 |
|
# +/- function fraggleSync replaced by function syncTopics which places a query |
17 |
|
# + function query has simple eval of error return code now |
18 |
|
# |
19 |
# Revision 1.10 2004/09/13 21:07:38 xabbu |
# Revision 1.10 2004/09/13 21:07:38 xabbu |
20 |
# + function query added for testing of the nql / rpc interface |
# + function query added for testing of the nql / rpc interface |
21 |
# |
# |
77 |
else: |
else: |
78 |
return None |
return None |
79 |
|
|
80 |
def fraggleSync(self): |
def syncTopics(self): |
81 |
#self.queryCms() |
query = "GET * FROM contenttypes" |
82 |
fraggleParser = fraggleParserXML.create(self) |
topicData = self.queryCms(query) |
83 |
# v1 - demo |
topictypes = topicData['1'] |
84 |
self.topics = [ |
|
85 |
{ |
for i in topictypes: |
86 |
'name': 'iNFO-Page:Test-ViaXMLRPC', |
self.topics[i] = topictypes[i]['1'] |
87 |
'mode': 'pull', |
|
88 |
'result': 'item', |
#print self.topics |
|
'target': { |
|
|
'url': 'http://netfrag.org/nfo/netfraggle.php', |
|
|
'method': 'nfo.getContent', |
|
|
'arguments': 'Test', |
|
|
'type': 'XMLRPC', |
|
|
} |
|
|
}, |
|
|
{ |
|
|
'name': 'iNFO-Page:Home-ViaXMLRPC', |
|
|
'mode': 'pull', |
|
|
'result': 'item', |
|
|
'target': { |
|
|
'url': 'http://netfrag.org/nfo/netfraggle.php', |
|
|
'method': 'nfo.getContent', |
|
|
'arguments': 'Home', |
|
|
'type': 'XMLRPC', |
|
|
} |
|
|
}, |
|
|
{ |
|
|
'name': 'iNFO-PageIndex', |
|
|
'mode': 'pull', |
|
|
'result': 'list', |
|
|
'target': { |
|
|
'url': 'http://netfrag.org/nfo/netfraggle.php', |
|
|
'method': 'nfo.listTopics', |
|
|
'arguments': ['xmlpage'], |
|
|
'type': 'XMLRPC', |
|
|
} |
|
|
}, |
|
|
{ |
|
|
'name': 'TWiki-Test-ViaTWiki', |
|
|
'mode': 'push', |
|
|
'target': { |
|
|
'url': 'http://netfrag.org/twiki/bin/view/Main/NetFraggleTest', |
|
|
'type': 'TWiki', |
|
|
} |
|
|
}, |
|
|
{ |
|
|
'name': 'TWiki-Test-ViaXMLRPC', |
|
|
'mode': 'push', |
|
|
'target': { |
|
|
'method': 'appendToPage', |
|
|
'arguments': ['NetFraggleTest'], |
|
|
'type': 'XMLRPC', |
|
|
} |
|
|
}, |
|
|
] |
|
|
topicfile = os.path.join(self.getDefaultDir(), 'topic.xml') |
|
|
fraggleParser.marshalXML(self.topics,topicfile) |
|
|
return |
|
|
|
|
|
# v2 - live |
|
|
|
|
|
# 1. load payload from remote side |
|
|
fragglexml = self.rpc.FraggleSync() |
|
89 |
|
|
|
# 2. (todo) unmarshal to self.topics (hash) |
|
|
# self.topics = unmarshal(fragglexml) |
|
|
|
|
90 |
def getTopics(self): |
def getTopics(self): |
91 |
return self.topics |
return self.topics |
92 |
|
|
95 |
|
|
96 |
def listItems(self,topicId): |
def listItems(self,topicId): |
97 |
result = self.queryCms("GET creator_id, language_id, description FROM contents") |
result = self.queryCms("GET creator_id, language_id, description FROM contents") |
98 |
print result |
#print result |
99 |
|
|
100 |
def queryCms(self,nqlquery): |
def queryCms(self,nqlquery): |
101 |
|
|
102 |
from xmlrpclib import Server,Error |
from xmlrpclib import Server,Error |
103 |
rpc = Server('http://netfrag.org/nfo/netfraggle.php') |
rpc = Server('http://netfrag.org/nfo/netfraggle.php') |
104 |
topicdata = rpc.query(nqlquery) |
result = rpc.query(nqlquery) |
105 |
print topicdata |
if result['0']['error'] == '0': |
106 |
return topicdata |
#print result |
107 |
|
return result |
108 |
|
|
109 |
|
#else: |
110 |
|
#print result['0']['error'] |
111 |
|
#return result |
112 |
|
|
113 |
def query_remote(self, topicmeta): |
def query_remote(self, topicmeta): |
114 |
|
|
115 |
if topicmeta['target']['type'] == 'XMLRPC': |
if topicmeta['target']['type'] == 'XMLRPC': |