Esempio n. 1
0
def loadPageTemplate(name, dir='skins/zwiki'):
    """
    Load the named page template from the filesystem and return it, or None.
    """
    f = os.path.join(abszwikipath(dir), '%s.pt' % name)
    if os.path.exists(f):
        return PageTemplateFile(f, globals(), __name__=name)
    else:
        return None
Esempio n. 2
0
def loadPageTemplate(name,dir='skins/zwiki'):
    """
    Load the named page template from the filesystem and return it, or None.
    """
    f = os.path.join(abszwikipath(dir),'%s.pt' % name)
    if os.path.exists(f):
        return PageTemplateFile(f,globals(),__name__=name)
    else:
        return None
Esempio n. 3
0
def loadDtmlMethod(name,dir='skins/zwiki'):
    """
    Load the named dtml method from the filesystem and return it, or None.
    """
    f = os.path.join(abszwikipath(dir),name)
    if os.path.exists('%s.dtml' % f):
        # need this one for i18n gettext patch to work ?
        #dm = DTMLFile(os.path.join(dir,name), globals())
        dm = HTMLFile(f, globals())
        # work around some (2.7 ?) glitch
        if not hasattr(dm,'meta_type'): dm.meta_type = 'DTML Method (File)'
        return dm
    else:
        return None
Esempio n. 4
0
def loadDtmlMethod(name, dir='skins/zwiki'):
    """
    Load the named dtml method from the filesystem and return it, or None.
    """
    f = os.path.join(abszwikipath(dir), name)
    if os.path.exists('%s.dtml' % f):
        # need this one for i18n gettext patch to work ?
        #dm = DTMLFile(os.path.join(dir,name), globals())
        dm = HTMLFile(f, globals())
        # work around some (2.7 ?) glitch
        if not safe_hasattr(dm, 'meta_type'):
            dm.meta_type = 'DTML Method (File)'
        return dm
    else:
        return None
Esempio n. 5
0
def loadFile(name, dir='skins/zwiki'):
    """
    Load and return a File from the filesystem, or None.
    """
    filepath = os.path.join(abszwikipath(dir), name)
    if os.path.exists(filepath):
        f = None
        try:
            try:
                f = open(filepath, 'rb')
                data = f.read()
                mtime = os.path.getmtime(filepath)
                file = File(name, '', data)
                # bug workaround: bobobase_modification_time will otherwise be current time
                file.bobobase_modification_time = lambda: mtime
                return file
            except IOError:
                return None
        finally:
            if f: f.close()
    else:
        return None
Esempio n. 6
0
def loadFile(name,dir='skins/zwiki'):
    """
    Load and return a File from the filesystem, or None.
    """
    filepath = os.path.join(abszwikipath(dir),name)
    if os.path.exists(filepath):
        f = None
        try:
            try:
                f = open(filepath,'rb')
                data = f.read()
                mtime = os.path.getmtime(filepath)
                file = File(name,'',data)
                # bug workaround: bobobase_modification_time will otherwise be current time
                file.bobobase_modification_time = lambda:mtime
                return file
            except IOError:
                return None
        finally:
            if f: f.close()
    else:
        return None
Esempio n. 7
0
    return getattr(obj, 'meta_type', None) in ('File', )


def isZwikiPage(obj):
    return getattr(obj, 'meta_type', None) in (PAGE_METATYPE, )


def addErrorTo(text, error):
    return """<div class="error">%s</div>\n%s""" % (error, text)


# load built-in zwiki skin templates from the filesystem
# skins/zwiki/ defines all of these, other skins need not

SKINS = {}
for s in os.listdir(abszwikipath('skins')):
    SKINS[s] = {}
    skindir = os.path.join(abszwikipath('skins'), s)
    for template in [
            # main view templates
            # these usually have a similarly named publish method
            'backlinks',
            'contentspage',
            'denied',
            'genericerror',
            'diffform',
            'editform',
            'history',
            'wikiindex',
            'wikistats',
            'recentchanges',
Esempio n. 8
0
        )

def isZwikiPage(obj):
    return getattr(obj,'meta_type',None) in (
        PAGE_METATYPE,
        )

def addErrorTo(text,error):
    return """<div class="error">%s</div>\n%s""" % (error,text)


# load built-in zwiki skin templates from the filesystem
# skins/zwiki/ defines all of these, other skins need not

SKINS = {}
for s in os.listdir(abszwikipath('skins')):
    SKINS[s] = {}
    skindir = os.path.join(abszwikipath('skins'),s)
    for template in [
        # main view templates
        # these usually have a similarly named publish method
        'backlinks',
        'contentspage',
        'denied',
        'diffform',
        'editform',
        'recentchanges',
        'searchwiki',
        'helppage',
        'subscribeform',
        'useroptions',