[Zope] Re: Formulator - TALES problem

Andreas Tille tillea at rki.de
Mon Oct 6 04:33:11 EDT 2003


On Fri, 3 Oct 2003, Michael Dunstan wrote:

> Try wrapping the DateTime in python script (say with id GetDateTime)
> then accessing that script via acquisition from the form object. For
> example:
>
>    python: form.GetDateTime()
Well, I tried this several time and have really no explanation for the
problem.  I managed to use Skripts for SQL queries perfectly but if I
want to set a time I always failed with the following strange /error_log:

Traceback (innermost last):
  Module ZPublisher.Publish, line 98, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 39, in call_object
  Module Shared.DC.Scripts.Bindings, line 252, in __call__
  Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec
  Module App.special_dtml, line 174, in _exec
  Module DocumentTemplate.DT_Util, line 201, in eval
   - __traceback_info__: render
  Module <string>, line 0, in ?
  Module Products.Formulator.Field, line 220, in render
  Module Products.Formulator.Field, line 187, in _render_helper
  Module Products.Formulator.Widget, line 805, in render
  Module Products.Formulator.Field, line 240, in render_sub_field
  Module Products.Formulator.Field, line 187, in _render_helper
  Module Products.Formulator.Widget, line 531, in render
  Module Products.Formulator.Widget, line 392, in render_items
  Module Products.Formulator.Field, line 117, in get_value
  Module Products.Formulator.MethodField, line 52, in __call__
  Module Products.Formulator.StandardFields, line 161, in override_year_items
  Module Products.Formulator.Field, line 109, in get_value
AttributeError: REQUEST

I tried several flavours of such a Script (which all work perfectly if I call
them alone).  Here are some failed tests:

   return DateTime()

   return DateTime().strftime("%Y/%m/%d %H:%m")

   return DateTime().HTML4()

   jetzt = DateTime()
   return str(jetzt.mm())+'/'+str(jetzt.dd())+'/'+str(jetzt.year())

   return '11/01/2003' # which not even uses DateTime()

The effect is for all tests the same.

> Note that form is the formulator object within ZODB itself. DateTime is
> not an attribute of that ZODB object (not even with with the use of
> acquistion). Python scripts have some objects already floating about in
> the namespace when they are called. DateTime is one such example of an
> object floating about in that namespace.  An implicit import of
> DateTime if you like.
Any hint what I might have done wrong here?

Kind regards

        Andreas.



More information about the Zope mailing list