| 12 |
|
|
| 13 |
#----------------------------------------------------------------------------- |
#----------------------------------------------------------------------------- |
| 14 |
# $Log$ |
# $Log$ |
| 15 |
|
# Revision 1.12 2004/09/17 09:42:30 xabbu |
| 16 |
|
# U function listItems() places a query to the server now and returns its results |
| 17 |
|
# |
| 18 |
|
# Revision 1.11 2004/09/15 22:27:06 xabbu |
| 19 |
|
# +/- function fraggleSync replaced by function syncTopics which places a query |
| 20 |
|
# + function query has simple eval of error return code now |
| 21 |
|
# |
| 22 |
# Revision 1.10 2004/09/13 21:07:38 xabbu |
# Revision 1.10 2004/09/13 21:07:38 xabbu |
| 23 |
# + function query added for testing of the nql / rpc interface |
# + function query added for testing of the nql / rpc interface |
| 24 |
# |
# |
| 80 |
else: |
else: |
| 81 |
return None |
return None |
| 82 |
|
|
| 83 |
def fraggleSync(self): |
def syncTopics(self): |
| 84 |
#self.queryCms() |
query = "GET * FROM contenttypes" |
| 85 |
fraggleParser = fraggleParserXML.create(self) |
topicData = self.queryCms(query) |
| 86 |
# v1 - demo |
topictypes = topicData['1'] |
| 87 |
self.topics = [ |
|
| 88 |
{ |
for i in topictypes: |
| 89 |
'name': 'iNFO-Page:Test-ViaXMLRPC', |
self.topics[i] = topictypes[i]['1'] |
| 90 |
'mode': 'pull', |
|
| 91 |
'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 |
|
| 92 |
|
|
|
# 1. load payload from remote side |
|
|
fragglexml = self.rpc.FraggleSync() |
|
|
|
|
|
# 2. (todo) unmarshal to self.topics (hash) |
|
|
# self.topics = unmarshal(fragglexml) |
|
|
|
|
| 93 |
def getTopics(self): |
def getTopics(self): |
| 94 |
return self.topics |
return self.topics |
| 95 |
|
|
| 96 |
def getTopicById(self, id): |
def getTopicById(self, id): |
| 97 |
return self.topics[id] |
return self.topics[id] |
| 98 |
|
|
| 99 |
def listItems(self,topicId): |
def listItems(self,contentkey): |
| 100 |
result = self.queryCms("GET creator_id, language_id, description FROM contents") |
result = self.queryCms(str("GET creator_id, language_id, description FROM contents WITH type "+contentkey)) |
| 101 |
print result |
return result |
| 102 |
|
|
| 103 |
def queryCms(self,nqlquery): |
def queryCms(self,nqlquery): |
| 104 |
|
|
| 105 |
from xmlrpclib import Server,Error |
from xmlrpclib import Server,Error |
| 106 |
rpc = Server('http://netfrag.org/nfo/netfraggle.php') |
rpc = Server('http://netfrag.org/nfo/netfraggle.php') |
| 107 |
topicdata = rpc.query(nqlquery) |
result = rpc.query(nqlquery) |
| 108 |
print topicdata |
if result['0']['error'] == '0': |
| 109 |
return topicdata |
#print result |
| 110 |
|
return result |
| 111 |
|
|
| 112 |
|
#else: |
| 113 |
|
#print result['0']['error'] |
| 114 |
|
#return result |
| 115 |
|
|
| 116 |
def query_remote(self, topicmeta): |
def query_remote(self, topicmeta): |
| 117 |
|
|
| 118 |
if topicmeta['target']['type'] == 'XMLRPC': |
if topicmeta['target']['type'] == 'XMLRPC': |