当前位置: 首页>>代码示例>>Python>>正文


Python SkunkWeb.Configuration类代码示例

本文整理汇总了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())
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:26,代码来源:ae_component.py

示例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
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:31,代码来源:protocol.py

示例3: __initConfig

def __initConfig():
    import SkunkWeb.Configuration as C
    import os
    C.mergeDefaults(
        webdavDB=os.join(C.SkunkRoot, 'var/run/WEBDAVdb'),
        webdavFS=fs.WebdavFS(),
        )
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:7,代码来源:__init__.py

示例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
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:35,代码来源:userdir.py

示例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)
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:33,代码来源:requestHandler.py

示例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]})
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:15,代码来源:protocol.py

示例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)
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:24,代码来源:pypgsqlcache.py

示例8: SIGALRMHandler

def SIGALRMHandler(*args):
    Configuration.trim()
    ERROR('Throwing timeout exception')
    signal.alarm(1) # in case they catch this exception
    raise DocumentTimeout, "timeout reached"
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:5,代码来源:requestHandler.py

示例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()
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:31,代码来源:__init__.py

示例10:

import SkunkWeb.Configuration as C
C.mergeDefaults(MvcOn=False)
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:2,代码来源:_shared.py

示例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)
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:23,代码来源:psycopgcache.py

示例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)
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:31,代码来源:slots.py

示例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'
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:31,代码来源:routing.py

示例14: __initConfig

def __initConfig():
    from SkunkWeb import Configuration
    Configuration.mergeDefaults(DocumentTimeout=30,
                                PostResponseTimeout=20,
                                job=None)
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:5,代码来源:__init__.py

示例15: _endSession

def _endSession(sessionDict):
    try:
        EndSession(Configuration.job, sessionDict)
    except:
        logException()
    Configuration.trim()
开发者ID:BackupTheBerlios,项目名称:skunkweb-svn,代码行数:6,代码来源:requestHandler.py


注:本文中的SkunkWeb.Configuration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。