class MyGroupRestController(EasyCrudRestController):
model = model.Group
def before_put(self, *args, **kw):
print args, kw
def __init__(self, *args, **kw):
super(MyGroupRestController, self).__init__(*args, **kw)
before_validate(self.before_put)(self.put)
There are other ways to register the hook, but they should all work correctly.
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/qTqkd_d9t0gJ.
> To post to this group, send email to turbo...@googlegroups.com.
> To unsubscribe from this group, send email to
> turbogears+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=en.
Change it to something like:
class MyGroupRestController(EasyCrudRestController):
model = model.Group
def before_put(self, *args, **kw):
print args, kw
before_validate(MyGroupRestController.before_put)(MyGroupRestController.put)
This is one of the things that are going to change on in 2.3+ which
allocates the controllers only on application startup, in the mean
time you must avoid doing anything that changes the controller class
inside the init itself.
>>> > turbogears+...@googlegroups.com.
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/turbogears?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/LUazTYzarrcJ.
>
> To post to this group, send email to turbo...@googlegroups.com.
> To unsubscribe from this group, send email to
> turbogears+...@googlegroups.com.
>>>> > For more options, visit this group at
>>>> > http://groups.google.com/group/turbogears?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "TurboGears" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/turbogears/-/LUazTYzarrcJ.
>>
>> To post to this group, send email to turbo...@googlegroups.com.
>> To unsubscribe from this group, send email to
About the behavior of the before_validate parameters, that is actually
the right one.
I used *args and **kw just because I'm lazy and didn't want to specify
the right parameters.
The expected before_validate hook signature is:
def before_validate_hook(remainder, params):
if you use *args and **kw you simply get the remainder and the params
inside the args argument :D
>> >>>> > turbogears+...@googlegroups.com.
>> >>>> > For more options, visit this group at
>> >>>> > http://groups.google.com/group/turbogears?hl=en.
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "TurboGears" group.
>> >> To view this discussion on the web visit
>> >> https://groups.google.com/d/msg/turbogears/-/LUazTYzarrcJ.
>> >>
>> >> To post to this group, send email to turbo...@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> turbogears+...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/turbogears?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/Dgo6nOyTDfQJ.
>
> To post to this group, send email to turbo...@googlegroups.com.
> To unsubscribe from this group, send email to
> turbogears+...@googlegroups.com.
>> >>>> > turbogears+unsubscribe@googlegroups.com.
>> >>>> > For more options, visit this group at
>> >>>> > http://groups.google.com/group/turbogears?hl=en.
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "TurboGears" group.
>> >> To view this discussion on the web visit
>> >> https://groups.google.com/d/msg/turbogears/-/LUazTYzarrcJ.
>> >>
>> >> To post to this group, send email to turbo...@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/turbogears?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/Dgo6nOyTDfQJ.
>
> To post to this group, send email to turbo...@googlegroups.com.
> To unsubscribe from this group, send email to