From dd35ca8d026ff34ecb5a7766ff5034582440a0b7 Mon Sep 17 00:00:00 2001 From: Mark McClain Date: Thu, 20 Jan 2011 10:06:53 -0500 Subject: [PATCH] create util module with functions shared across files --- pecan/decorators.py | 7 +------ pecan/hooks.py | 2 +- pecan/rest.py | 3 ++- pecan/routing.py | 5 ++--- pecan/util.py | 6 ++++++ 5 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 pecan/util.py diff --git a/pecan/decorators.py b/pecan/decorators.py index 3a9164a..258423a 100644 --- a/pecan/decorators.py +++ b/pecan/decorators.py @@ -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, diff --git a/pecan/hooks.py b/pecan/hooks.py index 9d64c39..f76f22a 100644 --- a/pecan/hooks.py +++ b/pecan/hooks.py @@ -1,5 +1,5 @@ -from routing import iscontroller from webob.exc import HTTPFound +from util import iscontroller __all__ = ['PecanHook', 'TransactionHook', 'HookController'] diff --git a/pecan/rest.py b/pecan/rest.py index bbd56d4..edb9e62 100644 --- a/pecan/rest.py +++ b/pecan/rest.py @@ -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): diff --git a/pecan/routing.py b/pecan/routing.py index e545c16..fa7a163 100644 --- a/pecan/routing.py +++ b/pecan/routing.py @@ -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) diff --git a/pecan/util.py b/pecan/util.py new file mode 100644 index 0000000..b4aeb12 --- /dev/null +++ b/pecan/util.py @@ -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