Re: [Zope] I am so lost.
At 05:53 PM 9/25/2003, Lee J. McAllister wrote:
How stranded are we talking?
Still trying to get Zope up and running
That's never been a problem.
or are you stuck trying to build a new Product?
Trying to install a downloaded product.
I know I consider the Zope documentation to be excellent in points but it lacks connectivity. Individual points and tasks are generally explained extremely well but there's very little coverage on how to get from point A to point B or how those points interact. I've found that intelligent googling of the list archives has been at least as helpful, if not more so for me than the documentation overall.
Even trying to grok some simple concepts. e.g. one can specify parameters on a Script (Python) object, but nothing I can find explains how these parameters get values. In looking thru the Shopping Cart Example I found a form specifying in part <form action="addItems"> <input type="text" name="orders.quantity:records" ... where addItems is a script in the same container, and addItems specifies orders, REQUEST=None as parameters. What's missing for me is the relationship between the form and the parameter list. In another example I experimented with a Page Template calculateForm: ... <form action="calculateSum"> <input type="text" name="a" tal:attributes="value request/a"><br> <input type="text" name="b" tal:attributes="value request/b"><br> <input type="text" tal:attributes="value result"><br> <input type=submit value="Submit" name="Next10"> </form> ... where calculateSum is script: ## parameters a,b sum=int(a)+int(b) return container.calculateForm(result=sum) After clicking Submit the form reappears, with the values for a and b filled in. What is the magic that associates the values I entered for a and b with the request to display the form again? Bob Gailer bgailer@alum.rpi.edu 303 442 2625 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003
<snip> You may want to check out devshed's Zope section. I found their articles very useful for starting out with Zope: http://www.devshed.com/Server_Side/zope/
On Thu, 2003-09-25 at 18:58, Bob Gailer wrote:
Even trying to grok some simple concepts. e.g. one can specify parameters on a Script (Python) object, but nothing I can find explains how these parameters get values.
When Zope receives a request a lot of information about that request is bundled up into the REQUEST object. This information includes any variables that were provided by the client, whether through GET or POST. To get an idea of what kind of information the REQUEST object is carrying around, create a Python Script called my_test that contains the following code: return container.REQUEST View this script and then view it as: my_test?var1=foo&var2=bar and see what that gives you. Notice that you now have two variables defined, var1 and var2. Play around with this a bit, try posting a form to it, etc.
In looking thru the Shopping Cart Example I found a form specifying in part
<form action="addItems"> <input type="text" name="orders.quantity:records" ...
where addItems is a script in the same container, and addItems specifies orders, REQUEST=None as parameters. What's missing for me is the relationship between the form and the parameter list.
The form given to the client specifies an action of addItem. That means that when the client posts the form, the addItem object will be called. Because there is a field in the form called orders, the addItem method/script will be passed the value that the client entered into the orders field. It's that simple... Zope makes form values *very* easy to grab and manipulate.
In another example I experimented with a Page Template calculateForm: ... <form action="calculateSum"> <input type="text" name="a" tal:attributes="value request/a"><br> <input type="text" name="b" tal:attributes="value request/b"><br> <input type="text" tal:attributes="value result"><br> <input type=submit value="Submit" name="Next10"> </form> ... where calculateSum is script:
## parameters a,b sum=int(a)+int(b) return container.calculateForm(result=sum)
After clicking Submit the form reappears, with the values for a and b filled in. What is the magic that associates the values I entered for a and b with the request to display the form again?
No magic... what is created by the Page Template is a *form* that the *client* posts to the calculateSum script. The *client* passes in these parameters by posting a form that contain fields with names that match the script's arguments. Sometimes you want Zope objects manipulating one another directly... more often, you create *interfaces* that allow the client to make correctly-formed requests to the objects that do your heavy lifting. Don't forget that almost everything you do with Zope is initiated by a client request and ends with information being transmitted back to them. If it seems like there's a step missing, it's usually because that step is assumed to have taken place on the client side. HTH, Dylan
Bob Gailer wrote at 2003-9-25 19:58 -0600:
... <form action="addItems"> <input type="text" name="orders.quantity:records" ...
where addItems is a script in the same container, and addItems specifies orders, REQUEST=None as parameters. What's missing for me is the relationship between the form and the parameter list.
<http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> may be another resource to read. The ZPublisher section tells you something about the magic of "ZPublisher", especially how request parameters are used to satisfy the parameter needs of called methods. Dieter
participants (4)
-
Bob Gailer -
Dieter Maurer -
Dylan Reinhardt -
Josh Trutwin