コード例 #1
0
 def getpage(self, fields):
     """fields - dict of HTTP pears. Returns formatted page string, according to fields['job']"""
     job = fields.get('job') or 'view'
     # Creat the context that is used by the template
     context = simpleTALES.Context(allowPythonPath=1)
     context.addGlobal(
         "cfg", {
             'version': Config.get('version'),
             'link': Config.get('link'),
             'logo': Config.get('logo'),
             'css': Config.get('css')
         })
     # Add objects into the template context
     context = getattr(self, "_context_" + job)(context, fields)
     # Open the template file
     templateFile = open(
         os.path.join(Config.get('zpt_path'), "".join([job, ".zpt"])), 'r')
     # Compile a template
     template = simpleTAL.compileHTMLTemplate(templateFile, self.encoding)
     # Close the template file
     templateFile.close()
     # Create fake file that lets print file as a string
     fastFile = simpleTALUtils.FastStringOutput()
     # Expand the template as HTML using this context
     template.expand(context, fastFile, self.encoding)
     return fastFile.getvalue()  #yo people! it's ZPT content"
コード例 #2
0
 def __init__(self):
     """Initilize PageFormatter
        'DataStore', 'ContentFormatter' and 'encoding' objects must be added to Config before,
        instanciating object of this class
     """
     self.datastore = Config.get("DataStore")
     self.formatter = Config.get("ContentFormatter")
     self.encoding = Config.get("encoding")
コード例 #3
0
 def __init__(self):
     """Initilize PageFormatter
        'DataStore', 'ContentFormatter' and 'encoding' objects must be added to Config before,
        instanciating object of this class
     """
     self.datastore = Config.get('DataStore')
     self.formatter = Config.get('ContentFormatter')
     self.encoding = Config.get('encoding')
コード例 #4
0
 def __init__(self):
     """Initilize XTMPageFormatter
        'DataStore', 'ContentFormatter', 'encoding' and 'XTMHandler' objects must be added
        to Config before, instanciating object of this class
     """
     self.xtm = Config.get('XTMHandler')
     ZPTPageFormatter.__init__(self)
コード例 #5
0
 def __init__(self):
     """Initilize XTMPageFormatter
        'DataStore', 'ContentFormatter', 'encoding' and 'XTMHandler' objects must be added
        to Config before, instanciating object of this class
     """
     self.xtm = Config.get('XTMHandler')
     ZPTPageFormatter.__init__(self)
コード例 #6
0
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()
コード例 #7
0
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()
コード例 #8
0
 def getpage(self, fields):
     """fields - dict of HTTP pears. Returns formatted page string, according to fields['job']"""
     job = fields.get('job') or 'view'
     # Creat the context that is used by the template
     context = simpleTALES.Context(allowPythonPath=1)
     context.addGlobal ("cfg", {'version':Config.get('version'), 
                                   'link':Config.get('link'),
                                   'logo':Config.get('logo'), 
                                    'css':Config.get('css')})
     # Add objects into the template context
     context = getattr(self, "_context_" + job)(context, fields)
     # Open the template file
     templateFile = open(os.path.join(Config.get('zpt_path'), "".join([job, ".zpt"])), 'r')
     # Compile a template
     template = simpleTAL.compileHTMLTemplate (templateFile, self.encoding)
     # Close the template file
     templateFile.close()
     # Create fake file that lets print file as a string
     fastFile = simpleTALUtils.FastStringOutput()
     # Expand the template as HTML using this context
     template.expand(context, fastFile, self.encoding)
     return fastFile.getvalue() #yo people! it's ZPT content"
コード例 #9
0
    def _context_history(self, context, fields):
        """add objects to the context for zpt template history.zpt"""
        wn = fields['wn']
        context.addGlobal ("title", wn)

        history = Config.get('History')

        items = history.listVersions(wn).items()
        def sortitems(a, b):
            return -cmp_fileversions(a[0], b[0])
        items.sort(sortitems)

        context.addGlobal("check", (len(items) > 1 and 1 or 0))
        context.addGlobal ("revisions", items)
        context.addGlobal ("time", time)
        return context
コード例 #10
0
    def _context_history(self, context, fields):
        """add objects to the context for zpt template history.zpt"""
        wn = fields['wn']
        context.addGlobal("title", wn)

        history = Config.get('History')

        items = history.listVersions(wn).items()

        def sortitems(a, b):
            return -cmp_fileversions(a[0], b[0])

        items.sort(sortitems)

        context.addGlobal("check", (len(items) > 1 and 1 or 0))
        context.addGlobal("revisions", items)
        context.addGlobal("time", time)
        return context
コード例 #11
0
 def __init__(self):
     """Initilize SimpleDataStore
        'content_path' must be added to Config before, instanciating object of this class
     """
     self.content_path = Config.get('content_path')
     self.history = Config.get('History')
コード例 #12
0
 def __init__(self):
     """Initilize SimpleDataStore
        'content_path' must be added to Config before, instanciating object of this class
     """
     self.content_path = Config.get('content_path')
     self.history = Config.get('History')
コード例 #13
0
 def __init__(self):
     """Initilize XTMFormProcessor
       'DataStore' and 'XTMHandler' objects must be added to Config before, instanciating object of this class
     """
     self.xtm = Config.get('XTMHandler') 
     SimpleFormProcessor.__init__(self)
コード例 #14
0
 def __init__(self):
     """Initilize FormProcessor
        'DataStore' object must be added to Config before, instanciating object of this class
     """
     self.datastore = Config.get('DataStore')
コード例 #15
0
cfg = {}  # configuration dict
cfg['encoding'] = 'utf-8'  # 'iso-8859-13'

svnrepos = 'svn://svn.berlios.de/meduswiki/trunk'

cfg['version'] = os.popen("svnversion . %s" % svnrepos).read()
cfg['link'] = 'http://meduswiki.berlios.de/'
cfg['logo'] = 'http://meduswiki.berlios.de/medus.png'
cfg['css'] = 'http://meduswiki.berlios.de/meduswiki.css'

cfg['data_path'] = 'data'
cfg['content_path'] = os.path.join(cfg['data_path'], 'content')
cfg['xtm_path'] = os.path.join(cfg['data_path'], 'topicmap.xml')
cfg['zpt_path'] = os.path.join('templates', mode)
#</Configuration>
Config.adddict(cfg)


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
コード例 #16
0
 def __init__(self):
     """Initilize XTMFormProcessor
       'DataStore' and 'XTMHandler' objects must be added to Config before, instanciating object of this class
     """
     self.xtm = Config.get('XTMHandler')
     SimpleFormProcessor.__init__(self)
コード例 #17
0
 def __init__(self):
     """Initilize WikiFormatter
        'DataStore' object must be added to Config before, instanciating object of this class
     """
     self.datastore = Config.get('DataStore')
コード例 #18
0
cfg = {} # configuration dict
cfg['encoding'] = 'utf-8' # 'iso-8859-13'

svnrepos = 'svn://svn.berlios.de/meduswiki/trunk'

cfg['version'] = os.popen("svnversion . %s" % svnrepos).read()
cfg['link'] = 'http://meduswiki.berlios.de/'
cfg['logo'] = 'http://meduswiki.berlios.de/medus.png'
cfg['css'] = 'http://meduswiki.berlios.de/meduswiki.css'

cfg['data_path'] = 'data'
cfg['content_path'] = os.path.join(cfg['data_path'], 'content')
cfg['xtm_path'] = os.path.join(cfg['data_path'], 'topicmap.xml')
cfg['zpt_path'] = os.path.join('templates', mode)
#</Configuration>
Config.adddict(cfg)


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