[Zope] "ZopeTime is not defined" error

Keith J. Farmer kfarmer@thuban.org
Sun, 27 Jan 2002 13:50:23 -0800


I've got a product with a ZClass inside it.  The constructor for the
ZClass uses the ZopeTime trick to generate autoIDs.  When I'm in the ZMI
as a manager, it works fine.  When I'm outside of the ZMI, using a
form/method combo that calls the constructor, even if I'm authenticated
with my management account, I get the ZopeTime error.

I've already scoured the lists, and I've tried the modification to
OFS.Application (ZopeTime__roles__=3DNone) to no avail.  Setting the =
proxy
roles to manager, and setting the security for Access Contents
Information doesn't help, either.

Traceback follows, along with the dtml source for the constructor and
the add method.

----------
Keith J. Farmer
kfarmer@thuban.org
http://www.thuban.org


##### Traceback:

Traceback (innermost last):
  File C:\PROGRA~1\Zope\lib\python\ZPublisher\Publish.py, line 150, in
publish_module
  File C:\PROGRA~1\Zope\lib\python\ZPublisher\Publish.py, line 114, in
publish
  File C:\PROGRA~1\Zope\lib\python\Zope\__init__.py, line 158, in
zpublisher_exception_hook
    (Object: calendar)
  File C:\PROGRA~1\Zope\lib\python\ZPublisher\Publish.py, line 98, in
publish
  File C:\PROGRA~1\Zope\lib\python\ZPublisher\mapply.py, line 88, in
mapply
    (Object: CalendarAdd)
  File C:\PROGRA~1\Zope\lib\python\ZPublisher\Publish.py, line 39, in
call_object
    (Object: CalendarAdd)
  File C:\PROGRA~1\Zope\lib\python\OFS\DTMLMethod.py, line 127, in
__call__
    (Object: CalendarAdd)
  File C:\PROGRA~1\Zope\lib\python\DocumentTemplate\DT_String.py, line
473, in __call__
    (Object: CalendarAdd)
  File C:\PROGRA~1\Zope\lib\python\DocumentTemplate\DT_Util.py, line
159, in eval
    (Object:
PARENTS[0].manage_addProduct['cloondara'].calendar_entry_add(REQUEST))
    (Info: REQUEST)
  File <string>, line 2, in f
  File C:\PROGRA~1\Zope\lib\python\OFS\DTMLMethod.py, line 127, in
__call__
    (Object: calendar_entry_add)
  File C:\PROGRA~1\Zope\lib\python\DocumentTemplate\DT_String.py, line
473, in __call__
    (Object: calendar_entry_add)
  File C:\PROGRA~1\Zope\lib\python\DocumentTemplate\DT_Util.py, line
159, in eval
    (Object: REQUEST.set('ts', ZopeTime()))
    (Info: REQUEST)
  File <string>, line 2, in f
NameError: (see above)


##### Public Add method:

<dtml-var standard_html_header>

<h2><dtml-var title></h2>

<dtml-call
"PARENTS[0].manage_addProduct['cloondara'].calendar_entry_add(REQUEST)">

<p>Thanks for your submission.</p>

<dtml-call expr=3D"RESPONSE.redirect(URL1)">

<dtml-var standard_html_footer>


##### ZClass's constructor:

<HTML>
<HEAD><TITLE>Add calendar_entry</TITLE></HEAD>
<BODY BGCOLOR=3D"#FFFFFF" LINK=3D"#000099" VLINK=3D"#555555">

<dtml-comment> We add the new object by calling the class in
                a with tag.  Not only does this get the thing
                added, it adds the new thing's attributes to
                the DTML name space, so we can call methods
                to initialize the object.
</dtml-comment>

<dtml-comment>
                The dtml-calls below are for auto-id during object
                initialization.
</dtml-comment>
<dtml-call "REQUEST.set('ts', ZopeTime())">
<dtml-call "REQUEST.set('id',_.str(_.int(ts)))">

<dtml-with "calendar_entry.createInObjectManager(REQUEST['id'],
REQUEST)">

  <dtml-comment>

     You can add code that modifies the new instance here.

     For example, if you have a property sheet that you want to update
     from form values, you can call it here:

       <dtml-call "propertysheets.Basic.manage_editProperties(
                  REQUEST)">

  </dtml-comment>

<dtml-call "REQUEST.set('title', REQUEST['date_start'] + '-' +
REQUEST['name'])">

<dtml-call "propertysheets.entry_info.manage_editProperties(REQUEST)">

<dtml-call reindex_object>

</dtml-with>

<dtml-comment> Now we need to return something.  We do this via
                a redirect so that the URL is correct.

                Unfortunately, the way we do this depends on
                whether we live in a product or in a class.
                If we live in a product, we need to use DestinationURL
                to decide where to go. If we live in a class,
                DestinationURL won't be available, so we use URL2.
</dtml-comment>

<dtml-if NoRedir>
<dtml-else>

<dtml-if DestinationURL>

 <dtml-call "RESPONSE.redirect(
       DestinationURL+'/manage_workspace')">

<dtml-else>

    <dtml-call "RESPONSE.redirect(
           URL2+'/manage_workspace')">
</dtml-if>

</dtml-if>

</body></html>