[Zope3-Users] Re: Passing Form Data (was Searching Content Objects)

Alen Stanisic alens at mbase.com.au
Sun Jul 31 20:56:13 EDT 2005


Jim Vine wrote:
> How does one go about generating
> a search form that accepts a few criteria, and has a
> "submit" button, that would then go off and fetches
> the results?
> 

Another way of doing this rather than manually building the form, submitting values 
and fetching them using self.request.get() could be defining a schema interface for your
search filter page (the interface containing your search filter attributes). You do not define it
as a content type as you search page is not a persistent object. Then in your browser.zcml
you register it as an addform something like:

<browser:addform
   schema=<your search filter interface>
   name=dummysearch.html
   template=dummysearch.pt
   class=<Add View class where you perform your search>
   >

In your view class I think you override AddView class update() method where after
you do 

data = getWidgetsData(self, <search form interface>)

your form fields should be available in the data dictionary.

Not sure if this would be the recommended way of collecting non-persistent form input but 
I feel that just by handcoding form html and fetching input using self.request.get you lose
some of the nice things of zope3 like automatic form generation and validation which I think
you would want to use even for non-persistent input like search forms. I haven't had a look
at the upcoming formlib but maybe it makes this sort of stuff even easier.

Alen







More information about the Zope3-users mailing list