Formulator - TALES problem
Hello, I tried to set the End Datetime for an datetime Formulator object to the current time. I uses TALES and started with python: form.DateTime() This failed with Error Type: AttributeError Error Value: DateTime Now I created a Python script named 'jetzt' which just does return DateTime() and alternatively I tried return str(DateTime()) moreover I tried several different formats. The error.log of Test method of the Formulator object was always like: 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 177, in render Module Products.Formulator.Field, line 155, in _render_helper Module Products.Formulator.Widget, line 671, in render Module Products.Formulator.Field, line 191, in render_sub_field Module Products.Formulator.Field, line 155, in _render_helper Module Products.Formulator.Widget, line 425, in render Module Products.Formulator.Widget, line 328, in render_items Module Products.Formulator.Field, line 106, in get_value Module Products.Formulator.MethodField, line 52, in __call__ Module Products.Formulator.StandardFields, line 148, in override_year_items Module Products.Formulator.Field, line 97, in get_value Module Products.Formulator.TALESField, line 43, in __call__ Module Products.PageTemplates.TALES, line 217, in evaluate - Expression: <PythonExpr form.jetzt()> - Names: {'default': <Products.PageTemplates.TALES.Default instance at 0x86c0cd4>, 'field': <DateTimeField instance at 9022ce0>, 'form': <BoundMethod instance at 9585280>, 'loop': <SafeMapping instance at 86e82e8>, 'nothing': None, 'repeat': <SafeMapping instance at 86e82e8>} Module Products.PageTemplates.ZRPythonExpr, line 48, in __call__ - __traceback_info__: form.jetzt() Module Python expression "form.jetzt()", line 2, in f AttributeError: jetzt Any hint which kind of value I have to return as a valid TALES? Kind regards Andreas.
Hi Andreas 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() 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. righto michael On Wednesday, October 01, 2003, at 03:22 AM, Andreas Tille wrote:
Hello,
I tried to set the End Datetime for an datetime Formulator object to the current time. I uses TALES and started with
python: form.DateTime()
This failed with
Error Type: AttributeError Error Value: DateTime
Now I created a Python script named 'jetzt' which just does
return DateTime() and alternatively I tried return str(DateTime())
moreover I tried several different formats. The error.log of Test method of the Formulator object was always like:
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 177, in render Module Products.Formulator.Field, line 155, in _render_helper Module Products.Formulator.Widget, line 671, in render Module Products.Formulator.Field, line 191, in render_sub_field Module Products.Formulator.Field, line 155, in _render_helper Module Products.Formulator.Widget, line 425, in render Module Products.Formulator.Widget, line 328, in render_items Module Products.Formulator.Field, line 106, in get_value Module Products.Formulator.MethodField, line 52, in __call__ Module Products.Formulator.StandardFields, line 148, in override_year_items Module Products.Formulator.Field, line 97, in get_value Module Products.Formulator.TALESField, line 43, in __call__ Module Products.PageTemplates.TALES, line 217, in evaluate - Expression: <PythonExpr form.jetzt()> - Names: {'default': <Products.PageTemplates.TALES.Default instance at 0x86c0cd4>, 'field': <DateTimeField instance at 9022ce0>, 'form': <BoundMethod instance at 9585280>, 'loop': <SafeMapping instance at 86e82e8>, 'nothing': None, 'repeat': <SafeMapping instance at 86e82e8>} Module Products.PageTemplates.ZRPythonExpr, line 48, in __call__ - __traceback_info__: form.jetzt() Module Python expression "form.jetzt()", line 2, in f AttributeError: jetzt
Any hint which kind of value I have to return as a valid TALES?
Kind regards
Andreas.
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
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.
participants (2)
-
Andreas Tille -
Michael Dunstan