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)
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
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'
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