本文整理汇总了Python中SkunkWeb.Configuration.push方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.push方法的具体用法?Python Configuration.push怎么用?Python Configuration.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkunkWeb.Configuration
的用法示例。
在下文中一共展示了Configuration.push方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doUserDirPre
# 需要导入模块: from SkunkWeb import Configuration [as 别名]
# 或者: from SkunkWeb.Configuration import push [as 别名]
def doUserDirPre(connection, sessionDict):
"""
hook for web.protocol.PreHandleConnection
"""
if not Configuration.userDir:
return
if connection.uri[:2] != '/~':
return
else:
DEBUG(USERDIR, 'is userdir!')
uri = connection.uri[2:]
slashind = uri.find('/')
if slashind == -1: slashind = len(uri)
uname = uri[:slashind]
rest_of_path = uri[slashind:]
DEBUG(USERDIR, 'new uri is %s' % rest_of_path)
DEBUG(USERDIR, 'user is %s' % uname)
try:
info = pwd.getpwnam(uname)
except KeyError:
return #allow it to pass through
newdocroot = info[5] + '/' + Configuration.userDirPath
sessionDict['UserDir'] = 1
sessionDict['UserDirDocRoot'] = Configuration.documentRoot
sessionDict['UserDirCC'] = Configuration.compileCacheRoot
cacheroot="%s/~%s/" % (Configuration.compileCacheRoot, uname)
connection.uri = rest_of_path
# this will clean itself up when the Configuration is trimmed
Configuration.push({'documentRoot' : newdocroot,
'compileCacheRoot' : cacheroot,
'componentCacheRoot' : cacheroot})
return