def test_addAssociation(): """association is created from parameters""" tmHandler = Handler() tmHandler.addTopic("role") tmHandler.addTopic("knows", "", "", "role") tmHandler.addTopic("unknown", "", "", "role") tmHandler.addAssociation("knows", "nonmexistant", "unknown") assert tmHandler.getTopicAssociations("knows")[0][2] == "unknown"
def test_addTopic(): """topic is created from paramaters""" string = """<topicMap xmlns:xlink="%s" id="%s"></topicMap>""" % (xlink, "2122") f = open("test21212.xml", "wt") f.write(string) f.close() tmHandler = Handler("test21212.xml") tmHandler.addTopic("name") assert tmHandler.hasTopic("name") os.remove("test21212.xml")
def test_addTopic(): """topic is created from paramaters""" string = """<topicMap xmlns:xlink="%s" id="%s"></topicMap>""" % (xlink, "2122") f = open("test21212.xml", 'wt') f.write(string) f.close() tmHandler = Handler("test21212.xml") tmHandler.addTopic("name") assert tmHandler.hasTopic("name") os.remove("test21212.xml")
def main(fields): """(fields) - dict of HTTP pairs""" sys.stderr = sys.stdout print "Content-type: text/html; charset=%s\r\n" % cfg['encoding'] try: wn = fields.get('wn') or os.getenv("QUERY_STRING") or '' # if wn=WikiName is given, then this one is used, if not, then checks for cgi.py?QUERY_STRING # at this moment we have WikiName in the variable (wn) if wn.isalnum(): # so WikiName as '4Suite' could be used here fields['wn'] = wn else: fields['wn'] = 'HomePage' # create data store, history and content formatter Config.add('History', History(cfg['content_path'])) Config.add('DataStore', SimpleDataStore()) Config.add('ContentFormatter', WikiFormatter()) # process mode if mode == 'simple': from medus.page.SimplePageFormatter import SimplePageFormatter pagelayout = SimplePageFormatter() elif mode == 'zpt': from medus.page.ZPTPageFormatter import ZPTPageFormatter pagelayout = ZPTPageFormatter() elif mode == 'xtm': from medus.page.XTMPageFormatter import XTMPageFormatter from xtm.Handler import Handler Config.add('XTMHandler', Handler(cfg['xtm_path'])) pagelayout = XTMPageFormatter() else: raise mode, " is not implemented" # process POST query if os.getenv( "REQUEST_METHOD" ) == "POST": # this means that FormProcessing must be done if mode == 'simple' or mode == 'zpt': from medus.form.SimpleFormProcessor import SimpleFormProcessor formproc = SimpleFormProcessor() elif mode == 'xtm': from medus.form.XTMFormProcessor import XTMFormProcessor formproc = XTMFormProcessor() formproc.process(fields) print pagelayout.getpage(fields) except: print "\n\n<pre>" traceback.print_exc()
def test_addAssociation(): """association is created from parameters""" tmHandler = Handler() tmHandler.addTopic("role") tmHandler.addTopic("knows", '', '', "role") tmHandler.addTopic("unknown", '', '', "role") tmHandler.addAssociation("knows", 'nonmexistant', "unknown") assert tmHandler.getTopicAssociations("knows")[0][2] == 'unknown'
def test_removeAssociation(): """must remove Association from topic map""" tmHandler = Handler() tmHandler.addTopic("role") tmHandler.addTopic("knows", '', '', "role") tmHandler.addTopic("unknown", '', '', "role") tmHandler.addAssociation("knows", 'oppositeRole', "unknown") assid = tmHandler.getTopicAssociations("knows")[0][0] tmHandler.removeAssociation(assid) assert not assid in tmHandler._tm.associations.keys()
def init(): global tmHandler, tm tmHandler = None #? tmHandler = Handler() tm = tmFactory.createTopicMap("1")
def test_removeAssociation(): """must remove Association from topic map""" tmHandler = Handler() tmHandler.addTopic("role") tmHandler.addTopic("knows", "", "", "role") tmHandler.addTopic("unknown", "", "", "role") tmHandler.addAssociation("knows", "oppositeRole", "unknown") assid = tmHandler.getTopicAssociations("knows")[0][0] tmHandler.removeAssociation(assid) assert not assid in tmHandler._tm.associations.keys()