Hi there, In my Product code I do more or less the following: .. from Globals import HTMLFile form1 = HTMLFile('addForm', globals(), formname='form1') form2 = HTMLFile('addForm', globals(), formname='form2') form3 = HTMLFile('addForm', globals(), formname='form3') .. addForm.dtml contains something like this: .. The name of the form is:<dtml-var formname> .. After this I register several product classes with Zope, product1, product2 and product3 each given their own form (form1, form2 and form3) as their addForm. Now, upon trying to add product1, I'd like it to have 'form1' appear in its addForm. But instead 'form3' appears, the HTMLFile that was created last. This happens for form2 as well. Somehow all the earlier values are forgotten. Why does this happen? What am I doing wrong? Should I use globals() as an argument here? What other arguments could work in its place? If I don't use globals() but None instead, Zope won't find the addForm.dtml file at all, looking for it in 'lib/python' for some reason. I suppose I should dig more into the code, but could anybody enlighten me on what's going on? Regards, Martijn
Martijn Faassen wrote:
In my Product code I do more or less the following:
form1 = HTMLFile('addForm', globals(), formname='form1')
[snip]
Why does this happen? What am I doing wrong? Should I use globals() as an argument here? What other arguments could work in its place? If I don't use globals() but None instead, Zope won't find the addForm.dtml file at all, looking for it in 'lib/python' for some reason. I suppose I should dig more into the code, but could anybody enlighten me on what's going on?
Here's some code I use in PythonMethod: from Globals import MessageDialog, HTMLFile, package_home import sys, os, traceback, re _www = os.path.join(package_home(globals()), 'www') manage_addPythonMethodForm=HTMLFile('methodAdd', _www) I do this because a recent version was bitten by a bug which mysteriously prevented my objects from being copied, imported, renamed, etc. It had something to do with the add form being initialized with HTMLFile('www/methodAdd', globals()), and changing to the above cured it. In any case, you may wish to try something like: from Globals import HTMLFile, package_home _pdir = package_home(globals()) form1 = HTMLFile('addForm', _pdir, formname='form1') ... Cheers, Evan @ 4-am
Evan Simpson wrote:
Martijn Faassen wrote:
[my problems with HTMLFile] [snip]
from Globals import HTMLFile, package_home _pdir = package_home(globals()) form1 = HTMLFile('addForm', _pdir, formname='form1') ...
Nope, this approach gives me the same bug as the one I described before. Weird. Anyway, I hacked around this problem with a custom class, but it'd be cleaner to use HTMLFile, so I'm still curious. Thanks anyway, though! Regards, Martijn
participants (2)
-
Evan Simpson -
Martijn Faassen