Hi, I'm working on a ZClass for Trainings. The visitors of the site have to be able to fill in a form online to join a training. At top of the form there is first shown some information about the training. I want to show this info with the GET method of a hyperlink. Like this: <a href="/form/main?<dtml-var PATH_INFO>" methods="GET">Online sign-up</a> The following thing to do is split the PATH_INFO variable and join it with dots: <dtml-let splitpath="_.string.split(QUERY_STRING,'/')" training="_.string.join(splitpath[1:],'.')"> Then I want to get the attributes of the training with the dtml-with tag: <dtml-with "training"> <table cellpadding="3" cellspacing="0" border="0" width="100%"> <tr><td>Institute:</td><td><dtml-var institute></td></tr> <tr><td>Location:</td><td><dtml-var location></td></tr> <tr><td>Title training:</td><td><dtml-var title></td></tr> <tr><td>Start date:</td><td><dtml-var date_start></td></tr> <tr><td>Stop date:</td><td><dtml-var date_stop></td></tr> </table> </dtml-with> </dtml-let> Institute, location etc are attributes of the ZClass Training. The 'with' tag doesn't work; I get KeyErrors. Can somebody help me? Greetz Nico
Nico de Boer wrote: Hmmm ... the weird and wonderfull workings of other peoples minds.... ;-) I don't understand why you use this overly complicated approach but I can see at least one problem:
The following thing to do is split the PATH_INFO variable and join it with dots:
<dtml-let splitpath="_.string.split(QUERY_STRING,'/')" training="_.string.join(splitpath[1:],'.')">
Then I want to get the attributes of the training with the dtml-with tag:
<dtml-with "training"> <table cellpadding="3" cellspacing="0" border="0" width="100%"> <tr><td>Institute:</td><td><dtml-var institute></td></tr> <tr><td>Location:</td><td><dtml-var location></td></tr> <tr><td>Title training:</td><td><dtml-var title></td></tr> <tr><td>Start date:</td><td><dtml-var date_start></td></tr> <tr><td>Stop date:</td><td><dtml-var date_stop></td></tr> </table> </dtml-with> </dtml-let>
Institute, location etc are attributes of the ZClass Training. The 'with' tag doesn't work; I get KeyErrors.
You have just turned "training" into a list of path elelements like: training = ['path', 'to', 'somewhere'] and trying to do: training.institute on a list will do you no good. regards Max M -- "Sorry I would Really Like To Help More On This Project, But Am To Busy Doing Paid Work On A Tight Deadline" Max M
I've first turned the QUERY_STRING into a list (splitpath), that I join with dots (training). So I get the following: training = path.to.training And now I want to do: <dtml-with "training"> what's according to me the same as: <dtml-with "path.to.training"> But the first with-tag doesn't work. Greetz Nico
Hi, I have a Z Class which itself is a base, let's name it ZBase for a number of other classes, say ZDerived1..ZDerivedN. Now I want to add another base class to ZBase, but I don't much fancy rebuilding ZDerived1..ZDerivedN, let alone recreating all instances of the ZDerived family. I found a few articles about this and they all sugest creating a new ZBase, but one with the same Class ID and the same Metatype. In order to avoid all interferance, I created the new ZBase class with the new derivation, added all methods to it, gave it the right Class ID and meta type and exported it to a ZBase.zexp file. Then I went back to the working version of my application with the old ZBase. I deleted the old ZBase, imported the new one and restarted. As luck would have it, things were still working great. Except that ever since, all changes to the new ZBase are ignored. If I change a method in ZBase and call that method using an instance of ZDerived1, I get unchanged results. Somewhere a copy of the old ZBase seems to lurk around. How can that be? I suspect that there are compiled versions of my python code in the ZODB and that for some reason the link to the source has been broken, so that the code is not recompiled or something similar. Any clue what I can do? Douwe
douwe@oberon.nl writes:
... rebasing a ZClass ... Except that ever since, all changes to the new ZBase are ignored. If I change a method in ZBase and call that method using an instance of ZDerived1, I get unchanged results. Somewhere a copy of the old ZBase seems to lurk around. How can that be? Did you restart your Zope?
Until you do, the instance will use the old class (via Python's "sys.modules" cache). Dieter
ZDerived1, I get unchanged results. Somewhere a copy of the old ZBase seems to lurk around. How can that be? Did you restart your Zope?
Yes I did restart Zope, but to no avail. So I decided to dig a little deeper. I exported my base class and one depending class in seperate .zexp files. I set up a new zope server, created a new product and imported the classes. I then deleted all methods from both classes, except one in the base. I modified this method to only return a fixed string. I then added a index_html method to the depending class that would only call the one remaining function in the base class. I created an instance of the depending class and tried to run index_html, but it gave an error, in the method of the base class, but alas on a line that no longer existed. To prove myself a point, I created a new depending class, directly derived from the base class and added the same index_html. Instances of this one do work. Very weird. I then exported the whole thing using xml, just to see if I could find something. Opening the xml reveiled the complete implementation of the base class, including all the methods I deleted. The method I left in the base class turned up twice, once in its new incarnation, once in its old incarnation. I did pack the database before export. I have now two simple zclasses which look completely identical, but give different results. Any clue as to what might go wrong and why deleted code shows up in an export? Douwe
Nico de Boer wrote:
I've first turned the QUERY_STRING into a list (splitpath), that I join with dots (training).
So I get the following:
training = path.to.training
And now I want to do:
<dtml-with "training">
what's according to me the same as:
<dtml-with "path.to.training">
Ah ok ... now I understand. You are doing it just a little wrong. You can traverse Zope with a path from code directly. You must use the restrictedTraverse() method.. Asuming that: QUERY_STRING='path/to/training' You can just do it like: <dtml-call "REQUEST.set('training', getPhysicalRoot().restrictedTraverse(QUERY_STRING))"> <dtml.with training> ... etc. regards Max M -- "Sorry I would Really Like To Help More On This Project, But Am To Busy Doing Paid Work On A Tight Deadline" Max M
participants (4)
-
Dieter Maurer -
douwe@oberon.nl -
Max M -
Nico de Boer