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"
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")
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')
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)
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"
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
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
def __init__(self): """Initilize WikiFormatter 'DataStore' object must be added to Config before, instanciating object of this class """ self.datastore = Config.get('DataStore')
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')
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)
def __init__(self): """Initilize FormProcessor 'DataStore' object must be added to Config before, instanciating object of this class """ self.datastore = Config.get('DataStore')