create util module with functions shared across files

This commit is contained in:
Mark McClain
2011-01-20 10:06:53 -05:00
parent f500bd0d78
commit dd35ca8d02
5 changed files with 12 additions and 11 deletions

View File

@@ -1,9 +1,5 @@
from inspect import getargspec
def _cfg(f):
if not hasattr(f, '_pecan'): f._pecan = {}
return f._pecan
from util import _cfg
def when_for(controller):
def when(method=None, **kw):
@@ -15,7 +11,6 @@ def when_for(controller):
return decorate
return when
def expose(template = None,
content_type = 'text/html',
schema = None,

View File

@@ -1,5 +1,5 @@
from routing import iscontroller
from webob.exc import HTTPFound
from util import iscontroller
__all__ = ['PecanHook', 'TransactionHook', 'HookController']

View File

@@ -2,7 +2,8 @@ from inspect import getargspec, ismethod
from core import abort, request
from decorators import expose
from routing import iscontroller, lookup_controller
from routing import lookup_controller
from util import iscontroller
class RestController(object):

View File

@@ -1,6 +1,8 @@
from webob import exc
from inspect import ismethod
from secure import handle_security, cross_boundary
from util import iscontroller
__all__ = ['lookup_controller', 'find_object']
@@ -73,6 +75,3 @@ def find_object(obj, remainder, notfound_handlers):
next, remainder = remainder[0], remainder[1:]
prev_obj = obj
obj = getattr(obj, next, None)
def iscontroller(obj):
return getattr(obj, 'exposed', False)

6
pecan/util.py Normal file
View File

@@ -0,0 +1,6 @@
def iscontroller(obj):
return getattr(obj, 'exposed', False)
def _cfg(f):
if not hasattr(f, '_pecan'): f._pecan = {}
return f._pecan