--- nfo/projects/netfraggle/bin/fraggleEngine.py 2004/08/25 22:47:28 1.2 +++ nfo/projects/netfraggle/bin/fraggleEngine.py 2004/08/30 13:03:13 1.5 @@ -1,31 +1,40 @@ -#!/usr/bin/env python +#----------------------------------------------------------------------------- +# Name: fraggleEngine.py +# Purpose: Does the main (non-gui) work +# +# Author: joko +# +# Created: 2004/30/08 +# RCS-ID: $Id: fraggleEngine.py,v 1.5 2004/08/30 13:03:13 joko Exp $ +# Copyright: (c) 2004 netfrag.org +# Licence: GPL +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# $Log: fraggleEngine.py,v $ +# Revision 1.5 2004/08/30 13:03:13 joko +# - def getDefaultDir now in fraggleCtlPreferences +# + def getTopicById +# +# Revision 1.4 2004/08/27 03:18:30 joko +# new methods: fraggleSync, getTopics +# +# Revision 1.3 2004/08/26 15:25:04 joko +# added cvs headers +#----------------------------------------------------------------------------- import os from fraggleConstants import * +import FraggleXMLRPC +import fraggleCtlPreferences class FraggleEngine: """Back-end doing the work.""" def __init__(self): self.settings = {} - - def getDefaultDir(self): - """Gets location of default dir and creates it - if necessary. ($HOME/.pears/)""" - try: - import pearsdebug - savedir = pearsdebug.savedir - except: - dir = '.netfraggle' - savedir = os.path.expanduser(os.path.join('~', dir)) - if len(savedir)<=len("c:\\/" + dir): - # problem that might occur on Win2k (no $HOME environment variable) - temp = os.path.join(os.path.expandvars('$USERPROFILE'), dir) - if temp > len("c:\\/" + dir): - savedir = temp - # create dir if it doesn't exist - if not os.path.exists(savedir): - os.makedirs(savedir) - return savedir + self.topics = {} + self.preferences = fraggleCtlPreferences.create(self) + self.rpc = FraggleXMLRPC.create(self, self.preferences.getConfig()) def setSetting(self, settingname, value): """Sets settingname to value in self.settings.""" @@ -44,6 +53,64 @@ else: return None + def fraggleSync(self): + + # v1 - demo + self.topics = [ + { + 'name': 'iNFO-Test-ViaXMLRPC', + 'mode': 'pull', + 'target': { + 'url': 'http://netfrag.org/nfo/netfraggle.php', + 'method': 'nfo.getContent', + 'arguments': ['Test'], + 'type': 'XMLRPC', + } + }, + { + 'name': 'iNFO-Home-ViaXMLRPC', + 'mode': 'pull', + 'target': { + 'url': 'http://netfrag.org/nfo/netfraggle.php', + 'method': 'nfo.getContent', + 'arguments': ['Home'], + '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() + + # 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] + class urlOpener(object): """Opens urls."""