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: Ian B. <ia...@co...> - 2005-04-28 21:59:10
|
Jussi Arpalahti wrote: > Is it possible to somehow make htmlfill aware of compound values? > > When using forms and validating the syntax for dictionary keys (the > variabledecode module) is really simple, yet powerful. > > Unfortunately it seems, that when using htmlfill you have to manually > generate form elements for every value you need ( foo-1.bar, foo-2.bar > etc.), and then use htmlfill to fill in the values. Htmlfill is so > nice a concept, so I'm lazily just hoping it would also do this for > me... No, because it gets confusing. How do you repeat fields? There's lots of options, tables, <br>, etc. To do it generally you need a templating language, and htmlfill isn't a templating language. The idea is for you to generate the HTML yourself using your templating language of choice (or Python), and then hand the generated output to htmlfill. formgen is the beginning of a Python-based generator, but it's quite incomplete (at least for using with htmlfill and other stuff). I think it's reasonable to write custom code for your form generation as well, it's all very tied to aesthetics. > As and aside I noticed, that FormEncode's documentation about using > compound values advises to using ForEach-validator from validators > module, when in fact it is in a separate module of the same name. Hrm, yes, I still have to review the docs after all the stuff that has been moved around lately. > Also there is no mention of using unpack_values -method of validator > exception to get htmlfill compliant error messages. I was briefly > stuck there, but a message on the mailing list provided vital clue ;) > > > BTW: Validating compound values was big problem for me when I was > researching various web frameworks, and I really liked the > variabledecode's idea of deep dictionary hierarchy <-> flat form > names. > > With Quixote for request handling and templates, the development of > web apps just feels good (compared to Zope2, Plone+Archetypes, Twisted > and WebWare) and I can concentrate just to app logic. > > So thank you for useful framework (of sorts) and insightful blogging! > I'm looking forward for the promise of Paste.. Cheers. And Quixote should be included in Paste quite soon now. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: Jussi A. <ja...@gm...> - 2005-04-28 21:43:17
|
Hi. Is it possible to somehow make htmlfill aware of compound values? When using forms and validating the syntax for dictionary keys (the variabledecode module) is really simple, yet powerful. Unfortunately it seems, that when using htmlfill you have to manually generate form elements for every value you need ( foo-1.bar, foo-2.bar etc.), and then use htmlfill to fill in the values. Htmlfill is so nice a concept, so I'm lazily just hoping it would also do this for me... As and aside I noticed, that FormEncode's documentation about using compound values advises to using ForEach-validator from validators module, when in fact it is in a separate module of the same name. Also there is no mention of using unpack_values -method of validator exception to get htmlfill compliant error messages. I was briefly stuck there, but a message on the mailing list provided vital clue ;) BTW: Validating compound values was big problem for me when I was researching various web frameworks, and I really liked the variabledecode's idea of deep dictionary hierarchy <-> flat form names. With Quixote for request handling and templates, the development of web apps just feels good (compared to Zope2, Plone+Archetypes, Twisted and WebWare) and I can concentrate just to app logic. So thank you for useful framework (of sorts) and insightful blogging! I'm looking forward for the promise of Paste.. Best, Jussi |
|
From: Ian B. <ia...@co...> - 2005-04-25 04:56:10
|
I did the reorganization tonight, changing the package name back to "formencode" and moving the repository to http://svn.colorstudy.com/FormEncode/trunk I also removed the PyProtocols stuff, removed the "to_python" and "from_python" functions, and cleaned a bunch of stuff up. I still have to fix up the docs. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: Ian B. <ia...@co...> - 2005-04-21 03:19:25
|
I should have called what is now "Validator" a branch, instead of a new package. Anyway, in an effort to disambiguate stuff I plan on moving the Subversion repository around. What is now /trunk/Validator will become /FormEncode/trunk, and what is now /trunk/FormEncode will become /FormEncode/branches/pre-htmlfill Also, the validator package will become formencode. This moving around of stuff can be annoying if you have outstanding changes, so you might want to check them in if you do. I plan on doing the move tomorrow evening. Also, I'm not 100% sure if you are all on the FormEncode list; if not please join. It's pretty darn low traffic. There's also a checkin list: http://lists.sourceforge.net/mailman/listinfo/formencode-cvs -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: Ian B. <ia...@co...> - 2005-04-21 00:15:24
|
Scott Chapman wrote: > Ian, > I'm working on cleaning it up a bit and testing it. Don't worry about > the version I sent you. I'll have another one off in an hour or two > that's better. OK. I know Peter has been doing stuff with it lately too, and I don't know if there's anything he hasn't checked in yet, but I'll let him speak up if so. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: michelts <mic...@gm...> - 2005-04-19 16:57:12
|
Hi again... > Like I said, that package is *very* out of date; I just thought I'd note > it in case it had any interesting differences. The validator package is > correct. Ok, let me understand :) The validator is reasonabily stable and the other funcionality are not (like htmlview). I done the validation over the page content, triggering the page final writing, so doesn't matter the way the form is generated... I done a example of use (it goes in webware examples)... Thanks for help... --=20 Michel Thadeu Sabchuk Curitiba - Brasil |
|
From: Ian B. <ia...@co...> - 2005-04-19 15:44:24
|
michelts wrote: > Hi Ian, > > I look at your FormEncodeKit, you are using formencode package instead > of validator, should I use this package? Is validator depreacted? Like I said, that package is *very* out of date; I just thought I'd note it in case it had any interesting differences. The validator package is correct. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: michelts <mic...@gm...> - 2005-04-19 11:40:30
|
Hi Ian, I look at your FormEncodeKit, you are using formencode package instead of validator, should I use this package? Is validator depreacted? thanks On 4/18/05, Ian Bicking <ia...@co...> wrote: > michelts wrote: > > Hi guys! > > > > I glad to tell you I done a FormEncode Component, I called it > > FEComponent. This is an old idea, I using it today in my projects > > (even before change it to a component). Maybe you Ian remember this > > thread, I create a FormServlet to handle the form processing, it > > trigger the final writing of the page, well, with your idea of > > components, the system is more stable I think... >=20 > Thanks, I'll give this a close look soon. I had a FormEncode component, > which is now rather out of date: > http://svn.colorstudy.com/trunk/FormEncode/experimental/FormEncodeKit/ >=20 > Hmmm... actually I'm getting a 404 from this URL: >=20 > > The package could be found in http://www.ebanda.com.br/fecomonent.tgz, > > there is the component itself, a formpage (like the ZPTPage on the > > zptkit example) and a Test.py, this is a servlet using the > > fecomponent... >=20 > -- > Ian Bicking / ia...@co... / http://blog.ianbicking.org >=20 --=20 Michel Thadeu Sabchuk Curitiba - Brasil |
|
From: michelts <mic...@gm...> - 2005-04-18 17:45:41
|
On 4/18/05, Ian Bicking <ia...@co...> wrote: > michelts wrote: > > Hi guys! > > > > I glad to tell you I done a FormEncode Component, I called it > > FEComponent. This is an old idea, I using it today in my projects > > (even before change it to a component). Maybe you Ian remember this > > thread, I create a FormServlet to handle the form processing, it > > trigger the final writing of the page, well, with your idea of > > components, the system is more stable I think... >=20 > Thanks, I'll give this a close look soon. I had a FormEncode component, > which is now rather out of date: > http://svn.colorstudy.com/trunk/FormEncode/experimental/FormEncodeKit/ I will see this code too... > Hmmm... actually I'm getting a 404 from this URL: Sorry, the url is http://www.ebanda.com.br/fecomponent.tgz (i forgot the letter p :) thanks --=20 Michel Thadeu Sabchuk Curitiba - Brasil |
|
From: Ian B. <ia...@co...> - 2005-04-18 16:37:09
|
michelts wrote: > Hi guys! > > I glad to tell you I done a FormEncode Component, I called it > FEComponent. This is an old idea, I using it today in my projects > (even before change it to a component). Maybe you Ian remember this > thread, I create a FormServlet to handle the form processing, it > trigger the final writing of the page, well, with your idea of > components, the system is more stable I think... Thanks, I'll give this a close look soon. I had a FormEncode component, which is now rather out of date: http://svn.colorstudy.com/trunk/FormEncode/experimental/FormEncodeKit/ Hmmm... actually I'm getting a 404 from this URL: > The package could be found in http://www.ebanda.com.br/fecomonent.tgz, > there is the component itself, a formpage (like the ZPTPage on the > zptkit example) and a Test.py, this is a servlet using the > fecomponent... -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: michelts <mic...@gm...> - 2005-04-17 12:08:00
|
Hi again, I create a kit to be inserted in Webware, there is a working example too (you can see it working in the Examples of Webware)... The package can be dowloaded in http://www.ebanda.com.br/fecomonent.tgz, I don't know if I must call it FEComponent or FEKit (the package). thanks and enjoy :) On 4/17/05, michelts <mic...@gm...> wrote: > Hi guys! >=20 > I glad to tell you I done a FormEncode Component, I called it > FEComponent. This is an old idea, I using it today in my projects > (even before change it to a component). Maybe you Ian remember this > thread, I create a FormServlet to handle the form processing, it > trigger the final writing of the page, well, with your idea of > components, the system is more stable I think... >=20 > The package could be found in http://www.ebanda.com.br/fecomonent.tgz, > there is the component itself, a formpage (like the ZPTPage on the > zptkit example) and a Test.py, this is a servlet using the > fecomponent... >=20 > I tryed to comment as most as possible of the source code but i'm here > for any questions ;) >=20 > The system is triggering the final writing of the page yet, but now I > don't need to worry the inheritance hierarchy ;) >=20 > I will be glad to see your comments, is this useful for the community? > Thanks for the Component idea Ian, it is really cool... >=20 > -- > Michel Thadeu Sabchuk > Curitiba - Brasil >=20 --=20 Michel Thadeu Sabchuk Curitiba - Brasil |
|
From: michelts <mic...@gm...> - 2005-04-17 05:08:51
|
Hi guys! I glad to tell you I done a FormEncode Component, I called it FEComponent. This is an old idea, I using it today in my projects (even before change it to a component). Maybe you Ian remember this thread, I create a FormServlet to handle the form processing, it trigger the final writing of the page, well, with your idea of components, the system is more stable I think... The package could be found in http://www.ebanda.com.br/fecomonent.tgz, there is the component itself, a formpage (like the ZPTPage on the zptkit example) and a Test.py, this is a servlet using the fecomponent... I tryed to comment as most as possible of the source code but i'm here for any questions ;) The system is triggering the final writing of the page yet, but now I don't need to worry the inheritance hierarchy ;) I will be glad to see your comments, is this useful for the community? Thanks for the Component idea Ian, it is really cool... --=20 Michel Thadeu Sabchuk Curitiba - Brasil |
|
From: Ian B. <ia...@co...> - 2005-03-07 16:48:24
|
michelts wrote: > Hi guys! > > I have a schema with a nested variable attribute: > > class Name(Schema): > first=NotEmpty() > last=NotEmpty() > > class PersonalData(Schema): > name=Name() > age=Int() > ... > > The validation is ok, I get a dictionary with the first name and last > name. But how do I deal with the htmlfill, what should I use in > <form:error name="???">? variabledecode turns that dictionary into a flattened dictionary with keys like 'name.first' and 'name.last' -- you use those names in the template destined for htmlfill. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: michelts <mic...@gm...> - 2005-03-07 14:17:10
|
Hi guys! I have a schema with a nested variable attribute: class Name(Schema): first=NotEmpty() last=NotEmpty() class PersonalData(Schema): name=Name() age=Int() ... The validation is ok, I get a dictionary with the first name and last name. But how do I deal with the htmlfill, what should I use in <form:error name="???">? Thanks in advance. -- Michel Thadeu Sabchuk Curitiba - Brasil |
|
From: Ian B. <ia...@co...> - 2005-01-11 17:43:01
|
Sorry to take so long, but I've now applied these changes. Michel Thadeu wrote: > Hi guys! >=20 > I made 2 changes on the htmlfill.py file, on to accept password input > fields and other to made checkboxes able to be checked when working > with a list of values (suppose I have a checkbox for a list of options, > I want to pass on a list of default values, and if the value of the > checkbox is in the list, then I should check this checkbox). >=20 > I append the diff to the message, is this the right way to help? >=20 > thanks for attention >=20 > =3D=3D=3D=3D=3D > -- > Michel Thadeu Sabchuk > Curitiba/PR >=20 >=20 > =09 > =09 > =09 > _______________________________________________________=20 > Yahoo! Acesso Gr=E1tis - Internet r=E1pida e gr=E1tis. Instale o discad= or agora! http://br.acesso.yahoo.com/ >=20 >=20 > -----------------------------------------------------------------------= - >=20 > Index: validator/htmlfill.py > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- validator/htmlfill.py (revision 346) > +++ validator/htmlfill.py (working copy) > @@ -134,7 +134,7 @@ > self.skip_error =3D True > self.skip_next =3D True > =20 > - def handle_end_iferror(self, attrs): > + def handle_end_iferror(self): > self.in_error =3D None > self.skip_error =3D False > self.skip_next =3D False > @@ -181,6 +181,8 @@ > or (self.get_attr(attrs, 'value') is None > and value)): > self.set_attr(attrs, 'checked', 'checked') > + elif (isinstance(value, (list, tuple)) and self.get_attr(a= ttrs, 'value') in value): > + self.set_attr(attrs, 'checked', 'checked') > else: > self.del_attr(attrs, 'checked') > self.write_tag('input', attrs) > @@ -196,6 +198,8 @@ > self.add_key(name) > elif t =3D=3D 'file': > pass # don't skip next > + elif t =3D=3D 'password': > + pass > else: > assert 0, "I don't know about this kind of <input>: %s (po= s: %s)" \ > % (t, self.getpos()) --=20 Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: Michel T. <mic...@ya...> - 2004-11-29 02:03:47
|
Hi guys! I made 2 changes on the htmlfill.py file, on to accept password input fields and other to made checkboxes able to be checked when working with a list of values (suppose I have a checkbox for a list of options, I want to pass on a list of default values, and if the value of the checkbox is in the list, then I should check this checkbox). I append the diff to the message, is this the right way to help? thanks for attention ===== -- Michel Thadeu Sabchuk Curitiba/PR _______________________________________________________ Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora! http://br.acesso.yahoo.com/ |
|
From: Ian B. <ia...@co...> - 2004-11-16 04:42:23
|
Michel Thadeu wrote: >>There's a security concern here, you should check that the method is >>marked public in some way. In Webware there's the actions() list of >>methods; I've also used attributes, or call all the methods >>action_name, >>or something like that. > > > Yes, you are right but I have a question about this, is there a problem > on have a class attribute called actions rather than a method? > > class MyServlet: > actions=['some_actions', 'some_another_action'] > ... > > Or it's only the author preference? It's just the Webware style standard to use methods. > Let me explain each part of the unclean code: > > >>> try: # I try to validate it >>> processedFields=validators.to_python(self.schema, >> >>dict([(key, >> >>>dictFields[key]) for key in self.schema.fields.keys()])) > > > First i try to validate the fields over the schema, using the keys of > schema specified. This way, a submit button or another fields that is > not part of the schema is not validated. This seems fine to me, and is pretty much what I've done. >>> getattr(self, methodToInvoke)(processedFields) >>> return >>> except validators.Invalid, error: # if an error occours >>> parser=htmlfill.FillingParser(rawFields, >>>errors=error.unpack_errors()) >>> parser.feed(self.response()._strmOut.buffer()) # I feed the >>>parser with the page content >>> self.response()._strmOut.clear() # clear the old page >> >>content >> >>> self.write(parser.text()) # and write the parsed page >> >>content >> >>> parser.close() >> >>This part isn't very clean (the _strmOut), but then you probably know >>that. > > > I looked the webware code searching where it writes the page content > out, I found the ASStreamOut class (WebKit/ASStreamOut), the class has > method to flush, clear, close, etc, and has the write method. The write > method is called on HTTPResponse's write method. It seems that the > HTTPResponse's write method write all the content to the _strmOut > attribute. > > So I feed the parser with _strmOut.buffer() (this is the page content > before it is commited), then I call _strmOut.clear(), this method > remove all content write to the page until that point. So I can write > the proper content (the parsed content). It's just the _strmOut stuff that's not as clean. OTOH, Webware is missing a public method for doing what you want -- capturing and replacing the output. I haven't had a problem with this, as I am not generating any HTML inside the servlet, I'm using external templates for that. But if you are generating HTML in your servlet, I can see why you end up doing this. With public methods to redirect output this would all be much more elegant. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: Michel T. <mic...@ya...> - 2004-11-16 01:48:19
|
Hi again!
I hope this is the true list now :) Sorry, it was my fault...
> > How do you work with FormEncode + Webware? I think on a way and
> > implement something, I wrote a class to handle the form validation
> and
> > the error processing:
> >
> > # file: FormServlet.py
> > from validator import htmlfill
> > from validator.schema import Schema
> > from validator import validators
> > from validator.variabledecode import NestedVariables
> >
> > class StandardSchema(Schema):
> > name=validators.NotEmpty()
> > age=validators.Int()
> >
> > class FormServlet:
> > schema=StandardSchema
> > def processForm(self):
> > rawFields=self.request().fields()
> > dictFields=validators.to_python(NestedVariables, rawFields)
> > if not rawFields: # this time the form was not submitted, is it
> true?
> > pass
> > else: # if the form was submitted
> > # first I define the action to execute when the form will be
> processed
> > for action in dictFields['action'].values():
> > if action.has_key(None): # first I find the proper action
> button
> > try:
> > methodToInvoke=action['methodToInvoke'] # try to use
> it's
> > method to invoke
> > except KeyError: # and if none was specified
> > methodToInvoke='processFormData' # use a standard method
> to
> > invoke
> > if action.has_key('suppressValidation'):
> > getattr(self, methodToInvoke)(rawFields)
> > return
>
> There's a security concern here, you should check that the method is
> marked public in some way. In Webware there's the actions() list of
> methods; I've also used attributes, or call all the methods
> action_name,
> or something like that.
Yes, you are right but I have a question about this, is there a problem
on have a class attribute called actions rather than a method?
class MyServlet:
actions=['some_actions', 'some_another_action']
...
Or it's only the author preference?
Let me explain each part of the unclean code:
> > try: # I try to validate it
> > processedFields=validators.to_python(self.schema,
> dict([(key,
> > dictFields[key]) for key in self.schema.fields.keys()]))
First i try to validate the fields over the schema, using the keys of
schema specified. This way, a submit button or another fields that is
not part of the schema is not validated.
> > getattr(self, methodToInvoke)(processedFields)
> > return
> > except validators.Invalid, error: # if an error occours
> > parser=htmlfill.FillingParser(rawFields,
> > errors=error.unpack_errors())
> > parser.feed(self.response()._strmOut.buffer()) # I feed the
> > parser with the page content
> > self.response()._strmOut.clear() # clear the old page
> content
> > self.write(parser.text()) # and write the parsed page
> content
> > parser.close()
> This part isn't very clean (the _strmOut), but then you probably know
> that.
I looked the webware code searching where it writes the page content
out, I found the ASStreamOut class (WebKit/ASStreamOut), the class has
method to flush, clear, close, etc, and has the write method. The write
method is called on HTTPResponse's write method. It seems that the
HTTPResponse's write method write all the content to the _strmOut
attribute.
So I feed the parser with _strmOut.buffer() (this is the page content
before it is commited), then I call _strmOut.clear(), this method
remove all content write to the page until that point. So I can write
the proper content (the parsed content).
> > def sleep(self, t):
> > """This way FormServlet should be the first class on
> extension."""
> > self.processForm()
> > try:
> > self.__class__.__bases__[1].sleep(self, t)
> > except IndexError:
> > raise Exception, 'the Servlet should be extended from two
> other,
> > the FormServlet and a BaseServlet'
>
> I think this is a bit too implicit and automatic, though maybe it
> will
> work fine. This automatic aspect was something I didn't like about
> FunFormKit, I'd rather have processForm() get called explicitly.
I agree again, I was thinking on a way to get the two possibilities
working together, or the use calls processForm on a method, or the user
let to the FormServlet do the job.
The first one is better on time I can call it on the writeBody method
(writeContent maybe), and write a header with a sucess message or a
error message.
> FormEncode had some of this, in FormComponent
>
(svn://colorstudy.com/trunk/FormEncode/experimental/FormEncodeKit/FormComponent);
>
> it worked reasonably well. It's built on Component (from
> svn://w4py.org/Component) is a way of mixing together pieces of code
> into one servlet, which is where some of the awkwardness is coming
> from.
Thank you for all the attention!
=====
--
Michel Thadeu Sabchuk
Curitiba/PR
_______________________________________________________
Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora! http://br.acesso.yahoo.com/
|
|
From: Michel T. <mic...@ya...> - 2004-11-16 00:44:04
|
Hi again!
I hope this is the true list now :) Sorry, it was my fault...
> > How do you work with FormEncode + Webware? I think on a way and
> > implement something, I wrote a class to handle the form validation
> and
> > the error processing:
> >
> > # file: FormServlet.py
> > from validator import htmlfill
> > from validator.schema import Schema
> > from validator import validators
> > from validator.variabledecode import NestedVariables
> >
> > class StandardSchema(Schema):
> > name=validators.NotEmpty()
> > age=validators.Int()
> >
> > class FormServlet:
> > schema=StandardSchema
> > def processForm(self):
> > rawFields=self.request().fields()
> > dictFields=validators.to_python(NestedVariables, rawFields)
> > if not rawFields: # this time the form was not submitted, is it
> true?
> > pass
> > else: # if the form was submitted
> > # first I define the action to execute when the form will be
> processed
> > for action in dictFields['action'].values():
> > if action.has_key(None): # first I find the proper action
> button
> > try:
> > methodToInvoke=action['methodToInvoke'] # try to use
> it's
> > method to invoke
> > except KeyError: # and if none was specified
> > methodToInvoke='processFormData' # use a standard method
> to
> > invoke
> > if action.has_key('suppressValidation'):
> > getattr(self, methodToInvoke)(rawFields)
> > return
>
> There's a security concern here, you should check that the method is
> marked public in some way. In Webware there's the actions() list of
> methods; I've also used attributes, or call all the methods
> action_name,
> or something like that.
Yes, you are right but I have a question about this, is there a problem
on have a class attribute called actions rather than a method?
class MyServlet:
actions=['some_actions', 'some_another_action']
...
Or it's only the author preference?
Let me explain each part of the unclean code:
> > try: # I try to validate it
> > processedFields=validators.to_python(self.schema,
> dict([(key,
> > dictFields[key]) for key in self.schema.fields.keys()]))
First i try to validate the fields over the schema, using the keys of
schema specified. This way, a submit button or another fields that is
not part of the schema is not validated.
> > getattr(self, methodToInvoke)(processedFields)
> > return
> > except validators.Invalid, error: # if an error occours
> > parser=htmlfill.FillingParser(rawFields,
> > errors=error.unpack_errors())
> > parser.feed(self.response()._strmOut.buffer()) # I feed the
> > parser with the page content
> > self.response()._strmOut.clear() # clear the old page
> content
> > self.write(parser.text()) # and write the parsed page
> content
> > parser.close()
> This part isn't very clean (the _strmOut), but then you probably know
> that.
I looked the webware code searching where it writes the page content
out, I found the ASStreamOut class (WebKit/ASStreamOut), the class has
method to flush, clear, close, etc, and has the write method. The write
method is called on HTTPResponse's write method. It seems that the
HTTPResponse's write method write all the content to the _strmOut
attribute.
So I feed the parser with _strmOut.buffer() (this is the page content
before it is commited), then I call _strmOut.clear(), this method
remove all content write to the page until that point. So I can write
the proper content (the parsed content).
>
>
> > def sleep(self, t):
> > """This way FormServlet should be the first class on
> extension."""
> > self.processForm()
> > try:
> > self.__class__.__bases__[1].sleep(self, t)
> > except IndexError:
> > raise Exception, 'the Servlet should be extended from two
> other,
> > the FormServlet and a BaseServlet'
>
> I think this is a bit too implicit and automatic, though maybe it
> will
> work fine. This automatic aspect was something I didn't like about
> FunFormKit, I'd rather have processForm() get called explicitly.
I agree again, I was thinking on a way to get the two possibilities
working together, or the use calls processForm on a method, or the user
let to the FormServlet do the job.
The first one is better on time I can call it on the writeBody method
(writeContent maybe), and write a header with a sucess message or a
error message.
> FormEncode had some of this, in FormComponent
>
(svn://colorstudy.com/trunk/FormEncode/experimental/FormEncodeKit/FormComponent);
>
> it worked reasonably well. It's built on Component (from
> svn://w4py.org/Component) is a way of mixing together pieces of code
> into one servlet, which is where some of the awkwardness is coming
> from.
Thank you for all the attention!
=====
--
Michel Thadeu Sabchuk
Curitiba/PR
_______________________________________________________
Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora! http://br.acesso.yahoo.com/
|
|
From: Ian B. <ia...@co...> - 2004-11-15 22:06:03
|
Shannon -jj Behrens wrote: >>Oops, still the wrong list -- for...@li... is the >>better list for this. Though I did just notice that I wasn't subscribed >>to that list... huh. Anyway, subscribed now. > > > Hmm, that would explain why you never responded to any of my mail. At > the company I work for, we decided not to use formencode because you > never replied to any of our questions! ;) Damn, I'm sorry about that. I must have just overlooked it when I set everything up, and then I just figured it was all very quiet... -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: Shannon -jj B. <jj...@gm...> - 2004-11-15 21:52:23
|
> Oops, still the wrong list -- for...@li... is the > better list for this. Though I did just notice that I wasn't subscribed > to that list... huh. Anyway, subscribed now. Hmm, that would explain why you never responded to any of my mail. At the company I work for, we decided not to use formencode because you never replied to any of our questions! ;) Oh well, -jj -- I am trying out gmail right now. I am forwarding all of my Yahoo mail to gmail, so please do not update your address book just yet. |
|
From: Ian B. <ia...@co...> - 2004-11-15 20:22:54
|
Michel Thadeu Sabchuk wrote: > Hi all! > > I try to use this behavior without sucess, I think I can be doing > something wrong: > > class MyValidator(validators.FancyValidator): > if_missing=-1 > ... > > This way my class will use -1 as the value if the validator was used > inside a Schema and the Schema key for the validator was not found, > won't it? Is this another syntax valid too: > > class MySchema(schema.Schema): > my_validator=MyValidator(if_missing=-1) What is the problem you are seeing? If the key is present, but is the empty string, then if_missing won't get triggered (if_empty will, though). -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
|
From: Ian B. <ia...@co...> - 2004-11-15 20:22:53
|
Michel Thadeu Sabchuk wrote:
> Hi guys, my first participation on this list was unsucessfull, I sent
> the message to wrong list...
Oops, still the wrong list -- for...@li... is the
better list for this. Though I did just notice that I wasn't subscribed
to that list... huh. Anyway, subscribed now.
> Well, I enjoy FormEncode, I think it's very flexible, I am FunFormKit
> user and I agree it is too restrict and becomes too complicated :)
> I first have a question about the htmlfill, I try it with sucess using
> the default substitution and the tag <form:error.../> but I have a
> problem with <form:iferror...></form:iferror>. The strange thing is that
> the <form:error> function works well, but the iferror not, first when I
> show the form, after replace the default values the <form:iferror> is
> not supressed. When I try to send wrong data (to force the form fail), I
> get an Exception:
>
> File "/usr/lib/python2.3/site-packages/validator/htmlfill.py", line 68,
> in feed
> HTMLParser.HTMLParser.feed(self, data)
> File "/usr/lib/python2.3/HTMLParser.py", line 108, in feed
> self.goahead(0)
> File "/usr/lib/python2.3/HTMLParser.py", line 150, in goahead
> k = self.parse_endtag(i)
> File "/usr/lib/python2.3/HTMLParser.py", line 329, in parse_endtag
> self.handle_endtag(tag.lower())
> File "/usr/lib/python2.3/site-packages/validator/htmlfill.py", line
> 127, in handle_endtag
> self.handle_end_iferror()
> TypeError: handle_end_iferror() takes exactly 2 arguments (1 given)
This exception should be resolved now. There still might be problems
with <form:iferror> being left in the output, I'll have to look at that
more closely.
> How do you work with FormEncode + Webware? I think on a way and
> implement something, I wrote a class to handle the form validation and
> the error processing:
>
> # file: FormServlet.py
> from validator import htmlfill
> from validator.schema import Schema
> from validator import validators
> from validator.variabledecode import NestedVariables
>
> class StandardSchema(Schema):
> name=validators.NotEmpty()
> age=validators.Int()
>
> class FormServlet:
> schema=StandardSchema
> def processForm(self):
> rawFields=self.request().fields()
> dictFields=validators.to_python(NestedVariables, rawFields)
> if not rawFields: # this time the form was not submitted, is it true?
> pass
> else: # if the form was submitted
> # first I define the action to execute when the form will be processed
> for action in dictFields['action'].values():
> if action.has_key(None): # first I find the proper action button
> try:
> methodToInvoke=action['methodToInvoke'] # try to use it's
> method to invoke
> except KeyError: # and if none was specified
> methodToInvoke='processFormData' # use a standard method to
> invoke
> if action.has_key('suppressValidation'):
> getattr(self, methodToInvoke)(rawFields)
> return
There's a security concern here, you should check that the method is
marked public in some way. In Webware there's the actions() list of
methods; I've also used attributes, or call all the methods action_name,
or something like that.
> try: # I try to validate it
> processedFields=validators.to_python(self.schema, dict([(key,
> dictFields[key]) for key in self.schema.fields.keys()]))
> getattr(self, methodToInvoke)(processedFields)
> return
> except validators.Invalid, error: # if an error occours
> parser=htmlfill.FillingParser(rawFields,
> errors=error.unpack_errors())
> parser.feed(self.response()._strmOut.buffer()) # I feed the
> parser with the page content
> self.response()._strmOut.clear() # clear the old page content
> self.write(parser.text()) # and write the parsed page content
> parser.close()
This part isn't very clean (the _strmOut), but then you probably know that.
> def sleep(self, t):
> """This way FormServlet should be the first class on extension."""
> self.processForm()
> try:
> self.__class__.__bases__[1].sleep(self, t)
> except IndexError:
> raise Exception, 'the Servlet should be extended from two other,
> the FormServlet and a BaseServlet'
I think this is a bit too implicit and automatic, though maybe it will
work fine. This automatic aspect was something I didn't like about
FunFormKit, I'd rather have processForm() get called explicitly.
FormEncode had some of this, in FormComponent
(svn://colorstudy.com/trunk/FormEncode/experimental/FormEncodeKit/FormComponent);
it worked reasonably well. It's built on Component (from
svn://w4py.org/Component) is a way of mixing together pieces of code
into one servlet, which is where some of the awkwardness is coming from.
> def processFormData(self, fields):
> """A sample method to handle the data submitted and
> validated/converted."""
> pass
> # end of file
>
> # file Teste.py
> # a example of use to the above class
> from Modelo import Modelo # modelo could be Page
> from FormServlet import FormServlet
> from validator.schema import Schema
> from validator import validators
>
> class Registro(Schema):
> name=validators.NotEmpty()
> age=validators.Int()
>
> class Teste(FormServlet, Modelo):
> titulo='Teste'
> schema=Registro
> def writeBody(self, **kw): # writeBody could be writeContent
> self.write('''\
> <form method="post">
> <table>
> <tr>
> <td>Name: <form:error name="name"></td><td><input type="text"
> name="name"></td>
> </tr>
> <tr>
> <td>Age: <form:error name="age"></td><td><input type="text"
> name="age"></td>
> </tr>
> </table>
> <p>
> <input type="submit" name="action.send" value="Send Data">
> <input type="hidden" name="action.send.methodToInvoke" value="sendData">
> <input type="submit" name="action.cancel" value="Cancel Operation">
> <input type="hidden" name="action.cancel.methodToInvoke"
> value="cancelOperation">
> <input type="hidden" name="action.cancel.suppressValidation" value="True">
> </p>
> </form>''')
>
> def sendData(self, fields):
> self.write('<h4>OK!!!</h4>')
>
> def cancelOperation(self, fields):
> self.write('<h4>Cancel!!!</h4>')
>
> # end of file
>
> This is only a first try, I think I can change the action handling
> method, the design should not know how an action suppress validation or
> what is the method to invoke when the action is clicked.
>
> The important thing is the need of compatibility between the Schema
> validator and the form design...
> Do you have suggestions? Are anybody working on something similar to this?
> Thanks for all attention...
--
Ian Bicking / ia...@co... / http://blog.ianbicking.org
|
|
From: Ian B. <ia...@co...> - 2004-11-12 18:48:55
|
I think you wrote to the SQLObject list, but meant to write to the
FormEncode list
Michel Thadeu wrote:
> Ian, after the recent thread about form validation I think to try
> FormEncode, I used and still use FunFormKit for my projects, I use the
> FFK form generation and I confess it limitates my possibilities.
>
> I like the way htmlfill work, I tried to make a validator to a form
> with sucess, my only problem was when I try to use htmlfill. I will put
> my code on the end of message.
>
> I must question you that are using FormEncode with Webware, what is the
> best way to work with the two packages? I think in a way:
Well, I'm still working out some of it (while trying not to make it too
automatic, and in the process mysterious). But here's more or less how
an edit form for a database object works. I'm realizing it's not that
short... sigh.
One app works like this:
def setup(self):
self.form_fields = self.request().fields()
if (self.form_fields.get('id', 'new') != 'new'
and not self.form_fields.get('submit')):
# fill in defaults...
python_data = self.schema.event_to_python(
db.Event.get(int(self.form_fields['id'])))
# note event_to_python is something I coded elsewhere
self.form_fields = variabledecode.variable_encode(
self.schema.from_python(python_data))
result, rendered_form = self.form()
if result is not None:
# successful submission, again python_to_event coded elsewhere
new_event = self.schema.python_to_event(result)
self.redirect(...)
def form(self):
fields = self.form_fields
errors = {}
if fields.has_key('submit'):
try:
del fields['submit'] # not part of the schema
result = self.schema.to_python(
variabledecode.variable_decode(fields))
except Invalid, e:
errors = variabledecode.variable_encode(e.unpack_errors())
else:
return result, None
# 'submit' is a hidden
fields['submit'] = 'true'
p = htmlfill.FillingParser(fields, errors=errors, use_all_keys=True)
# I actually use ZPT to render the form, but not the defaults...
p.feed(self.get_html())
p.close()
form = p.text()
return None, form
> First I will check for errors in the writeHTML method, if the form was
> processed and there is an error, I will define an attribute with this
> error. If there is no error, I can call a formProcessed function...
>
> Then I should write the content of the page, the form is part of the
> page (using self.write to write it). I want to trigger the page
> writing, I want to get the content before write and then parse it with
> htmlfill, filling default values and error messages. Does anyone know
> how can I trigger the page writing? I use a subclass of the Cheetah's
> Template, not Page.
>
> Sorry any english mistake, my htmlfill try are the follow:
>
> #:: FormEncode test...
> from validator.schema import Schema
> from validator import validators
> from validator import htmlfill
>
> class MyValidator(Schema):
> name=validators.String(not_empty=True)
> age=validators.Int()
>
> form='''\
> <form method="post">
> <table>
> <tr>
> <td>Name: <form:error name="name"></td><td><input type="text"
> name="name"></td>
> <form:iferror name="name">mndfnaofdas</form:iferror>
> </tr>
> <p><input type="submit" name="_action_send" value="Send Data"></p>
> </form>'''
>
> userInput={'name':'michel', 'age':20}
>
> errorDict={}
> try:
> userInput=validators.to_python(MyValidator, userInput)
> except validators.Invalid, error:
> errorDict=error.error_dict
I think this should be errorDict = error.unpack_errors(); especially if
the form has nested items (though this one doesn't). Otherwise it looks
fine, except for the bug you found.
> parser=htmlfill.FillingParser(userInput, errors=errorDict)
> parser.feed(form)
> print parser.text()
> parser.close()
>
> ...
>
> I get the follow error:
>
> Traceback (most recent call last):
> File "teste.py", line 29, in ?
> parser.feed(form)
> File "/usr/lib/python2.3/site-packages/validator/htmlfill.py", line
> 68, in feed
> HTMLParser.HTMLParser.feed(self, data)
> File "/usr/lib/python2.3/HTMLParser.py", line 108, in feed
> self.goahead(0)
> File "/usr/lib/python2.3/HTMLParser.py", line 150, in goahead
> k = self.parse_endtag(i)
> File "/usr/lib/python2.3/HTMLParser.py", line 329, in parse_endtag
> self.handle_endtag(tag.lower())
> File "/usr/lib/python2.3/site-packages/validator/htmlfill.py", line
> 127, in handle_endtag
> self.handle_end_iferror()
> TypeError: handle_end_iferror() takes exactly 2 arguments (1 given)
>
> Thanks for any help!
I guess I haven't been using iferror, the formatter mostly works for me.
Anyway, that was just a bug, I committed a fix to it.
--
Ian Bicking / ia...@co... / http://blog.ianbicking.org
|
|
From: Carlos R. <car...@gm...> - 2004-10-08 22:38:25
|
On Fri, 08 Oct 2004 17:05:10 -0500, Ian Bicking <ia...@co...> wrote: > Nested classes are unusual, so I don't think it has a name. If you > think of the objects as factories instead of classes (where classes are > also factories) then I think there might be a term for this. :-/ I'm not _that_ good at naming things... and specially considering that english is not my first language, I'm afraid I may come up with a really terrible name for it. > IPage(root.users) would be the typical way to phrase this now. > PyProtocols added this recently, and Zope and Twisted have been using > this syntax for a while, though I have yet to convert FormEncode to do this. Nice. I'm still fleshing out the details, and I'm doing some experiments with it. As I said, that's more like pseudo code now. Many things don't run yet -- I'm writing samples and reading it later, checking what idiom best conveys the meaning of it. It's not defined if I'm going to use a class or a interface for this type of construction (as per PyProtocols definition -- the pure interface style vs the baseclass style). Only actual coding can answer that, but, as you said, Zope and Twisted are good examples of actual usage. > > 2) Use composition instead of single inheritance. One good example is > > the validator problem. A single data field may be seen as a composite > > structure: > > <...sample snip...> > I can see how this makes sense. Without this abstract master object > (DataField), you end up with a circle of objects, where each points to > the others and none of them are clearly the "master". I might try this > with FormEncode. Yes, that's the idea. At this level of the application hierarchy, all _aspects_ are peers. The master has only a few propertis -- a common name and other properties that are valid for whatever aspect is associated with it. (I'm using the word "aspect" here for the first time -- as we talk, it seems that I'm getting closer to aspect-oriented programming... it's really interesting) > Well, the validators in FormEncode actually do conversion in addition to > validation, which is why the view adds validators -- it's really adding > converters to the process. Conversion is another aspect, don't you think? On the other hand, it may be done either before or after validation, so there's not a clear precedence order... that may be a good reason to implement both aspects (validation & conversion) into a single class. > > What happens, behind the scene, is that the true username object is > > much more complex, and is composed of other nested instances and > > attributes. But the programmer does not need to see it. This > > complexity is hidden by the adaptation layer, and the programmer works > > with a higher abstraction layer. > > Right. Except it's gets into that circular situation, where all the > objects are peers, but they are also all (kind of) interchangeable. > It's easier to think about if there's a single master object, and each > of these interfaces is another face on that master object. But it's > unclear what the master object should be. Maybe it shouldn't "be" > anything -- it would be your domain object, up to the programmer to > construct and name. Yes -- the master object is a kind of named container that know how to manage all its aspects. It can accept new aspects; for example, one could add new aspects at runtime to build the structure in a incremental way. BTW, the mapping of the application to a tree structure is something that also bothers me. It looks too rigid, and may impose a forced structure on the application. But it's a simplification, and at this point, it's much needed to make things manageable (at least it makes things predictable). Finally, thank you -- this conversation greatly enhanced my own understanding of the problem. I have a short vacation ahead now, and it's better for me to go and pack my stuff before my wife comes home :-) But I'm very happy with the progress today -- no code, but a lot of ideas are much clearer now. Have a nice weekend! -- Carlos Ribeiro Consultoria em Projetos blog: http://rascunhosrotos.blogspot.com blog: http://pythonnotes.blogspot.com mail: car...@gm... mail: car...@ya... |