After the recursion guard bit me again (I spent some hours already a few weeks 
ago!),
I decided to write some documentation for the issue which should be added to
http://docs.turbogears.org/1.0/ValidateDecorator.

Unfortunately, this is (again) an "official" site which I can't edit.

fs

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Docs" 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/turbogears-docs?hl=en
-~----------~----~----~----~------~----~------~--~---

Be aware of the recursion guard
-------------------------------

The validate decorator has a built-in "recursion guard" which should prevent
unwanted recursions. Unfortunately, the current implementation (1.0.x) causes
some side effects which may affect you:

- Parameters for functions named "validate" won't get validated despite a 
correctly placed validate decorator. The only workaround is to choose a 
different name. 
- The validate decorator will only be called once per request. This can be a 
problem if you call other exposed methods from another method.

The latter can be demonstrated with the following controller example snippet  ::

    @expose()
    @validate(validators={"userid": validators.String()})
    def foo(self, userid=None, tg_errors=None):
       return self.bar(userid=userid)

    @expose()
    @validate(validators={"userid": validators.String()})
    def foo(self, userid=None, tg_errors=None):
        # userid is not validated if the call came from foo()
        return userid

Reply via email to