<div dir="ltr">Hello, <br><br>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.<br><br>
>From what I read, the edit form needs to override the getContent function:<br><br>def getContent(self):<br> #get the id from the request object<br> personid = int(<b>self.request['entityid']</b>)<br>
<br> #use the id to look up the person<br> person = sql.getPerson(personid)<br><br> #create a return a dictionary<br> content = dict(<br> [ (name, getattr(person,name))<br>
for name in self.fields.keys()]) <br> return content<br><br>This works and I can display values just fine, but when I do something similar in the action handler<br><br> @button.buttonAndHandler(u'Apply',name='applyView')<br>
def handleApplyView(self,action):<br> self.handleApply(self,action)<br> if not self.widgets.errors:<br> url = absoluteURL(self.context,self.request)<br> url += '/person-view?id=' + <b>self.request['entityid']</b><br>
self.request.response.redirect(url)<br><br><br>I get an error that there is no entityid key in self.request. Inspecting the request object seems to confirm that. <br>I guess my other options are to:<br>
<br>- Get the value from form directly with <b>self.request.form.widgets.entityid</b> (seems like an ugly thing to do)<br>- Get the value from <b>data[]</b> dictionary.<br><br>What would be the best pattern for handling this type of processing?<br>
<br>I have used z3c.formdemo and their example (sqlmessage) but for some reason self.request['id'] seems to work for them. <br><br>Thanks for your time<br><br>Daniel Fimiarz<br></div>