[Zope-dev] HTMLFile() question

Evan Simpson evan@4-am.com
Thu, 18 Nov 1999 16:01:48 -0600


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