示例#1
0
文件: code.py 项目: cclauss/infogami
def get_user_preferences():
    # @ quick hack to avoid querying for user_preferences again and again
    if 'user_preferences' not in web.ctx:
        web.ctx.user_preferences = context.get('user') and web.ctx.site.get(
            context.user.key + "/preferences"
        )
    return web.ctx.user_preferences
示例#2
0
 def __getitem__(self, key):
     key = self.process_key(key)
     root = web.rstrips(self.getroot() or "", "/")
     if root is None or context.get('rescue_mode'):
         raise KeyError, key
     
     value = self.templates[root + key]    
     if isinstance(value, LazyTemplate):
         value = value.func()
                 
     return value
示例#3
0
文件: code.py 项目: hornc/infogami
    def __getitem__(self, key):
        key = self.process_key(key)
        root = self.getroot()
        if root is None or context.get('rescue_mode'):
            raise KeyError(key)

        root = web.rstrips(root or "", "/")
        value = self.templates[root + key]
        if isinstance(value, LazyTemplate):
            value = value.func()

        return value
示例#4
0
def get_user_preferences():
    #@ quick hack to avoid querying for user_preferences again and again
    if 'user_preferences' not in web.ctx:
        web.ctx.user_preferences = context.get('user') and web.ctx.site.get(context.user.key + "/preferences")
    return web.ctx.user_preferences