This part of the pylons code base is very much up to us to figure out
as it was added by Jonathan, Rick and me, at Ben's request.   So if
you have changes you want made just send me an hg bundle and I'll
review them and get them pushed up to Ben for inclusion into pylons.

--Mark

On Jan 23, 2008 11:41 PM, percious <[EMAIL PROTECTED]> wrote:
>
> I think this might be a change to the pylons code base.
>
> I am just having a hard time creating validators where the forms are
> dynamic... Wonder what I would need that for?
>
> -chris
>
> On Jan 23, 9:29 pm, "Mark Ramm" <[EMAIL PROTECTED]> wrote:
> > Hmm, I need to catch up on what happened to validate during the
> > sprint, and perhaps stop banging my head against a wall with 2.4
> > compatability issues that definitely walk the dependency chain back up
> > to pylons...
> >
> > I think there was a notion to make validate into a "real" decorator
> > with no particular hooks in the TurboGears controller's __call__
> > method.   That would make it easy enough to replace the TG validator
> > with custom validators from tosca, or wherever.
> >
> > Max Ishenko also had some ideas on how he would like TG validators to
> > be better, coming from newforms I think.   I think Alberto did a bit
> > of hacking around, but I don't think Max made any validator
> > changes....
> >
> > I'll look into this more and see what's happening.
> >
> > But I'm definitely open to ideas about how to make validation better
> > in TurboGears 2...
> >
> > So, if there's something missing from the current version that was in
> > there before, feel free to add it back.  ;)
> >
> > And if there's something that it should be doing better, (like taking
> > form as a keyword param as mentioned in another thread), I'm open to
> > making those changes too.
> >
> > --Mark Ramm
> >
>
> > On Jan 23, 2008 10:49 PM, percious <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> >
> > > I was wondering why this code has been removed.  I find it very
> > > usefull.
> >
> > > #TODO: Consider depricating this in favor of pylons validate decorator
> > > class validate(object):
> > >     """Validate regesters validator on the decorated function.
> >
> > >     :Parameters:
> > >       validator
> > >         Valdators
> > >       error_handler
> > >         Assign error handler
> > >     """
> > >     def __init__(self, validator=None, error_handler=None, **kw):
> > >         if not hasattr(validator, 'to_python') and hasattr(validator,
> > > 'validator'):
> > >             validator = validator.validator
> > >         elif kw:
> > >             assert validator is None, \
> > >                    'validator must not be specified with additional
> > > keyword arguments'
> > >             validator = kw
> > >         if not isinstance(validator, formencode.Schema):
> > >             validator = _schema(validator)
> > >         self.validator = validator
> > >         self.error_handler = error_handler
> >
> > >     def __call__(self, func):
> > >         deco = TGDecoration.get_decoration(func)
> > >         deco.validator = self.validator
> > >         deco.error_handler = self.error_handler
> > >         return func
> >
> > > The way I use this code is to retrieve the target form from my widget
> > > cache in the following manner:
> >
> > > class DBMechanicValidator(object):
> > >     @property
> > >     def validator(self):
> > >         if not pylons.request.method == 'POST':
> > >             return func(self, *args, **kwargs)
> > >         if post_only:
> > >             params = pylons.request.POST.copy()
> > >         else:
> > >             params = pylons.request.params.copy()
> >
> > >         sprocket = self.sprockets[params['dbsprockets_id']]
> > >         form = sprocket.view.widget
> > >         return form
> >
> > > Now, maybe I could write a formencode.Schema that does the same thing,
> > > but i think I need to be pointed in the right direction to get that
> > > working.
> >
> > > cheers.
> >
> > --
> > Mark Ramm-Christensen
> > email: mark at compoundthinking dot com
> > blog:www.compoundthinking.com/blog
>
> >
>



-- 
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog

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

Reply via email to