create util module with functions shared across files
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from routing import iscontroller
|
||||
from webob.exc import HTTPFound
|
||||
from util import iscontroller
|
||||
|
||||
|
||||
__all__ = ['PecanHook', 'TransactionHook', 'HookController']
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
6
pecan/util.py
Normal 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
|
||||
Reference in New Issue
Block a user