« Return to Thread: CrudRestController and @before_validate
Ooooh noo....I think I was doing something incredibily stupid...I'm not sure what I coded yesterday, I don't seem to have saved it, but I think I was using the decorator wrongly.I think it was something like:@before_validate()def before_put(...):Thanks a lot!
Am Montag, 16. April 2012 10:36:07 UTC+2 schrieb Alessandro Molina:How are you registering the decorator? It should work correctly.
I tested it on the fly and it seems to correctly work as expected.class MyGroupRestController(
EasyCrudRestController):
model = model.Groupdef before_put(self, *args, **kw):
print args, kwdef __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.
On Sun, Apr 15, 2012 at 11:54 PM, Moritz Schlarb <mail@...> wrote:
> Hi there!
>
> I'm subclassing EasyCrudRestController and now I have an attribute
> self.event, that I don't want to be changed in the add and edit forms, but
> that needs to be present when writing the form to the database.
> I thought about using a @before_validate hook to simply insert it into
> kwargs, but that doesn't work since @before_validate doesn't seem to get
> called (no logging).
> Another alternative would be using a HiddenField, but then I would have to
> insert the value into the AddForm, which I don't know how to do.
>
> Any help would be nice! ;)
>
> Thanks and good night,
> Moritz
>
> --
> 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 turbogears@....
> To unsubscribe from this group, send email to
> turbogears%2Bunsubscribe@....
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=en .
« Return to Thread: CrudRestController and @before_validate
| Free embeddable forum powered by Nabble | Forum Help |