def _munge_debug(): _SR.registerService('hoptime.service', 'HOPTIME') HOPTIME = _SR.HOPTIME def _debug(message): _d(HOPTIME, str(message)) hopapi.DEBUG = _debug
# # You may distribute under the terms of either the GNU General # Public License or the SkunkWeb License, as specified in the # README file. # # $Id: userdir.py,v 1.7 2003/05/01 20:45:53 drew_csillag Exp $ ######################################################################## import pwd from SkunkWeb import Configuration Configuration.mergeDefaults(userDir = 1, userDirPath = 'public_html') from SkunkWeb import ServiceRegistry ServiceRegistry.registerService('userdir') from SkunkWeb.LogObj import DEBUG from SkunkWeb.ServiceRegistry import USERDIR 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:]
def __initFlag(): ServiceRegistry.registerService("remote")
def __initFlag(): import SkunkWeb.ServiceRegistry as sr sr.registerService('webdav')
# # $Id$ # Time-stamp: <01/05/09 14:36:02 smulloni> ######################################################################## import AE.Component import exceptions import new import socket import SocketScience import cPickle import types from SkunkWeb.LogObj import DEBUG, logException from SkunkWeb import ServiceRegistry ServiceRegistry.registerService('remote_client') REMOTE_CLIENT=ServiceRegistry.REMOTE_CLIENT SWRC_PROTOCOL="swrc" DEFAULT_PORT=9887 class RemoteException(Exception): """ a class that wraps a remotely raised exception """ def __init__(self, remoteInstance): if isinstance(remoteInstance, Exception): Exception.__init__(self, remoteInstance.args) else: Exception.__init__(self, remoteInstance) self.remoteInstance=remoteInstance
harmless. Then log using a log format like this: LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %{SKUNKTREK_ID}e" cookie-combined Note that this only logs *incoming* cookies. This means that clients who don't accept cookies won't generate spurious usertracking ids in the apache logs, which is apparently a problem with apache's mod_usertrack. """ from SkunkWeb import Configuration, ServiceRegistry from SkunkWeb.LogObj import DEBUG from uuid import uuid import time import Cookie ServiceRegistry.registerService('usertracking') USERTRACKING=ServiceRegistry.USERTRACKING _cookie_attrs=('path', 'expires', 'domain', 'comment', 'version', 'max-age') _config_attrs=tuple([("usertrackingCookie%s" % \ x.replace('-', '_').capitalize(), x) \ for x in _cookie_attrs]) Configuration.mergeDefaults( # whether usertracking is on
# Copyright (C) 2002 Jacob Smullyan <*****@*****.**> # # 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 ServiceRegistry, Configuration from SkunkWeb.LogObj import DEBUG, logException import AE.Cache import vfs import os, sys import cStringIO import rfc822 ServiceRegistry.registerService('pycgi') PYCGI=ServiceRegistry.PYCGI # use templating's 404 handler if it is already imported, # or is about to be loaded, to the extent possible to determine. # this is cut-and-pasted from rewrite.py, which is unfortunate; # I should put this is a separate place, but where? if sys.modules.has_key('templating') \ or 'templating' in Configuration.services: import templating fourOhFourHandler=templating.Handler.fourOhFourHandler else: def fourOhFourHandler(connection, sessionDict): connection.setStatus(404)
# 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, ServiceRegistry from SkunkWeb.LogObj import DEBUG from requestHandler.protocol import PreemptiveResponse import AE.Cache import os import Authenticator import sys import base64 Configuration.mergeDefaults(basicAuthName=None, basicAuthFile=None) ServiceRegistry.registerService("basicauth") AUTH = ServiceRegistry.BASICAUTH def getAuthorizationFromHeaders(conn, sessionDict): """ pulls REMOTE_USER, REMOTE_PASSWORD, and AUTH_TYPE out of request headers. """ DEBUG(AUTH, "looking for authorization headers") auth = conn.requestHeaders.get( 'Authorization', conn.requestHeaders.get('Proxy-Authorization')) if auth: DEBUG(AUTH, "found authorization") conn.authType, ai = auth.split() ucp = base64.decodestring(ai) colon_idx = ucp.find(':')
``rewrite.RewriteCond``, that performs most of the tests you'll want to perform -- exactly the same tests as you would perform while scoping. By default, all of your rewrite rules will be applied, one by one. But if you want it to stop after the first match, set ``Configuration.rewriteApplyAll`` to a false value. This service used to contain a series of hooks and the ability to use them to manipulate the list of rewrite rules at runtime. These were relatively expensive and seemed to offer little functionality, so they have been removed. """ from SkunkWeb import ServiceRegistry, Configuration, constants ServiceRegistry.registerService('rewrite') from SkunkWeb.LogObj import DEBUG, logException from SkunkWeb.ServiceRegistry import REWRITE import re import sys from requestHandler.protocol import PreemptiveResponse from skunklib import normpath def _fixPath(root, path): return normpath('%s/%s' % (root,path)) Configuration.mergeDefaults(rewriteBeforeScope=1, rewriteRules = [], rewriteApplyAll = 1, rewriteMatchToArgs=1)
def __initFlag(): from SkunkWeb import ServiceRegistry ServiceRegistry.registerService("userdir")
# # Copyright (C) 2002 Drew Csillag <*****@*****.**> # # You may distribute under the terms of either the GNU General # Public License or the SkunkWeb License, as specified in the # README file. # # $Id$ ######################################################################## from SkunkWeb import Configuration, ServiceRegistry, Hooks from SkunkWeb.LogObj import DEBUG Configuration.mergeDefaults(pspTemplateTypes=[], pspTopLevelInterpret=1) ServiceRegistry.registerService('psptemplate') PSP=ServiceRegistry.PSPTEMPLATE from DT import DT_REGULAR, DT_DATA, DT_INCLUDE import AE.Cache import AE.CodeSources import AE.Executables import psp PSP_CACHEFILE_VERSION = 1 def _pspCompileFunc( name, data ): return psp.psp_compile( data, name ) def getPSPCode( name, srcModTime ): return AE.Cache._getCompiledThing( name, srcModTime, 'psptemplate', _pspCompileFunc,
def __initFlag(): from SkunkWeb import ServiceRegistry ServiceRegistry.registerService('web', 'WEB')
def __initFlag(): from SkunkWeb import ServiceRegistry ServiceRegistry.registerService('userdir')
# # You may distribute under the terms of either the GNU General # Public License or the SkunkWeb License, as specified in the # README file. # # $Id$ ######################################################################## import pwd from SkunkWeb import Configuration Configuration.mergeDefaults(userDir = 1, userDirPath = 'public_html') from SkunkWeb import ServiceRegistry ServiceRegistry.registerService('userdir') from SkunkWeb.LogObj import DEBUG from SkunkWeb.ServiceRegistry import USERDIR 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:]
# Copyright (C) 2002 Jacob Smullyan <*****@*****.**> # # 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 ServiceRegistry, Configuration from SkunkWeb.LogObj import DEBUG, logException import AE.Cache import vfs import os, sys import cStringIO import rfc822 ServiceRegistry.registerService('pycgi') PYCGI = ServiceRegistry.PYCGI # use templating's 404 handler if it is already imported, # or is about to be loaded, to the extent possible to determine. # this is cut-and-pasted from rewrite.py, which is unfortunate; # I should put this is a separate place, but where? if sys.modules.has_key('templating') \ or 'templating' in Configuration.services: import templating fourOhFourHandler = templating.Handler.fourOhFourHandler else: def fourOhFourHandler(connection, sessionDict):
# # $Id: remote_client.py,v 1.5 2003/05/01 20:45:53 drew_csillag Exp $ # Time-stamp: <01/05/09 14:36:02 smulloni> ######################################################################## import AE.Component import exceptions import new import socket import SocketScience import cPickle import types from SkunkWeb.LogObj import DEBUG, logException from SkunkWeb import ServiceRegistry ServiceRegistry.registerService('remote_client') REMOTE_CLIENT = ServiceRegistry.REMOTE_CLIENT SWRC_PROTOCOL = "swrc" DEFAULT_PORT = 9887 class RemoteException(Exception): """ a class that wraps a remotely raised exception """ def __init__(self, remoteInstance): if isinstance(remoteInstance, Exception): Exception.__init__(self, remoteInstance.args) else: Exception.__init__(self, remoteInstance)
# # Copyright (C) 2002 Drew Csillag <*****@*****.**> # # You may distribute under the terms of either the GNU General # Public License or the SkunkWeb License, as specified in the # README file. # # $Id$ ######################################################################## from SkunkWeb import Configuration, ServiceRegistry, Hooks from SkunkWeb.LogObj import DEBUG Configuration.mergeDefaults(pspTemplateTypes=[], pspTopLevelInterpret=1) ServiceRegistry.registerService('psptemplate') PSP = ServiceRegistry.PSPTEMPLATE from DT import DT_REGULAR, DT_DATA, DT_INCLUDE import AE.Cache import AE.CodeSources import AE.Executables import psp PSP_CACHEFILE_VERSION = 1 def _pspCompileFunc(name, data): return psp.psp_compile(data, name) def getPSPCode(name, srcModTime):
def __initFlag(): from SkunkWeb import ServiceRegistry ServiceRegistry.registerService('requestHandler')
# README file. # # $Id: aecgi.py,v 1.4 2003/05/01 20:45:53 drew_csillag Exp $ # Time-stamp: <01/05/04 17:32:39 smulloni> ######################################################################## from SkunkWeb import Configuration, ServiceRegistry, Hooks from SkunkWeb.LogObj import DEBUG import requestHandler.protocol import requestHandler.requestHandler from requestHandler.protocol import RequestFailed import SocketScience import marshal ServiceRegistry.registerService('aecgi') AECGI=ServiceRegistry.AECGI class AecgiProtocol(requestHandler.protocol.Protocol): """ protocol used to communicate with Apache via mod_skunkweb """ def marshalRequest(self, sock, sessionDict): """ Sends a handshake byte, obtains the content length from the value of the first ten bytes read, and then reads no more than that amount, which it marshals with the 'marshal' module. Finally, returns the marshalled request data """ SocketScience.send_it_all(sock, '\0')
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. # #$Id$ from SkunkWeb import Configuration, ServiceRegistry, LogObj import marshal import errno import stat ServiceRegistry.registerService('pars') PARS=ServiceRegistry.PARS DEBUG=LogObj.DEBUG Configuration.mergeDefaults( parFiles = [], parFallthrough = 1 ) import templating import AE.Cache parDirs = {} parContents = {} def _loadParfiles(f):
# from SkunkWeb import Configuration, ServiceRegistry from SkunkWeb.LogObj import DEBUG from requestHandler.protocol import PreemptiveResponse import AE.Cache import os import Authenticator import sys import base64 Configuration.mergeDefaults( basicAuthName = None, basicAuthFile = None ) ServiceRegistry.registerService("basicauth") AUTH=ServiceRegistry.BASICAUTH def getAuthorizationFromHeaders(conn, sessionDict): """ pulls REMOTE_USER, REMOTE_PASSWORD, and AUTH_TYPE out of request headers. """ DEBUG(AUTH, "looking for authorization headers") auth = conn.requestHeaders.get('Authorization', conn.requestHeaders.get('Proxy-Authorization')) if auth: DEBUG(AUTH, "found authorization") conn.authType, ai = auth.split() ucp = base64.decodestring(ai) colon_idx = ucp.find(':') conn.remoteUser = ucp[:colon_idx]
# Public License or the SkunkWeb License, as specified in the # README file. # # $Id$ # Time-stamp: <01/05/04 17:32:39 smulloni> ######################################################################## from SkunkWeb import Configuration, ServiceRegistry, Hooks from SkunkWeb.LogObj import DEBUG, ERROR import requestHandler.protocol import requestHandler.requestHandler import SocketScience import skunklib import fcgi ServiceRegistry.registerService('fcgiprot') FCGIPROT = ServiceRegistry.FCGIPROT RequestFailed = Hooks.KeyedHook() class sockfile: def __init__(self): self.contents = [] def send(self, c): DEBUG(FCGIPROT, 'sending %s' % c) self.contents.append(c) def value(self): return ''.join(self.contents)
def __initFlag(): from SkunkWeb import ServiceRegistry ServiceRegistry.registerService('web', 'WEB') import SkunkWeb.Configuration as C C.mergeDefaults(mergeQueryStringWithPostData=1, HttpLoggingOn=0)
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. # # $Id$ # Time-stamp: <01/05/09 14:36:02 smulloni> ######################################################################## import AE.Component import exceptions import socket import SocketScience import cPickle import types from SkunkWeb.LogObj import DEBUG, logException from SkunkWeb import ServiceRegistry ServiceRegistry.registerService("remote_client") REMOTE_CLIENT = ServiceRegistry.REMOTE_CLIENT SWRC_PROTOCOL = "swrc" DEFAULT_PORT = 9887 class RemoteException: pass def getRemoteException(realException): """ dynamically creates a RemoteException mixin with the realException's class, and keeps a copy of the realException in the 'remoteInstance'
# (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. # from SkunkWeb import Configuration, LogObj, ServiceRegistry from requestHandler.requestHandler import CleanupRequest import Oracle ServiceRegistry.registerService('oracle') Configuration.mergeDefaults( OracleConnectStrings = {}, OracleProcedurePackageLists = {} ) for u, str in Configuration.OracleConnectStrings.items(): LogObj.DEBUG(ServiceRegistry.ORACLE, 'initializing user %s' % u) Oracle.initUser(u, str) for u, pkglist in Configuration.OracleProcedurePackageLists: Oracle.loadSignatures(u, pkglist, LogObj.LOG, lambda x: LogObj.DEBUG(ServiceRegistry.ORACLE, x)) def rollbackConnection(*args):
# You may distribute under the terms of either the GNU General # Public License or the SkunkWeb License, as specified in the # README file. # # Time-stamp: <01/05/04 17:32:39 smulloni> ######################################################################## from SkunkWeb import Configuration, ServiceRegistry, Hooks from SkunkWeb.LogObj import DEBUG, ERROR import requestHandler.protocol import requestHandler.requestHandler import SocketScience import skunklib import fcgi ServiceRegistry.registerService('fcgiprot') FCGIPROT=ServiceRegistry.FCGIPROT RequestFailed=Hooks.KeyedHook() class sockfile: def __init__(self): self.contents=[] def send(self, c): DEBUG(FCGIPROT, 'sending %s' % c) self.contents.append(c) def value(self): return ''.join(self.contents)
from SkunkWeb.LogObj import DEBUG, ERROR, logException from requestHandler.protocol import PreemptiveResponse import AE.Cache import AE.Component import os import Authenticator import sys import base64 import armor Configuration.mergeDefaults( authAuthorizer = None, authActivated = None, authAuthorizerCtorArgs = (), ) ServiceRegistry.registerService("auth") AUTH=ServiceRegistry.AUTH class OK(Exception): pass # an authorizer #class authorizer: # def __init__(self, ......): # """ # The ...... will be filled with the contents of # Configuration.authAuthorizerCtorArgs when this object is instantiated. # """ # # def checkCredentials(self, conn): # """ # Examine the connection however you see fit to see if the
``rewrite.RewriteCond``, that performs most of the tests you'll want to perform -- exactly the same tests as you would perform while scoping. By default, all of your rewrite rules will be applied, one by one. But if you want it to stop after the first match, set ``Configuration.rewriteApplyAll`` to a false value. This service used to contain a series of hooks and the ability to use them to manipulate the list of rewrite rules at runtime. These were relatively expensive and seemed to offer little functionality, so they have been removed. """ from SkunkWeb import ServiceRegistry, Configuration, constants ServiceRegistry.registerService('rewrite') from SkunkWeb.LogObj import DEBUG, logException from SkunkWeb.ServiceRegistry import REWRITE import re import sys from requestHandler.protocol import PreemptiveResponse from skunklib import normpath def _fixPath(root, path): return normpath('%s/%s' % (root, path)) Configuration.mergeDefaults(rewriteBeforeScope=1, rewriteRules=[], rewriteApplyAll=1,
def __initFlag(): import SkunkWeb.ServiceRegistry as reg reg.registerService('sessionHandler')
def __initFlag(): ServiceRegistry.registerService('remote')
# You may distribute under the terms of either the GNU General # Public License or the SkunkWeb License, as specified in the # README file. # # Time-stamp: <01/05/04 17:32:39 smulloni> ######################################################################## from SkunkWeb import Configuration, ServiceRegistry, Hooks from SkunkWeb.LogObj import DEBUG, DEBUGIT, logException import os import select import sys import rfc822 import cStringIO ServiceRegistry.registerService('extcgi') EXTCGI=ServiceRegistry.EXTCGI Configuration.mergeDefaults(CGIProgram = None, CGIProgramArgs = (), CGIProgramBase = '') def _fix(dict): #fixup the environment variables nd = {} for k,v in dict.items(): nd[str(k)] = str(v) pb = Configuration.CGIProgramBase if nd["SCRIPT_NAME"][:len(pb)] == pb: remnant = nd["SCRIPT_NAME"][len(pb):] if remnant: nd["PATH_INFO"] = '/' + remnant
def __initFlag(): from SkunkWeb import ServiceRegistry ServiceRegistry.registerService('templating')
from SkunkWeb.LogObj import DEBUG, ERROR, logException from requestHandler.protocol import PreemptiveResponse import AE.Cache import AE.Component import os import Authenticator import sys import base64 import armor Configuration.mergeDefaults( authAuthorizer=None, authActivated=None, authAuthorizerCtorArgs=(), ) ServiceRegistry.registerService("auth") AUTH = ServiceRegistry.AUTH class OK(Exception): pass # an authorizer #class authorizer: # def __init__(self, ......): # """ # The ...... will be filled with the contents of # Configuration.authAuthorizerCtorArgs when this object is instantiated. # """ #
def _munge_debug(): _SR.registerService('hoptime.service', 'HOPTIME') HOPTIME=_SR.HOPTIME def _debug(message): _d(HOPTIME, str(message)) hopapi.DEBUG=_debug
# You may distribute under the terms of either the GNU General # Public License or the SkunkWeb License, as specified in the # README file. # # Time-stamp: <01/05/04 17:32:39 smulloni> ######################################################################## from SkunkWeb import Configuration, ServiceRegistry, Hooks from SkunkWeb.LogObj import DEBUG, DEBUGIT, logException import os import select import sys import rfc822 import cStringIO ServiceRegistry.registerService('extcgi') EXTCGI = ServiceRegistry.EXTCGI Configuration.mergeDefaults(CGIProgram=None, CGIProgramArgs=(), CGIProgramBase='') def _fix(dict): #fixup the environment variables nd = {} for k, v in dict.items(): nd[str(k)] = str(v) pb = Configuration.CGIProgramBase if nd["SCRIPT_NAME"][:len(pb)] == pb: remnant = nd["SCRIPT_NAME"][len(pb):] if remnant:
# README file. # # $Id: aecgi.py,v 1.4 2003/05/01 20:45:53 drew_csillag Exp $ # Time-stamp: <01/05/04 17:32:39 smulloni> ######################################################################## from SkunkWeb import Configuration, ServiceRegistry, Hooks from SkunkWeb.LogObj import DEBUG import requestHandler.protocol import requestHandler.requestHandler from requestHandler.protocol import RequestFailed import SocketScience import marshal ServiceRegistry.registerService('aecgi') AECGI = ServiceRegistry.AECGI class AecgiProtocol(requestHandler.protocol.Protocol): """ protocol used to communicate with Apache via mod_skunkweb """ def marshalRequest(self, sock, sessionDict): """ Sends a handshake byte, obtains the content length from the value of the first ten bytes read, and then reads no more than that amount, which it marshals with the 'marshal' module. Finally, returns the marshalled request data """ SocketScience.send_it_all(sock, '\0')
# README file. # # $Id$ # Time-stamp: <01/05/04 17:32:39 smulloni> ######################################################################## from SkunkWeb import Configuration, ServiceRegistry, Hooks from SkunkWeb.LogObj import DEBUG import requestHandler.protocol import requestHandler.requestHandler from requestHandler.protocol import RequestFailed import SocketScience import marshal ServiceRegistry.registerService("aecgi") AECGI = ServiceRegistry.AECGI class AecgiProtocol(requestHandler.protocol.Protocol): """ protocol used to communicate with Apache via mod_skunkweb """ def marshalRequest(self, sock, sessionDict): """ Sends a handshake byte, obtains the content length from the value of the first ten bytes read, and then reads no more than that amount, which it marshals with the 'marshal' module. Finally, returns the marshalled request data """