I want to do the following tasks A user enters a list of products. Such a list is equivalent to an order. Then i want the user to enter some things for each product. I don't want to implement DTML pages for each combination of products and i want to present one entry screen for each order. I tried the following approach: I created a Folder named 'Products'. In this folder i created subfolders named after the prducts code number, e.g. `4007', `4008'., .... In each of these folders i defined a DTML Method `New' which hholds the DTML code to create an input form fr this product. My plan is also to create methods named 'Display', 'Edit', .... so i can render the objects in different ways. In anotehr page i want to do something like: <dtml-in products> <dtml-var "URL1 + '/Products/' + _['sequence-item'] + '/New'"> </dtml-in> but this doesn't work. Nothing is displayed. I also tries <dtml-var expr="...."> and <dtml-call "..."> (the last one was pure desperation). So what's the correct method for implementig such a system?
Michael Lausch schrieb:
I want to do the following tasks
A user enters a list of products. Such a list is equivalent to an order. Then i want the user to enter some things for each product. I don't want to implement DTML pages for each combination of products and i want to present one entry screen for each order.
I tried the following approach: I created a Folder named 'Products'. In this folder i created subfolders named after the prducts code number, e.g. `4007', `4008'., ....
In each of these folders i defined a DTML Method `New' which hholds the DTML code to create an input form fr this product. My plan is also to create methods named 'Display', 'Edit', .... so i can render the objects in different ways.
A more zopish would be: define your 'New', 'Display' and 'Edit' methods in the Products folder and use properties in the subfolders for the different rendering. For example: give each subfolder a property 'Description', and a property 'Price', in your Display method put something like: Description: <dtml-var Description><br> Costs: <dtml-var Price> So, with an url http://yourhost/Products/4007/Display Display is rendered in the context of the object '4007' and its properties will be used.
In anotehr page i want to do something like:
<dtml-in products> <dtml-var "URL1 + '/Products/' + _['sequence-item'] + '/New'"> </dtml-in>
This is a bit unclear. Where do you call it (note that Zope doesn't know 'pages', it only knows objects, which define what's going on) and where does the 'products' come from? I assume you want something like this: <dtml-in "objectValues(['Folder'])"> <dtml-var absolute_url>/New <dtml-var title_or_id><br> </dtml-in> objectValues(['Folder']) gives a list of all (sub)folders of the current object. Note, that if you put this into a DTML Document, the list will be empty, because a DTML Document is an object by itself, which has no folders associated with. You'll need in an DTML Document a <dtml-with "PARENTS[0]">, this will include the namespace of the folder object, where the DTML Document is called from. For each found item <dtml-var absolute_url> displays the absolute url
but this doesn't work. Nothing is displayed. I also tries <dtml-var expr="...."> and <dtml-call "..."> (the last one was pure desperation).
So what's the correct method for implementig such a system?
Generally, this sounds like a typical ZClass task. Have a look into the ZClass tutorial and into the example products (there is one called the boring product on Zope.org) for more informations. hth, Thomas
On Sun, 5 Mar 2000, Michael Lausch wrote:
I want to do the following tasks
A user enters a list of products. Such a list is equivalent to an order. Then i want the user to enter some things for each product. I don't want to implement DTML pages for each combination of products and i want to present one entry screen for each order.
I tried the following approach: I created a Folder named 'Products'. In this folder i created subfolders named after the prducts code number, e.g. `4007', `4008'., ....
In each of these folders i defined a DTML Method `New' which hholds the DTML code to create an input form fr this product. My plan is also to create methods named 'Display', 'Edit', .... so i can render the objects in different ways.
In anotehr page i want to do something like:
<dtml-in products> <dtml-var "URL1 + '/Products/' + _['sequence-item'] + '/New'"> </dtml-in>
Try (untested): <dtml-in expr="Products.objectValues()"> <dtml-var expr="_['sequence-item'].New(_.None, _)"> </dtml-in>
So what's the correct method for implementig such a system?
I would investigate ZClasses. It seems to me like you could end up with a "Product" ZClass (though I might call it something else to avoid confusion with Zope Products), which contains your New, Edit, and Display methods. Depending on how much each Product differs, you might have a WidgetProduct, ThingamabobProduct, DoohickeyProduct, etc. Or, maybe you can just get away with Product. I'd have to know more specifics to get into detail. --Jeff --- Jeff K. Hoffman 704.849.0731 x108 Chief Technology Officer mailto:jeff@goingv.com Going Virtual, L.L.C. http://www.goingv.com/
On Sun, 5 Mar 2000, Michael Lausch wrote:
<dtml-in products> <dtml-var "URL1 + '/Products/' + _['sequence-item'] + '/New'"> </dtml-in>
but this doesn't work. Nothing is displayed. I also tries <dtml-var expr="...."> and <dtml-call "..."> (the last one was pure desperation).
I'm a relative beginner to Zope, so I'm not sure what I'm talking about <grin>, but it seems to me from my limited experience that you can't call out an object using a URL in a dtml-var. Instead you need an object reference. So try something along these lines (this is untested because I'm in the middle of my own debugging mess): <dtml-in products> <dtml-var "Products.get_item(_['sequence-item'],0).New" </dtml-in> I'm sure the above is not right from a Zope standpoint, and the Python is probably wrong too, but maybe it will send you in in the right direction. What I'm aming for with that psuedo code is to get the property of Products whose name is in sequence-item, without rendering it (that's the ',0' bit), and to pick up *its* 'New' property and render that. Maybe a real Zope expert can correct my code. Or more likely, as others have suggested, using a ZClass is the right direction anyway, which would avoid the whole syntax issue <grin>. --RDM
participants (4)
-
Jeff Hoffman -
Michael Lausch -
R. David Murray -
Thomas Weiner