[Zope3-Users] z3c, GET variables handling pattern

Daniel Fimiarz dfimiarz at gmail.com
Thu Sep 11 15:19:08 EDT 2008


Hello,

I am new to plone/zope. I am trying to use z3c forms with plone to fetch
some data from RDBMS but I am having an issue with variables passed to edit
forms using GET and POST variables.

>From what I read, the edit form needs to override the getContent function:

def getContent(self):
               #get the id from the request object
               personid = int(*self.request['entityid']*)

               #use the id to look up the person
               person = sql.getPerson(personid)

               #create a return a dictionary
               content = dict(
                       [ (name, getattr(person,name))
                       for name in self.fields.keys()])
               return content

This works and I can display values just fine, but when I do something
similar in the action handler

@button.buttonAndHandler(u'Apply',name='applyView')
       def handleApplyView(self,action):
               self.handleApply(self,action)
               if not self.widgets.errors:
                       url = absoluteURL(self.context,self.request)
                       url += '/person-view?id=' + *self.request['entityid']
*
                       self.request.response.redirect(url)


I get an error that there is no entityid key in self.request.  Inspecting
the request object seems to confirm that.
I guess my other options are to:

- Get the value from form directly with
*self.request.form.widgets.entityid*(seems like an ugly thing to do)
- Get the value from *data[]* dictionary.

What would be the best pattern for handling this type of processing?

I have used z3c.formdemo and their example (sqlmessage) but for some reason
self.request['id'] seems to work for them.

Thanks for your time

Daniel Fimiarz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope3-users/attachments/20080911/8d03bd10/attachment.html 


More information about the Zope3-users mailing list