hi folks,

i'm trying to refactor a set of resource controllers to use a common
base class. all the subclasses need customized validators, and
authorization but their method implementations are generic. both
validation and authorization where previously applied using
decorators. what i'm trying to figure out is how to apply the
decorators to the subclass when their inheriting the method that they
need to apply to. ideally i'd rather not redefine the methods just to
call the base implementation, as it defeats the purpose of eliminating
duplicate code. i would prefer instead to retrieve the function apply
the decorator and place the result in the subclass after its
construction.

class GenericResourceController( BaseControlller ):

   def index( self ):
         ...

class PizzaController( GenericResourceController ):

   form_schema = ...
   permission = ....

pc = PizzaController

class SandwichController( GenericResourceController ):
  form_schema = ...
  permission = ...

sc = SandwhichController

and then do something along the lines of... (not working.. )

PizzaController.index = authorize( validator( pc.index.im_func,
pc.form_schema ), pc.permission )
SandwhichController.index = authorize( validator( sc.index.im_func ),
sc.permission )

is this possible?

thanks,

kapil

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to