本文整理汇总了Python中SkunkWeb.Configuration类的典型用法代码示例。如果您正苦于以下问题:Python Configuration类的具体用法?Python Configuration怎么用?Python Configuration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __initConfig
def __initConfig():
from AE import cfg
from SkunkWeb import Configuration, confvars
# set our defaults from AE defaults
Configuration.mergeDefaults(
documentRoot = confvars.DEFAULT_DOCROOT,
compileCacheRoot = confvars.DEFAULT_CACHE,
componentCacheRoot = confvars.DEFAULT_CACHE,
failoverComponentCacheRoot = "%s/failoverCache" % Configuration.SkunkRoot,
mimeTypesFile = confvars.DEFAULT_MIME_TYPES_FILE_NAME,
componentCommentLevel = 0,
)
dd = {}
for k, v in cfg.Configuration._d.items():
if k not in ['documentRoot',
'compileCacheRoot',
'componentCacheRoot',
'failoverComponentCacheRoot',
'mimeTypesFile',
'componentCommentLevel']:
dd[k]=v
Configuration.mergeDefaults(dd)
# set AE's config object to ours
cfg.Configuration = Configuration
__checkScopes(Configuration.scopeMatchers())
示例2: _processRequest
def _processRequest(requestData, sessionDict):
"""
request handling functioning for requestHandler's
HandleRequest hook.
"""
response=None
# DEBUG(WEB, 'creating Connection')
# DEBUG(WEB, 'requestData is %s' % str(requestData))
connection=HTTPConnection(requestData)
sessionDict[constants.CONNECTION]=connection
sessionDict[constants.HOST]=connection.host
sessionDict[constants.LOCATION]=connection.uri
sessionDict[constants.SERVER_PORT]=int(connection.env['SERVER_PORT'])
try:
# DEBUG(WEB, 'executing HaveConnection hook')
HaveConnection(Configuration.job, connection, sessionDict)
# DEBUG(WEB, 'survived HaveConnection hook')
# overlay of config information
Configuration.trim()
Configuration.scope(sessionDict)
#Configuration.saveMash()
# DEBUG(WEB, 'executing PreHandleConnection hook')
PreHandleConnection(Configuration.job, connection, sessionDict)
except PreemptiveResponse, pr:
# DEBUG(WEB, 'got preemptive response')
response=pr.responseData
示例3: __initConfig
def __initConfig():
import SkunkWeb.Configuration as C
import os
C.mergeDefaults(
webdavDB=os.join(C.SkunkRoot, 'var/run/WEBDAVdb'),
webdavFS=fs.WebdavFS(),
)
示例4: doUserDirPre
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
示例5: _beginSession
def _beginSession(sock, sessionDict):
# capture the ip & port (or path, for a unix socket)
# on which the request came, for scoping of configuration
# data on their basis
ip, port, unixpath=None, None, None
try:
addr=sock.getsockname()
if type(addr)==types.TupleType:
ip, port=addr
else:
unixpath=addr
except:
ERROR("failed to read addr off socket!")
logException()
raise
if ip and port:
sessionDict[constants.IP]=ip
sessionDict[constants.PORT]=port
else:
sessionDict[constants.UNIXPATH]=unixpath
# get configuration data for the job
Configuration.scope(sessionDict)
# job must be defined, or else die here
if Configuration.job==None:
message="No job specified for service on %s:%d, "\
"request cannot be processed!" % (ip, port)
ERROR(message)
raise SkunkCriticalError, message
BeginSession(Configuration.job, sock, sessionDict)
示例6: _cleanupConfig
def _cleanupConfig(requestData, sessionDict):
"""
function for requestHandler's CleanupRequest hook
"""
if sessionDict.has_key(constants.HOST):
del sessionDict[constants.HOST]
if sessionDict.has_key(constants.LOCATION):
del sessionDict[constants.LOCATION]
Configuration.trim()
if sessionDict.has_key(constants.IP):
Configuration.scope({constants.IP : sessionDict[constants.IP],
constants.PORT: sessionDict[constants.PORT]})
elif sessionDict.has_key(constants.UNIXPATH):
Configuration.scope({constants.UNIXPATH : sessionDict[constants.UNIXPATH]})
示例7: Copyright
########################################################################
# Copyright (C) 2002 Andrew T. Csillag <[email protected]>
#
# You may distribute under the terms of either the GNU General
# Public License or the SkunkWeb License, as specified in the
# README file.
########################################################################
from SkunkWeb import Configuration
import PyPgSQLcache
Configuration.mergeDefaults(
PyPgSQLConnectParams = {},
)
for u, p in Configuration.PyPgSQLConnectParams.items():
PyPgSQLcache.initUser ( u, p )
def rollback(*args):
for v in PyPgSQLcache._connections.values():
v.rollback()
from requestHandler.requestHandler import CleanupRequest
CleanupRequest.addFunction(rollback)
示例8: SIGALRMHandler
def SIGALRMHandler(*args):
Configuration.trim()
ERROR('Throwing timeout exception')
signal.alarm(1) # in case they catch this exception
raise DocumentTimeout, "timeout reached"
示例9: Copyright
# Copyright (C) 2001 Andrew T. Csillag <[email protected]>
#
# You may distribute under the terms of either the GNU General
# Public License or the SkunkWeb License, as specified in the
# README file.
#
########################################################################
from SkunkWeb import Configuration
import MySQL
from SkunkExcept import SkunkStandardError
from requestHandler.requestHandler import CleanupRequest
Configuration.mergeDefaults(
MySQLConnectParams = {},
MySQLRollback=0,
MySQLTestFunc=None
)
# add test function (used by MySQL connection cache to test
# connections before handing them out)
MySQL.connection_test=Configuration.MySQLTestFunc
for u, p in Configuration.MySQLConnectParams.items():
MySQL.initUser(u, p)
# optional rollback
def rollback(*args):
for v in MySQL._connections.values():
try:
v.rollback()
示例10:
import SkunkWeb.Configuration as C
C.mergeDefaults(MvcOn=False)
示例11: Copyright
########################################################################
# Copyright (C) 2004 Andrew T. Csillag <[email protected]>,
# Jacob Smullyan <[email protected]>
#
# You may distribute under the terms of either the GNU General
# Public License or the SkunkWeb License, as specified in the
# README file.
########################################################################
from SkunkWeb import Configuration
import PsycopgCache
Configuration.mergeDefaults(PsycopgConnectParams = {})
for u, p in Configuration.PsycopgConnectParams.items():
PsycopgCache.initUser (u, p)
def rollback(*args):
for v in PsycopgCache._connections.values():
v.rollback()
from requestHandler.requestHandler import CleanupRequest
CleanupRequest.addFunction(rollback)
示例12: getCurrentSlot
import os
import datetime
import computils
from AE.Component import DT_INCLUDE
import SkunkWeb.Configuration as C
C.mergeDefaults(skinDir='/comp/skins',
defaultSkin='default')
import threading
_local=threading.local()
_local.SLOTSTACK=[]
def getCurrentSlot():
if _local.SLOTSTACK:
return _local.SLOTSTACK[-1]
def push_slot(slot):
_local.SLOTSTACK.append(slot)
def pop_slot():
if _local.SLOTSTACK:
_local.SLOTSTACK.pop()
class Slot(object):
def __init__(self, name):
self.name=name
class ComponentSlot(Slot):
def __init__(self, name, compname, comptype=None, cache=computils.NO, **kw):
Slot.__init__(self, name)
示例13: _do_redirect
import SkunkWeb.Configuration as Cfg
from SkunkWeb import Context
from web.protocol import RouteConnection
from SkunkWeb.constants import WEB_JOB
# the controller service is required
import controller
# make sure that the context object is installed
import context
from mvc.log import debug
__all__=['url_for', 'redirect_to']
Cfg.mergeDefaults(routes=[])
def _do_redirect(url):
Context.Connection.redirect(url)
def routing_hook(connection, sessionDict):
if not Cfg.MvcOn:
return
debug("in routing hook")
# initialize routes request config
rcfg=request_config()
rcfg.redirect=_do_redirect
rcfg.mapper=map=Mapper()
rcfg.host=connection.host
if connection.env.get('HTTPS', False):
rcfg.protocol='HTTPS'
示例14: __initConfig
def __initConfig():
from SkunkWeb import Configuration
Configuration.mergeDefaults(DocumentTimeout=30,
PostResponseTimeout=20,
job=None)
示例15: _endSession
def _endSession(sessionDict):
try:
EndSession(Configuration.job, sessionDict)
except:
logException()
Configuration.trim()