Sean Cazzell wrote:
> If people need something more powerful than a coercer, they can always
> put the code in their method, or if they need it in multiple places,
> write a decorator.  Something like
> 
> @turbogears.expose(...)
> @require_valid_user_id('user_id')
> @turbogears.unpack(...)
> def show_profile(self, user_id):
>    ...

This makes me think it would be nice to do fetching.  For instance,

@unpack()
def show_profile(self, user_id_int_get=User.get): ...


In this case _get would mean that the default was a getter.  If that
returned None or raised a LookupError (SQLObjectNotFound happens to
subclass LookupError) then it would give a 404.

Of course, at a certain point there's too much information in those
signatures, and the variables themselves become rather excessive.  But
the same basic conversions could be described in different ways as well,
maybe like:

@unpack(user=('int_get', User.get))
def show_profile(self, user): ...

Or... something.  I'm not sure.  At a certain point it's no more compact
than just doing the conversions manually.  But I feel like some really
compact and simple method is waiting inside there somewhere.

-- 
Ian Bicking  |  [EMAIL PROTECTED]  |  http://blog.ianbicking.org

Reply via email to