--- nfo/projects/netfraggle/bin/fraggleEngine.py 2004/09/01 21:43:30 1.9 +++ nfo/projects/netfraggle/bin/fraggleEngine.py 2004/09/21 18:07:09 1.13 @@ -5,13 +5,26 @@ # Author: joko # # Created: 2004/30/08 -# RCS-ID: $Id: fraggleEngine.py,v 1.9 2004/09/01 21:43:30 xabbu Exp $ +# RCS-ID: $Id: fraggleEngine.py,v 1.13 2004/09/21 18:07:09 xabbu Exp $ # Copyright: (c) 2004 netfrag.org # Licence: GPL #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # $Log: fraggleEngine.py,v $ +# Revision 1.13 2004/09/21 18:07:09 xabbu +# + added functions listItems and getContent +# +# Revision 1.12 2004/09/17 09:42:30 xabbu +# U function listItems() places a query to the server now and returns its results +# +# Revision 1.11 2004/09/15 22:27:06 xabbu +# +/- function fraggleSync replaced by function syncTopics which places a query +# + function query has simple eval of error return code now +# +# Revision 1.10 2004/09/13 21:07:38 xabbu +# + function query added for testing of the nql / rpc interface +# # Revision 1.9 2004/09/01 21:43:30 xabbu # +Moved funtion getDefaultDir from FraggleCtlPreferences to FraggleEngine for more convenience # +FraggleCtlModules class creation for handling content modules @@ -42,6 +55,7 @@ import FraggleXMLRPC import fraggleCtlPreferences import FraggleCtlModules +import fraggleParserXML class FraggleEngine: """Back-end doing the work.""" @@ -69,77 +83,47 @@ else: return None - def fraggleSync(self): - - # v1 - demo - self.topics = [ - { - 'name': 'iNFO-Page:Test-ViaXMLRPC', - 'mode': 'pull', - 'result': 'item', - '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', - } - }, - ] - return - - # v2 - live - - # 1. load payload from remote side - fragglexml = self.rpc.FraggleSync() + def syncTopics(self): + query = "GET * FROM contenttypes" + topicData = self.queryCms(query) + topictypes = topicData['1'] + + for i in topictypes: + self.topics[i] = topictypes[i]['1'] + + #print self.topics - # 2. (todo) unmarshal to self.topics (hash) - # self.topics = unmarshal(fragglexml) - def getTopics(self): return self.topics def getTopicById(self, id): return self.topics[id] - + + def listItems(self,contentkey): + print contentkey + result = self.queryCms(str("GET creator_id, language_id, description, id FROM contents WITH type "+contentkey)) + return result + + def getContent(self,contentkey): + query = str("GET content, creator_id, description, id FROM contents WITH id "+contentkey) + result = self.queryCms(query) + print query + return result + + + def queryCms(self,nqlquery): + + from xmlrpclib import Server,Error + rpc = Server('http://netfrag.org/nfo/netfraggle.php') + result = rpc.query(nqlquery) + if result['0']['error'] == '0': + #print result + return result + + #else: + #print result['0']['error'] + #return result + def query_remote(self, topicmeta): if topicmeta['target']['type'] == 'XMLRPC':