You can subscribe to this list here.
2004 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(6) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
(8) |
Nov
(9) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
(13) |
May
(34) |
Jun
(7) |
Jul
(6) |
Aug
(1) |
Sep
(23) |
Oct
(37) |
Nov
(41) |
Dec
(39) |
2006 |
Jan
(19) |
Feb
(1) |
Mar
(5) |
Apr
(9) |
May
(3) |
Jun
(8) |
Jul
(6) |
Aug
(12) |
Sep
(15) |
Oct
(26) |
Nov
(7) |
Dec
(11) |
2007 |
Jan
(12) |
Feb
(6) |
Mar
(13) |
Apr
(14) |
May
(12) |
Jun
(8) |
Jul
(3) |
Aug
|
Sep
(4) |
Oct
(19) |
Nov
(9) |
Dec
|
2008 |
Jan
(14) |
Feb
(3) |
Mar
(11) |
Apr
(6) |
May
(18) |
Jun
(15) |
Jul
(1) |
Aug
(23) |
Sep
(18) |
Oct
(39) |
Nov
(11) |
Dec
(16) |
2009 |
Jan
(8) |
Feb
(9) |
Mar
(33) |
Apr
(16) |
May
(5) |
Jun
(3) |
Jul
(2) |
Aug
(2) |
Sep
(1) |
Oct
(6) |
Nov
(11) |
Dec
(2) |
2010 |
Jan
(2) |
Feb
(4) |
Mar
|
Apr
|
May
(2) |
Jun
(3) |
Jul
(2) |
Aug
|
Sep
(3) |
Oct
|
Nov
|
Dec
|
2011 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
(10) |
Aug
(36) |
Sep
(8) |
Oct
(1) |
Nov
|
Dec
(10) |
2012 |
Jan
(3) |
Feb
(5) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
(15) |
Aug
|
Sep
(9) |
Oct
|
Nov
|
Dec
(1) |
2013 |
Jan
(3) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(10) |
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
(4) |
2015 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
(1) |
Nov
(2) |
Dec
|
2018 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Michael J. <pri...@gm...> - 2012-07-21 18:09:37
|
Hi there, i have a schema validator and want to use another compound validator (SimpleFormValidator) from within the schema. E.g. I do something along the lines: def validate_text(value_dict, state, validator): # validation of text_field goes here. check value_dict for bool_field's value to determine what to do next. class ProductConfigurationSchema(Schema): filter_extra_fields = True allow_extra_fields = True bool_field = validators.Bool() text_field = SimpleFormValidator(validate_text) This does not work as the schema does not expect that its fields are compound validators. It doesn't pass the value_dict to the SimpleFormValidator but rather a single value. This results in the following errror in SimpleFormValidators to_python method: value_dict = value_dict.copy() AttributeError: 'unicode' object has no attribute 'copy' I followed that route because I want to achieve the following: The visibility of the text_field depends on the bool_field. Therefore I'd thought I write a custom method that checks the state of the bool when validating the text_field. If it is set, I would perform the actual validation. If the bool is not set, the text_field is irrelevant and validating would essentially be a no-op. Any tip how to tackle this? Cheers, prinz. |
From: Jonathan V. <jva...@2x...> - 2012-07-12 17:23:24
|
so, after going through the htmfill and rewritingparser code for a bit ( and HtmlParser ), i'll sadly have to give up on this attempt to patch Formencode. I was able to get the text input fields to work pretty easily , but the textareas were next on my list . the current implementation doesn't have access to the inner content of the textarea ( where the value is, whereas input elements access the nodes' start-tag attributes ), and instead depends on the submitted default ( or error ) -- otherwise rendering an empty node. it looks like formencode would have to be radically restructured itself, and the integration with HtmlParrser changed a lot as well, for this work. I'll work on adjusting my code instead. thanks again , Chris. |
From: Jonathan V. <jva...@2x...> - 2012-07-12 14:58:01
|
On Jul 12, 2012, at 10:37 AM, Chris Lambacher wrote: > Hi, > > htmlfill does not need to take a whole page as input and running htmlfill over a particular form is likely to give you the result you want (see below). However, your second suggestion sounds like a good one, and I would also consider a patch teaching htmlfill about more than one form. Chris- That's a great idea -- breaking the forms into separate functions. I'm using Mako under Pyramid with a validation routine that is very familiar to Formencode's usage under pylons, where a "reprint" of the entire template would be triggered. I could probably rewrite my support library ( https://github.com/jvanasco/pyramid_formencode_classic ) to handle partial forms , and slightly change the logic. I'll jump into formencode proper for an hour today though, and see if I can figure out a way to handle multiple forms. |
From: Chris L. <ch...@ka...> - 2012-07-12 14:37:27
|
Hi, htmlfill does not need to take a whole page as input and running htmlfill over a particular form is likely to give you the result you want (see below). However, your second suggestion sounds like a good one, and I would also consider a patch teaching htmlfill about more than one form. The easiest way to do this will htmlfill as it is now will depend on how you render your pages. I'll use Mako, as an example. You can create a def for the form something like this: <%def name="renderform()" buffer="True"> <input type="text" name="name" value="fill"> <select name="occupation"> <option value="">Default</option> <option value="Crazy Cultist">Crazy cultist</option> </select> <textarea cols="20" style="width: 100%" name="address"> An address</textarea> <input type="radio" name="living" value="yes"> <input type="radio" name="living" value="no"> <input type="checkbox" name="nice_guy" checked="checked"> </%def> and then place the form and htmlfill it like so: <% defaults = dict(name='Bob Jones', occupation='Crazy Cultist', address='14 W. Canal\nNew Guinea', living='no', nice_guy=0) %> ${htmlfill.render(renderform(), defaults)} will result in: <input type="text" name="name" value="Bob Jones"> <select name="occupation"> <option value="">Default</option> <option value="Crazy Cultist" selected="selected">Crazy cultist</option> </select> <textarea cols="20" style="width: 100%" name="address">14 W. Canal New Guinea</textarea> <input type="radio" name="living" value="yes"> <input type="radio" name="living" value="no" checked="checked"> <input type="checkbox" name="nice_guy"> This limits the htmlfill to the one form in question. You can probably pass the result of functools.partial from your controller to have the defaults, errors, etc all pre-bound to the function ahead of time. Something like: formfillfn = functools.partial(htmlfill.render, defaults=pre_computed_defaults, errors=pre_computed_errors) then the call above can be changed to filter syntax: ${renderform() | formfillfn} I don't use Jinja but it looks like you could do this for the functools.partial method: {% filter formfillfn %} <input type="text" name="name" value="fill"> <select name="occupation"> <option value="">Default</option> <option value="Crazy Cultist">Crazy cultist</option> </select> <textarea cols="20" style="width: 100%" name="address"> An address</textarea> <input type="radio" name="living" value="yes"> <input type="radio" name="living" value="no"> <input type="checkbox" name="nice_guy" checked="checked"> {% endfilter %} -Chris On Wed, Jul 11, 2012 at 6:48 PM, Jonathan Vanasco <jva...@2x...> wrote: > hoping someone can give me a suggestion : > > I sometimes have two forms displayed on a single page. They're validated > separately and submitted to different locations. ( this is under pylons > and pyramid ) > > example: > the left side of the screen shows Account Data > the right side of the screen has a "change password" and "change > email" field > > > If i use htmlfill.render on this page to reprint on an error the following > behavior happens: > > 1) default settings > - the validated form looks like i want it to > -- there are errors displayed > -- the 'invalid' fields are blank > -- the 'valid' fields are filled > - the non-validated forms are all blank > > 2) force_defaults=False > - the non-validated forms have their default values > - the validated form loses all the submitted values > > does anyone have a suggestion on how i can achieve this: > > - the non-validated forms have their default values > - the validated form has the submitted values & > errors/blanks > > the ideas i have so far are: > - push the defaults from the other form into the validated form's > defaults > - add a kwarg to htmlfill.render that would only allow the form > re-writing to affect fields explicitly listed in `defaults` and `errors` > > it'll probably take me as much time to code either of these solutions. if > the community would benefit from the second idea - i'd be happy to write a > patch. > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > FormEncode-discuss mailing list > For...@li... > https://lists.sourceforge.net/lists/listinfo/formencode-discuss > -- Christopher Lambacher ch...@ka... |
From: Jonathan V. <jva...@2x...> - 2012-07-11 23:07:47
|
hoping someone can give me a suggestion : I sometimes have two forms displayed on a single page. They're validated separately and submitted to different locations. ( this is under pylons and pyramid ) example: the left side of the screen shows Account Data the right side of the screen has a "change password" and "change email" field If i use htmlfill.render on this page to reprint on an error the following behavior happens: 1) default settings - the validated form looks like i want it to -- there are errors displayed -- the 'invalid' fields are blank -- the 'valid' fields are filled - the non-validated forms are all blank 2) force_defaults=False - the non-validated forms have their default values - the validated form loses all the submitted values does anyone have a suggestion on how i can achieve this: - the non-validated forms have their default values - the validated form has the submitted values & errors/blanks the ideas i have so far are: - push the defaults from the other form into the validated form's defaults - add a kwarg to htmlfill.render that would only allow the form re-writing to affect fields explicitly listed in `defaults` and `errors` it'll probably take me as much time to code either of these solutions. if the community would benefit from the second idea - i'd be happy to write a patch. |
From: Marius G. <ma...@po...> - 2012-03-16 18:20:51
|
On Thu, Mar 15, 2012 at 01:53:21PM -0400, David Stanek wrote: > Chris Lambacher and I have been talking about moving this project over > to git. Much of the surrounding ecosystem (TurbeGears/Pyramid/Pylons) > have already moved in that direction so I don't think this is a > controversial change. > > What I would like some feedback on is github vs. bitbucket. I'm more > of a github fan and I think it will make the conversion more obvious, > but there are some cons too. Thoughts? Yay! Github! Marius Gedminas -- C is for Cookies. Perl is even better for Cookies. |
From: Ian B. <ia...@co...> - 2012-03-15 19:48:56
|
Yeah, the times are changing, I personally use github for all my new projects, and it seems appropriate for FormEncode as well. On Thu, Mar 15, 2012 at 12:53 PM, David Stanek <ds...@ds...> wrote: > Chris Lambacher and I have been talking about moving this project over > to git. Much of the surrounding ecosystem (TurbeGears/Pyramid/Pylons) > have already moved in that direction so I don't think this is a > controversial change. > > What I would like some feedback on is github vs. bitbucket. I'm more > of a github fan and I think it will make the conversion more obvious, > but there are some cons too. Thoughts? > > Thanks! > > -- > David > blog: http://www.traceback.org > twitter: http://twitter.com/dstanek > www: http://dstanek.com > > > ------------------------------------------------------------------------------ > This SF email is sponsosred by: > Try Windows Azure free for 90 days Click Here > http://p.sf.net/sfu/sfd2d-msazure > _______________________________________________ > FormEncode-discuss mailing list > For...@li... > https://lists.sourceforge.net/lists/listinfo/formencode-discuss > |
From: Jon N. <jne...@ja...> - 2012-03-15 19:34:51
|
On Thu, Mar 15, 2012 at 12:53 PM, David Stanek <ds...@ds...> wrote: > Chris Lambacher and I have been talking about moving this project over > to git. Much of the surrounding ecosystem (TurbeGears/Pyramid/Pylons) > have already moved in that direction so I don't think this is a > controversial change. Yay! > What I would like some feedback on is github vs. bitbucket. I'm more > of a github fan and I think it will make the conversion more obvious, > but there are some cons too. Thoughts? I'd prefer github. -- Jon |
From: David S. <ds...@ds...> - 2012-03-15 18:16:00
|
Chris Lambacher and I have been talking about moving this project over to git. Much of the surrounding ecosystem (TurbeGears/Pyramid/Pylons) have already moved in that direction so I don't think this is a controversial change. What I would like some feedback on is github vs. bitbucket. I'm more of a github fan and I think it will make the conversion more obvious, but there are some cons too. Thoughts? Thanks! -- David blog: http://www.traceback.org twitter: http://twitter.com/dstanek www: http://dstanek.com |
From: Chris L. <ch...@ka...> - 2012-02-23 02:38:41
|
Hi Jonathan, So I think the issue here is that the docs could be more clear: auto_error_formatter is used to create the HTML that goes above the fields. By default it wraps the error message in a span and adds a <br>. In this text "is used to create the HTML that goes above the fields" is a reference to the docs for the auto_insert_errors docs: If auto_insert_errors is true (the default) then any errors for which <form:error> tags can’t be found will be put just above the associated input field, or at the top of the form if no field can be found. The docs there clearly indicate that the "auto_insert_errors" argument is explicitly talking about errors that *don't* have a <form:error> tag. In your case you *do* have a form error tag and if you want to override the default formatter in that case then you need to set something in the "error_formatters" argument. In other words, "auto_error_formatter" is not a global catch all formatter for all errors, it is a catch all for errors that don't have a "<form:error>" tag. If you want to override the default formatter for "<form:error>" tags, pass in error_formatters as {'default': my_formatter} and you will be off to the races. If you want to have a global default for your project, I recommend that you write and use a wrapper function that provides the defaults you want while passing through the parameters that you need to change regularly. -Chris On Wed, Feb 22, 2012 at 6:52 PM, Jonathan Vanasco <jva...@2x...> wrote: > Thanks Chris. > > I knew about being able to specify & pass custom formatters. I wanted to > avoid that, and rely on the auto error. I guess i wanted a clue on how to > patch formencode. > > My issue is with the behavior I illustrated below, which I would consider > a bug. > > One would assume that if you pass in the "auto_error_formatter" argument, > it would be used for generating ALL errors. Instead it generates errors > only for html input type elements, and does not format the form:error > blocks. > > On Feb 5, 2012, at 10:42 AM, Chris Lambacher wrote: > > You should be able to use the formatter attribute to specify a custom > formatter: > http://www.formencode.org/en/latest/htmlfill.html#errors: > <form:error name="field_name" format="formatter"> > > You will also need to provide the error_formatters argument to renderer if > the formatter you want to use is not one of the default ones: > > http://www.formencode.org/en/latest/modules/htmlfill.html#formencode.htmlfill.render > > -Chris > > On Sat, Feb 4, 2012 at 3:11 PM, Jonathan Vanasco <jva...@2x...>wrote: > >> >> i'm a little confused by htmlfill's behavior on this. >> >> Given a form like this: >> <form:error name="Error_Main"/> >> <input id="login-email_address" name="email_address" >> placeholder="Email Address" size="30" type="text" /> >> <input id="login-password" name="password" placeholder="Password" >> size="30" type="password" /> >> >> and a call to htmlfill with this: >> formencode.htmlfill.render(\ >> form_content, >> defaults=defaults, >> errors=errors, >> auto_error_formatter=custom_formatter >> ) >> >> My output is essentially this: >> Error Main -- rendered with default formatter >> email_address -- rendered with custom formatter >> password -- rendered with custom formatter >> >> anyone have an idea to get the Error_Main section to render with the >> custom formatter along with the other fields (aside from specifying a >> custom renderer in the field and passing in a dict )? >> >> ------------------------------------------------------------------------------ >> Try before you buy = See our experts in action! >> The most comprehensive online learning library for Microsoft developers >> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, >> Metro Style Apps, more. Free future releases when you subscribe now! >> http://p.sf.net/sfu/learndevnow-dev2 >> _______________________________________________ >> FormEncode-discuss mailing list >> For...@li... >> https://lists.sourceforge.net/lists/listinfo/formencode-discuss >> > > > > -- > Christopher Lambacher > ch...@ka... > > > // Jonathan Vanasco > > c. 646.729.6436 | 415.501.9815 > e. jon...@2x... > w. http://findmeon.com/user/jvanasco > linkedin. http://linkedin.com/in/jonathanvanasco > blog. http://destructuring.net > > -- Christopher Lambacher ch...@ka... |
From: Chris L. <ch...@ka...> - 2012-02-23 02:07:12
|
Hi Vanasco, This is a generic FormEncode question so you should ask on the FormEncode list. I copied that list on this email. The FormEncode list is pretty low volume, but the maintainers do respond ;). You might want to include what you want as your final state (for instance I assume you want ints rather than unicode values). You could then use a Pipe validator: from formencode import Pipe from formencode.validators import OneOf, Int account_type_ids= (1,2,3,4,5) #must be one of the items in account_type_ids validator = Pipe(Int(),OneOf(account_ type_ids) #must be int between 1 and 5 validator = Int(min=1, max=5) Note that if account_type_ids is not *actually* a list or tuple there may be other options including DictConverter. Some useful doc links: http://www.formencode.org/en/latest/modules/compound.html#formencode.compound.Pipe http://www.formencode.org/en/latest/modules/validators.html#formencode.validators.Int http://www.formencode.org/en/latest/modules/validators.html#formencode.validators.DictConverter -Chris On Wednesday, February 22, 2012, Jonathan Vanasco wrote: > > the request get/post data comes in from pyramid as unicode strings. > > the values i have in the database / my code for constant on many items > are integers > > let's use this as an example... > > account_type_ids= (1,2,3,4,5) > other_type_ids= (1,2,3,4,5) > third_type_ids= (1,2,3,4,5) > > > is there a better way of doing this: > > def unicode_wrap(listed): > return [ u"%s" % i for i in listed ] > > class MySchema(formencode.Schema): > account_type_id = > formencode.validators.OneOf( unicode_wrap(account_type_ids), > not_empty=True ) > other_type_id = > formencode.validators.OneOf( unicode_wrap(other_type_ids), > not_empty=True ) > third_type_id = > formencode.validators.OneOf( unicode_wrap(third_type_ids), > not_empty=True ) > > i've combed the formencode docs and list archives, but just I can't > figure out a good way to handle this. > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To post to this group, send email to pyl...@go.... > To unsubscribe from this group, send email to > pyl...@go.... > For more options, visit this group at > http://groups.google.com/group/pylons-discuss?hl=en. > > |
From: Jonathan V. <jva...@2x...> - 2012-02-22 23:52:30
|
Thanks Chris. I knew about being able to specify & pass custom formatters. I wanted to avoid that, and rely on the auto error. I guess i wanted a clue on how to patch formencode. My issue is with the behavior I illustrated below, which I would consider a bug. One would assume that if you pass in the "auto_error_formatter" argument, it would be used for generating ALL errors. Instead it generates errors only for html input type elements, and does not format the form:error blocks. On Feb 5, 2012, at 10:42 AM, Chris Lambacher wrote: > You should be able to use the formatter attribute to specify a custom formatter: > http://www.formencode.org/en/latest/htmlfill.html#errors: > <form:error name="field_name" format="formatter"> > > You will also need to provide the error_formatters argument to renderer if the formatter you want to use is not one of the default ones: > http://www.formencode.org/en/latest/modules/htmlfill.html#formencode.htmlfill.render > > -Chris > > On Sat, Feb 4, 2012 at 3:11 PM, Jonathan Vanasco <jva...@2x...> wrote: > > i'm a little confused by htmlfill's behavior on this. > > Given a form like this: > <form:error name="Error_Main"/> > <input id="login-email_address" name="email_address" placeholder="Email Address" size="30" type="text" /> > <input id="login-password" name="password" placeholder="Password" size="30" type="password" /> > > and a call to htmlfill with this: > formencode.htmlfill.render(\ > form_content, > defaults=defaults, > errors=errors, > auto_error_formatter=custom_formatter > ) > > My output is essentially this: > Error Main -- rendered with default formatter > email_address -- rendered with custom formatter > password -- rendered with custom formatter > > anyone have an idea to get the Error_Main section to render with the custom formatter along with the other fields (aside from specifying a custom renderer in the field and passing in a dict )? > ------------------------------------------------------------------------------ > Try before you buy = See our experts in action! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-dev2 > _______________________________________________ > FormEncode-discuss mailing list > For...@li... > https://lists.sourceforge.net/lists/listinfo/formencode-discuss > > > > -- > Christopher Lambacher > ch...@ka... // Jonathan Vanasco c. 646.729.6436 | 415.501.9815 e. jon...@2x... w. http://findmeon.com/user/jvanasco linkedin. http://linkedin.com/in/jonathanvanasco blog. http://destructuring.net |
From: Chris L. <ch...@ka...> - 2012-02-05 15:42:47
|
You should be able to use the formatter attribute to specify a custom formatter: http://www.formencode.org/en/latest/htmlfill.html#errors: <form:error name="field_name" format="formatter"> You will also need to provide the error_formatters argument to renderer if the formatter you want to use is not one of the default ones: http://www.formencode.org/en/latest/modules/htmlfill.html#formencode.htmlfill.render -Chris On Sat, Feb 4, 2012 at 3:11 PM, Jonathan Vanasco <jva...@2x...> wrote: > > i'm a little confused by htmlfill's behavior on this. > > Given a form like this: > <form:error name="Error_Main"/> > <input id="login-email_address" name="email_address" > placeholder="Email Address" size="30" type="text" /> > <input id="login-password" name="password" placeholder="Password" > size="30" type="password" /> > > and a call to htmlfill with this: > formencode.htmlfill.render(\ > form_content, > defaults=defaults, > errors=errors, > auto_error_formatter=custom_formatter > ) > > My output is essentially this: > Error Main -- rendered with default formatter > email_address -- rendered with custom formatter > password -- rendered with custom formatter > > anyone have an idea to get the Error_Main section to render with the > custom formatter along with the other fields (aside from specifying a > custom renderer in the field and passing in a dict )? > > ------------------------------------------------------------------------------ > Try before you buy = See our experts in action! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-dev2 > _______________________________________________ > FormEncode-discuss mailing list > For...@li... > https://lists.sourceforge.net/lists/listinfo/formencode-discuss > -- Christopher Lambacher ch...@ka... |
From: Jonathan V. <jva...@2x...> - 2012-02-04 20:44:12
|
i'm a little confused by htmlfill's behavior on this. Given a form like this: <form:error name="Error_Main"/> <input id="login-email_address" name="email_address" placeholder="Email Address" size="30" type="text" /> <input id="login-password" name="password" placeholder="Password" size="30" type="password" /> and a call to htmlfill with this: formencode.htmlfill.render(\ form_content, defaults=defaults, errors=errors, auto_error_formatter=custom_formatter ) My output is essentially this: Error Main -- rendered with default formatter email_address -- rendered with custom formatter password -- rendered with custom formatter anyone have an idea to get the Error_Main section to render with the custom formatter along with the other fields (aside from specifying a custom renderer in the field and passing in a dict )? |
From: Łukasz M. <lm...@zo...> - 2012-01-21 19:26:43
|
W dniu 2012-01-19 15:43, Chris Lambacher pisze: > Hi Łukasz, > > I'll assume that 'validators.OneOf[1,2,3,4]' was a typo and that you > meant validators.OneOf([1,2,3,4]). > > You need to combine two validators using either All or Pipe (see > http://www.formencode.org/en/latest/modules/compound.html). > Many thanks. Somehow I forgot about All(), but you are right, Pipe is more intuitive. Thanks again, Łukasz |
From: Chris L. <ch...@ka...> - 2012-01-19 14:43:23
|
Hi Łukasz, I'll assume that 'validators.OneOf[1,2,3,4]' was a typo and that you meant validators.OneOf([1,2,3,4]). You need to combine two validators using either All or Pipe (see http://www.formencode.org/en/latest/modules/compound.html). Pipe will be most intuitive: >>> from formencode import validators, Pipe >>> pv = Pipe(validators.Int(), validators.OneOf([1,2,3,4])) >>> pv.to_python('1') 1 All is the same but you need to put the validators in reverse order that you wish them to evaluate for to_python: >>> from formencode import validators, All >>> av = All(validators.OneOf([1,2,3,4]), validators.Int()) >>> av.to_python('1') 1 >>> from formencode import Invalid >>> try: ... av.to_python('b') ... except Invalid, e: ... print e ... Please enter an integer value -Chris On Thu, Jan 19, 2012 at 5:44 AM, Lukasz Michalski <lm...@zo...> wrote: > Hi, > > Does anyone have an example how to validate set of integers from input > string? > > validators.OneOf[1,2,3,4,5] throws an exception when '1' is passed. > validators.Int() AFAIK does not allow to specify set of valid values. > > Is there any method to combine those two? > > Thanks, > Łukasz > > > ------------------------------------------------------------------------------ > Keep Your Developer Skills Current with LearnDevNow! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-d2d > _______________________________________________ > FormEncode-discuss mailing list > For...@li... > https://lists.sourceforge.net/lists/listinfo/formencode-discuss > -- Christopher Lambacher ch...@ka... |
From: Lukasz M. <lm...@zo...> - 2012-01-19 11:02:23
|
Hi, Does anyone have an example how to validate set of integers from input string? validators.OneOf[1,2,3,4,5] throws an exception when '1' is passed. validators.Int() AFAIK does not allow to specify set of valid values. Is there any method to combine those two? Thanks, Łukasz |
From: Chris L. <ch...@ka...> - 2011-12-27 00:53:11
|
On Mon, Dec 26, 2011 at 6:40 PM, Daniel Lepage <dpl...@gm...> wrote: > Hi Chris, > > This is done through AJAX. I don't have the "enter values, then hit > save" workflow - instead, the user can change the values in these form > fields at any time and the results are immediately sent to the server > and, if valid, saved. It is not common to save *some* of the data (i.e. the parts that validated) rather than *all* the data (i.e. on completely valid). I think as a user, in most cases, I would find this surprising behaviour. > > The values are used by other parts of the system, so I can't just > store the POSTed strings - I need the actual converted values for all > the valid POSTed values, even if there are also invalid values. You certainly don't want to use the raw posted values in general for anything other than re-generating forms. ToscaWidgets *should* be capable of regenerating forms on error (I haven't looked at ToscaWidgets in a long time and not very closely either). If you are doing an AJAX Post, then you should also be able to return success or failure back to the form (including information about which fields failed) and leave the content of the page untouched unless you see that the validation completed because the server gave you a successful result. If you *really* want to collect partial success and the errors, you should probably eschew Schemas and write a function which takes a dict of validators and returns the errors and the valid values. This is fairly trivial to write: def validate_things(validators, form_values): valid = {} errors = {} for key, validator in validators.iteritems(): try: valid[key] = validator.to_python(form_values.get(key)) except Invalid, e: errors[key] = e return valid, errors -Chris -- Christopher Lambacher ch...@ka... |
From: Chris L. <ch...@ka...> - 2011-12-27 00:37:15
|
On Mon, Dec 26, 2011 at 6:11 PM, W-Mark Kubacki <wm...@hu...> wrote: > 2011/12/27 Chris Lambacher <ch...@ka...>: >> >> Use the raw post values to render the page. You shouldn't need >> validated values to do so.[...] > > Of course Chris wanted to be brief in his answer; just one thing we > sometimes forget to mention: > > *Don't* use unvalidated/unfiltered values for re-rendering your form! > Imagine someone provided a value such as: > "><script language="">... > It will open your webapp to XSS, (XSRF, too?) or other kinds of attacks. Mark is of course correct. I sometimes forget that not all template languages automatically escape values inserted into templates. If you are going to be re-inserting unvalidated post values into your templates make sure that your template language (or form rendering tool) properly escapes values inserted into the page. -Chris -- Christopher Lambacher ch...@ka... |
From: Daniel L. <dpl...@gm...> - 2011-12-26 23:43:30
|
Hi Mark, Thanks for the tip! I'm already using AJAX, with JQuery instead of Prototype (the rest of the project was already using JQuery), and I agree that it makes the user experience much more streamlined. Thanks, Dan On Mon, Dec 26, 2011 at 6:04 PM, W-Mark Kubacki <wm...@hu...> wrote: > Hi Dan! > > No solution, just a remark: If you avoided the page-break by > submitting data asynchronously ("AJAX" (xml)) you can better please > your users. It worked very well for me. The corresponding JS code (you > will need Prototype for that) can be found here, along with a video of > what I have in mind: > [1] http://tgwidgets.ossdl.de/wiki/Scriptaculous/AJAJForms > > -- > Mark |
From: Daniel L. <dpl...@gm...> - 2011-12-26 23:40:44
|
Hi Chris, This is done through AJAX. I don't have the "enter values, then hit save" workflow - instead, the user can change the values in these form fields at any time and the results are immediately sent to the server and, if valid, saved. The values are used by other parts of the system, so I can't just store the POSTed strings - I need the actual converted values for all the valid POSTed values, even if there are also invalid values. The framework backing this is Flask at a high leve and ToscaWidgets 2 at a lower level, but due to a separate data API the validation is ToscaWidgets-independent. Thanks, Dan On Mon, Dec 26, 2011 at 6:02 PM, Chris Lambacher <ch...@ka...> wrote: > Hi Dan, > > Use the raw post values to render the page. You shouldn't need > validated values to do so. If you need to get related data using some > of the values, you can check if those values specifically caused > errors and do a more direct conversion if not. > > If you tell me the framework you are using I might be able to provide > you with some more specific tips. > > -Chris > > On Mon, Dec 26, 2011 at 5:55 PM, Daniel Lepage <dpl...@gm...> wrote: >> Hi Chris, >> >> I have a web form that can be edited and saved multiple times. When >> the user inputs data, all valid fields are saved and all invalid >> fields display error messages. >> >> So I need to show the error messages for the invalid fields AND get >> the python values of the valid fields. >> >> Right now my hack is a subclass of Schema that overrides _to_python >> with a function that is char-for-char identical except for a single >> line, where instead of raising Invalid I raise a custom subclass >> (PartialInvalid) that also contains all the valid values. >> >> This works well enough, but it's inelegant, so I was hoping to find a >> better solution. >> >> Thanks, >> Dan >> >> On Mon, Dec 26, 2011 at 5:41 PM, Chris Lambacher <ch...@ka...> wrote: >>> Hi Dan, >>> >>> There is no official and nice way of doing that and without knowing >>> why you want to do that I would guess "you are doing it wrong". There >>> are some hackish ways that you might be able to get the value but they >>> are likely to be error prone. >>> >>> Can you elaborate on why you want to do it that way? Do you want to >>> display the error? Do you want to ignore the error? >>> >>> -Chris >>> >>> >>> On Mon, Dec 26, 2011 at 5:12 PM, Daniel Lepage <dpl...@gm...> wrote: >>>> Hi everyone, >>>> >>>> Is there a way to get the python values for successful fields in a >>>> Schema when other fields have failed? >>>> >>>> For example, suppose I have the following schema and input value: >>>> >>>> sch = Schema(fields=dict(x=Int(), y=DateConverter(), z=Int())) >>>> v = dict(x='12', y='1/16/1973', z='foo') >>>> >>>> I'd like to validate v against sch in such a way that I get not only >>>> the error message from z, but also the values 12 and datetime(1973, 1, >>>> 16) from x and y, respectively. >>>> >>>> Is there a way to do this? >>>> >>>> None of my use cases rely on chained_validators, so all I need are the >>>> values computed by the fields of the schema. >>>> >>>> Thanks, >>>> Dan Lepage >>>> >>>> ------------------------------------------------------------------------------ >>>> Write once. Port to many. >>>> Get the SDK and tools to simplify cross-platform app development. Create >>>> new or port existing apps to sell to consumers worldwide. Explore the >>>> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join >>>> http://p.sf.net/sfu/intel-appdev >>>> _______________________________________________ >>>> FormEncode-discuss mailing list >>>> For...@li... >>>> https://lists.sourceforge.net/lists/listinfo/formencode-discuss >>> >>> >>> >>> -- >>> Christopher Lambacher >>> ch...@ka... >> >> ------------------------------------------------------------------------------ >> Write once. Port to many. >> Get the SDK and tools to simplify cross-platform app development. Create >> new or port existing apps to sell to consumers worldwide. Explore the >> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join >> http://p.sf.net/sfu/intel-appdev >> _______________________________________________ >> FormEncode-discuss mailing list >> For...@li... >> https://lists.sourceforge.net/lists/listinfo/formencode-discuss > > > > -- > Christopher Lambacher > ch...@ka... |
From: Chris L. <ch...@ka...> - 2011-12-26 23:02:12
|
Hi Dan, Use the raw post values to render the page. You shouldn't need validated values to do so. If you need to get related data using some of the values, you can check if those values specifically caused errors and do a more direct conversion if not. If you tell me the framework you are using I might be able to provide you with some more specific tips. -Chris On Mon, Dec 26, 2011 at 5:55 PM, Daniel Lepage <dpl...@gm...> wrote: > Hi Chris, > > I have a web form that can be edited and saved multiple times. When > the user inputs data, all valid fields are saved and all invalid > fields display error messages. > > So I need to show the error messages for the invalid fields AND get > the python values of the valid fields. > > Right now my hack is a subclass of Schema that overrides _to_python > with a function that is char-for-char identical except for a single > line, where instead of raising Invalid I raise a custom subclass > (PartialInvalid) that also contains all the valid values. > > This works well enough, but it's inelegant, so I was hoping to find a > better solution. > > Thanks, > Dan > > On Mon, Dec 26, 2011 at 5:41 PM, Chris Lambacher <ch...@ka...> wrote: >> Hi Dan, >> >> There is no official and nice way of doing that and without knowing >> why you want to do that I would guess "you are doing it wrong". There >> are some hackish ways that you might be able to get the value but they >> are likely to be error prone. >> >> Can you elaborate on why you want to do it that way? Do you want to >> display the error? Do you want to ignore the error? >> >> -Chris >> >> >> On Mon, Dec 26, 2011 at 5:12 PM, Daniel Lepage <dpl...@gm...> wrote: >>> Hi everyone, >>> >>> Is there a way to get the python values for successful fields in a >>> Schema when other fields have failed? >>> >>> For example, suppose I have the following schema and input value: >>> >>> sch = Schema(fields=dict(x=Int(), y=DateConverter(), z=Int())) >>> v = dict(x='12', y='1/16/1973', z='foo') >>> >>> I'd like to validate v against sch in such a way that I get not only >>> the error message from z, but also the values 12 and datetime(1973, 1, >>> 16) from x and y, respectively. >>> >>> Is there a way to do this? >>> >>> None of my use cases rely on chained_validators, so all I need are the >>> values computed by the fields of the schema. >>> >>> Thanks, >>> Dan Lepage >>> >>> ------------------------------------------------------------------------------ >>> Write once. Port to many. >>> Get the SDK and tools to simplify cross-platform app development. Create >>> new or port existing apps to sell to consumers worldwide. Explore the >>> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join >>> http://p.sf.net/sfu/intel-appdev >>> _______________________________________________ >>> FormEncode-discuss mailing list >>> For...@li... >>> https://lists.sourceforge.net/lists/listinfo/formencode-discuss >> >> >> >> -- >> Christopher Lambacher >> ch...@ka... > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev > _______________________________________________ > FormEncode-discuss mailing list > For...@li... > https://lists.sourceforge.net/lists/listinfo/formencode-discuss -- Christopher Lambacher ch...@ka... |
From: Daniel L. <dpl...@gm...> - 2011-12-26 22:56:10
|
Hi Chris, I have a web form that can be edited and saved multiple times. When the user inputs data, all valid fields are saved and all invalid fields display error messages. So I need to show the error messages for the invalid fields AND get the python values of the valid fields. Right now my hack is a subclass of Schema that overrides _to_python with a function that is char-for-char identical except for a single line, where instead of raising Invalid I raise a custom subclass (PartialInvalid) that also contains all the valid values. This works well enough, but it's inelegant, so I was hoping to find a better solution. Thanks, Dan On Mon, Dec 26, 2011 at 5:41 PM, Chris Lambacher <ch...@ka...> wrote: > Hi Dan, > > There is no official and nice way of doing that and without knowing > why you want to do that I would guess "you are doing it wrong". There > are some hackish ways that you might be able to get the value but they > are likely to be error prone. > > Can you elaborate on why you want to do it that way? Do you want to > display the error? Do you want to ignore the error? > > -Chris > > > On Mon, Dec 26, 2011 at 5:12 PM, Daniel Lepage <dpl...@gm...> wrote: >> Hi everyone, >> >> Is there a way to get the python values for successful fields in a >> Schema when other fields have failed? >> >> For example, suppose I have the following schema and input value: >> >> sch = Schema(fields=dict(x=Int(), y=DateConverter(), z=Int())) >> v = dict(x='12', y='1/16/1973', z='foo') >> >> I'd like to validate v against sch in such a way that I get not only >> the error message from z, but also the values 12 and datetime(1973, 1, >> 16) from x and y, respectively. >> >> Is there a way to do this? >> >> None of my use cases rely on chained_validators, so all I need are the >> values computed by the fields of the schema. >> >> Thanks, >> Dan Lepage >> >> ------------------------------------------------------------------------------ >> Write once. Port to many. >> Get the SDK and tools to simplify cross-platform app development. Create >> new or port existing apps to sell to consumers worldwide. Explore the >> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join >> http://p.sf.net/sfu/intel-appdev >> _______________________________________________ >> FormEncode-discuss mailing list >> For...@li... >> https://lists.sourceforge.net/lists/listinfo/formencode-discuss > > > > -- > Christopher Lambacher > ch...@ka... |
From: Chris L. <ch...@ka...> - 2011-12-26 22:41:43
|
Hi Dan, There is no official and nice way of doing that and without knowing why you want to do that I would guess "you are doing it wrong". There are some hackish ways that you might be able to get the value but they are likely to be error prone. Can you elaborate on why you want to do it that way? Do you want to display the error? Do you want to ignore the error? -Chris On Mon, Dec 26, 2011 at 5:12 PM, Daniel Lepage <dpl...@gm...> wrote: > Hi everyone, > > Is there a way to get the python values for successful fields in a > Schema when other fields have failed? > > For example, suppose I have the following schema and input value: > > sch = Schema(fields=dict(x=Int(), y=DateConverter(), z=Int())) > v = dict(x='12', y='1/16/1973', z='foo') > > I'd like to validate v against sch in such a way that I get not only > the error message from z, but also the values 12 and datetime(1973, 1, > 16) from x and y, respectively. > > Is there a way to do this? > > None of my use cases rely on chained_validators, so all I need are the > values computed by the fields of the schema. > > Thanks, > Dan Lepage > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev > _______________________________________________ > FormEncode-discuss mailing list > For...@li... > https://lists.sourceforge.net/lists/listinfo/formencode-discuss -- Christopher Lambacher ch...@ka... |
From: Daniel L. <dpl...@gm...> - 2011-12-26 22:13:07
|
Hi everyone, Is there a way to get the python values for successful fields in a Schema when other fields have failed? For example, suppose I have the following schema and input value: sch = Schema(fields=dict(x=Int(), y=DateConverter(), z=Int())) v = dict(x='12', y='1/16/1973', z='foo') I'd like to validate v against sch in such a way that I get not only the error message from z, but also the values 12 and datetime(1973, 1, 16) from x and y, respectively. Is there a way to do this? None of my use cases rely on chained_validators, so all I need are the values computed by the fields of the schema. Thanks, Dan Lepage |