예제 #1
0
    def logodir(self):

        datapath = runtime_data.get('site.data.path')
        if not datapath:
            datapath = get_site_config(
                'site.data.path', '/opt/LuoYun/data/' )
            runtime_data['site.data.path'] = datapath

        return os.path.join(datapath, 'forum/catalog/%s' % self.id)
예제 #2
0
파일: utils.py 프로젝트: crook/LuoYunCloud
def get_site_config(key, default_value=None):

    dbsession = runtime_data.get('dbsession')
    if not dbsession:
        dbsession = orm.create_session()
        runtime_data['dbsession'] = dbsession

    db = dbsession()
    v = SiteConfig.get(db, key, default_value)

    dbsession.remove()

    return v
예제 #3
0
    def logourl(self):

        dataurl = runtime_data.get('site.data.url')
        if not dataurl:
            dataurl = get_site_config( 'site.data.url', '/dl/' )
            runtime_data['site.data.url'] = dataurl

        thumb_file = os.path.join( self.logodir, 'thumb.png')

        if os.path.exists( thumb_file ):
            return '%s/forum/catalog/%s/thumb.png' % (
                dataurl.rstrip('/'), self.id )
        else:
            return '/static/image/forum/catalog_logo.png'
예제 #4
0
def get_runtime_data(key, value=None):

    v = runtime_data.get(key)

    if v:
        return v

    db = global_dbsession()
    v = SiteConfig.get(db, key, None)

    if v:
        runtime_data[key] = v
        return v

    return value