Changeset 760
- Timestamp:
- 02/13/06 04:04:08 (3 years ago)
- Files:
-
- trunk/turbogears/errorhandling.py (modified) (2 diffs)
- trunk/turbogears/tests/test_errorhandling.py (modified) (2 diffs)
- trunk/turbogears/util.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/turbogears/errorhandling.py
r756 r760 7 7 8 8 import turbogears.util as tg_util 9 from turbogears.decorator import decorator10 9 11 10 … … 139 138 return registrant 140 139 141 def bind_args(**add):142 """ Call with additional arguments. """143 def entagle(registrant):144 def call(handler, rules=None):145 def newhandler(handler, *args, **kw):146 kw.update(add)147 return handler(*args, **kw)148 return registrant(decorator(newhandler)(handler), rules)149 return call150 return entagle151 152 140 __all__ = ["dispatch_error", "dispatch_error_adaptor", "try_call", 153 "run_with_errors", "default", "register_handler" , "bind_args"]141 "run_with_errors", "default", "register_handler"] trunk/turbogears/tests/test_errorhandling.py
r756 r760 6 6 from turbogears.controllers import error_handler, exception_handler, \ 7 7 expose, validate 8 from turbogears. errorhandlingimport bind_args8 from turbogears.util import bind_args 9 9 from turbogears import validators 10 10 from turbogears import testutil … … 134 134 def bindargs(self, bar=""): 135 135 return dict(title="Bind arguments to error handler") 136 bindargs = bind_args(baz=123)(error_handler)(simpleerrorhandler)(bindargs)136 bindargs = error_handler(bind_args(baz=123)(simpleerrorhandler))(bindargs) 137 137 bindargs = validate(validators={"bar":validators.Int()})(bindargs) 138 138 bindargs = expose()(bindargs) trunk/turbogears/util.py
r753 r760 8 8 import pkg_resources 9 9 import setuptools 10 11 from turbogears.decorator import decorator 10 12 11 13 … … 225 227 return args, kw 226 228 229 def bind_args(**add): 230 """ Call with arguments set to a predefined value. """ 231 def entagle(func): 232 def call(func, *args, **kw): 233 kw.update(add) 234 return func(*args, **kw) 235 return decorator(call)(func) 236 return entagle 237 227 238 __all__ = ["Enum", "setlike", "get_package_name", "get_model", 228 239 "DictObj", "DictWrapper", "url", "ensure_sequence", 229 240 "to_kw", "from_kw", "remove_excess_args", "infinite_recursion", 230 "arg_pos", "inject_arg" ]241 "arg_pos", "inject_arg", "bind_args"]