Re: [ZPT] creating lists of objects in tal
Am 07.09.2006 um 15:10 schrieb Sinan Kalkan: the announcements python:[] part in tal:define tag initializes the list, and the list becomes populated with the a python:announcements.append(obj) in tal:define tag. You should assemble all your data structures outside of your template and pass them in. ZPT's run security checks on all objects which might be one reason for slowing stuff down. I suspect if you rewrite your code to use a single PythonScript then it will run a lot faster and be a lot easier to work with. Charlie -- Charlie Clark Helmholtzstr. 20 Düsseldorf D- 40215 Tel: +49-211-938-5360 GSM: +49-178-782-6226 ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
[ZPT] Using alternatives to Zope's DateTime module in PageTemplates
Hi, this is probably a no brainer but I haven't found a solution to it yet. Is there a simple way to enable Python modules for use in PageTemplates as is the case with PythonScripts? ie. I would like to be able to replace DateTime instances with mxDateTime instances applying formatting strftime('%d.%m.%Y') currently throws a security error as neither mxDateTime nor even Python's own datetime methods are allowed by default in PageTemplates. Thanks Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows, Mac OS, Linux, Solaris, FreeBSD for free! ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
Re: [ZPT] Using alternatives to Zope's DateTime module in PageTemplates
Am 23.10.2006, 14:36 Uhr, schrieb Andreas Jung [EMAIL PROTECTED]: - lib/python/Products/PythonScripts/README.txt Exactly the same mechanism? I'll give it a try. Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows, Mac OS, Linux, Solaris, FreeBSD for free! ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
Re: [ZPT] Using alternatives to Zope's DateTime module in PageTemplates
Am 23.10.2006, 14:38 Uhr, schrieb Charlie Clark [EMAIL PROTECTED]: Am 23.10.2006, 14:36 Uhr, schrieb Andreas Jung [EMAIL PROTECTED]: - lib/python/Products/PythonScripts/README.txt Exactly the same mechanism? I'll give it a try. I still have the same problem: import mx.DateTime, datetime d1 = mx.DateTime.DateTime(2006, 10, 22) print d1 print d1.strftime(%Y.%m.%d) d2 = datetime.datetime(2006, 10, 22) print d2 print d2.strftime(%Y.%m.%d) return printed strftime() works find with the mx.DateTime object but not with the Python datetime object. Is an additional security declaration required? Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows, Mac OS, Linux, Solaris, FreeBSD for free! ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
Re: [ZPT] Using alternatives to Zope's DateTime module in PageTemplates
Am 23.10.2006, 15:13 Uhr, schrieb Charlie Clark [EMAIL PROTECTED]: I still have the same problem: import mx.DateTime, datetime d1 = mx.DateTime.DateTime(2006, 10, 22) print d1 print d1.strftime(%Y.%m.%d) d2 = datetime.datetime(2006, 10, 22) print d2 print d2.strftime(%Y.%m.%d) return printed strftime() works find with the mx.DateTime object but not with the Python datetime object. Is an additional security declaration required? ah, the problem seems that Python datetime returns extension types and not classes and Zope's security does not work with extension types! Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows, Mac OS, Linux, Solaris, FreeBSD for free! ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
Re: [ZPT] Using alternatives to Zope's DateTime module in PageTemplates
Am 24.10.2006, 22:26 Uhr, schrieb Dieter Maurer [EMAIL PROTECTED]: Charlie Clark wrote at 2006-10-23 16:03 +0200: ... ah, the problem seems that Python datetime returns extension types and not classes and Zope's security does not work with extension types! It does, but you need to use allowType... Thanks for that. import datetime allow_type(datetime.datetime) do work but calling strftime() on a datetime object throws an import error Error Type: ImportError Error Value: import of __doc__ from time is unauthorized. You are not allowed to access '__doc__' in this context Is this correct? This is the same error thrown when using a wrapper class that uses getattr(datime_object, method_name) instead of overwriting the methods. -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows, Mac OS, Linux, Solaris, FreeBSD for free! ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
Re: [ZPT] Using alternatives to Zope's DateTime module in PageTemplates
Am 06.11.2006, 23:12 Uhr, schrieb Dieter Maurer [EMAIL PROTECTED]: Charlie Clark wrote at 2006-10-24 22:43 +0200: Am 24.10.2006, 22:26 Uhr, schrieb Dieter Maurer [EMAIL PROTECTED]: It does, but you need to use allowType... Thanks for that. import datetime allow_type(datetime.datetime) do work but calling strftime() on a datetime object throws an import error Error Type: ImportError Error Value: import of __doc__ from time is unauthorized. You are not allowed to access '__doc__' in this context Is this correct? You know that you must always (!) provide full error information. This includes a traceback (beside Error Type and Error Value. Apologies. Just had this come up again. Now with the full traceback: Traceback (innermost last): Module ZPublisher.Publish, line 115, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 41, in call_object Module Shared.DC.Scripts.Bindings, line 311, in __call__ Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec Module Products.PythonScripts.PythonScript, line 325, in _exec Module None, line 6, in process_bank - PythonScript at /psytec/fachbereich/shrinks/anmelden/process_bank - Line 6 Module Shared.DC.Scripts.Bindings, line 311, in __call__ Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec Module Products.PythonScripts.PythonScript, line 325, in _exec Module None, line 26, in set_bank - PythonScript at /psytec/fachbereich/shrinks/anmelden/set_bank - Line 26 Module Shared.DC.Scripts.Bindings, line 311, in __call__ Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec Module Products.PythonScripts.PythonScript, line 325, in _exec Module None, line 7, in premium - PythonScript at /psytec/scripts/premium - Line 7 Module Shared.DC.Scripts.Bindings, line 311, in __call__ Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec Module Products.PythonScripts.PythonScript, line 325, in _exec Module None, line 15, in printBill - PythonScript at /psytec/scripts/printBill - Line 15 Module Shared.DC.Scripts.Bindings, line 311, in __call__ Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec Module Products.PythonScripts.PythonScript, line 325, in _exec Module None, line 31, in generate - PythonScript at /psytec/scripts/generate - Line 31 Module AccessControl.ZopeGuards, line 284, in guarded_import ImportError: import of __doc__ from time is unauthorized. You are not allowed to access '__doc__' in this context All I am doing is calling strftime() on a datetime object. Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows, Mac OS, Linux, Solaris, FreeBSD for free! ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
Re: [ZPT] Using alternatives to Zope's DateTime module in PageTemplates
Am 15.11.2006, 21:01 Uhr, schrieb Dieter Maurer [EMAIL PROTECTED]: Module None, line 31, in generate - PythonScript at /psytec/scripts/generate - Line 31 Module AccessControl.ZopeGuards, line 284, in guarded_import ImportError: import of __doc__ from time is unauthorized. You are not allowed to access '__doc__' in this context What code do you see in line 31 of psytec/scripts/generate. I expect an import time there and would be really surprised when it would contain someDateTimeObject.strftime(...). If I am wrong, then the RestrictedPython compiler would probably generate wrong code. Why are you surprised that I am formatting a database result? result.create_date.strftime('%d.%m.%Y') # line 31 This has been cast by psycopg to a Python datetime object which I have added as an allowed type. Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows, Mac OS, Linux, Solaris, FreeBSD for free! ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
Re: [ZPT] How to write input to a file and run a perl script
Am 30.04.2007, 15:23 Uhr, schrieb Charu ASTHANA [EMAIL PROTECTED]: Dear users, I am fairly new to zope. i am not much of a computer scientist but I can do some programming. ok so here is my problem: I have ot create a web page, which asks the user for some inputs and upload of a data file. The input values and the file name (the uploaded file will be saved on the server) are to be written to a text file that will be saved on the server. Why do you want to save to a file rather than the Zope database? If you need access to the file system you must use an ExternalMethod. This text file will then be given as input to a perl program that will read and do some calculations. Now I have reached so far: I have created a web page which asks for user inputs. Then when the user submits the form : a) I create another web page that shows the user what all he has inputted and , b) also send the input ( thought he set parameter list) to a python script. Now I am not able to understand ??? 1) how to write all the set of parameter that python script has got onto a text file ( i do not clearly understand about the limitations of script in zope context) Look at context.REQUEST.form in the PythonScript for the values. You cannot access the file system from within a PythonScript 2) Also how do I call a perl script from this python script. ( i could not understand the concept of external methods) You cannot. How complex is the perl script? It might make sense to rewrite it in Python to be able to use it from within Zope otherwise you must use an ExternalMethod to invoke your perl script, pass it the data and get a response from it but would be fairly complicated. Any pointers will be very helpful. Also any example of similar code will be beneficial. For what you want to do it seems strange to want to use Zope rather than using a Perl cgi script. If you are going to stick with the Zope then you should probably spend some time reading the Zope Book to understand what Zope is, how it works and what it lets you do. Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
[ZPT] Working with encoded values in more recent versions of ZPT
Hi, I've noticed in Zope 2.10 that the behaviour of ZPT with regard to encoded values returned by a database has changed which leads to errors when using string: and non-ascii characters. ie. tal:content tal:content=string: ${result/firstname} ${result/surname} / will raise UnicodeDecodeError for result = {'firstname':'charlie', 'surname':'Düsseldorf'} but not if Python string formatting is used tal:content tal:content=python: '%s %s' % (result['firstname'], result['surname']) / Is this the only workaround apart from decoding all return values? Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
Re: [ZPT] Working with encoded values in more recent versions of ZPT
Am 20.08.2007, 20:53 Uhr, schrieb Dieter Maurer [EMAIL PROTECTED]: This is caused by switching in the Zope3 (unicode based) ZPT implementation for Zope 2.10. Yes, I know the cause and can see it in the tracebacks. It's just a bit weird that string formatting works fine but TALES string: expressions treat everything as ASCII. So maybe I need to look at the underlying implementation of ZPT. The new ZPT implementaion required serveral minor releases before it became stable. Maybe, you do not yet have the most current version. Zope 2.10.3-final. There has been another version since then but the changelog makes no reference to ZPT. Andreas tried hard to control the inevitable string/unicode integration problems. Maybe, you read the available documentation to find out about your choices. Have the ZPT docs been updated? Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
Re: [ZPT] Working with encoded values in more recent versions of ZPT
Am 20.08.2007, 21:12 Uhr, schrieb Andreas Jung [EMAIL PROTECTED]: If you think this is a bug, please put it into a unittest (ZPT has enough related tests which can serve as an example). Will do. I've noticed that the newer templates have explicit output-encodings and I thought that this might be related but it seems not. Currently a major issue for me for migrating a site to Zope 2.10 FWIW this is current traceback Traceback (innermost last): Module ZPublisher.Publish, line 119, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 42, in call_object Module Shared.DC.Scripts.Bindings, line 313, in __call__ Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec Module Products.PageTemplates.ZopePageTemplate, line 331, in _exec Module Products.PageTemplates.ZopePageTemplate, line 427, in pt_render Module Products.PageTemplates.PageTemplate, line 89, in pt_render Module zope.pagetemplate.pagetemplate, line 117, in pt_render Module zope.tal.talinterpreter, line 271, in __call__ Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 861, in do_defineMacro Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 824, in do_loop_tal Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 534, in do_optTag_tal Module zope.tal.talinterpreter, line 516, in no_tag Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 824, in do_loop_tal Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 534, in do_optTag_tal Module zope.tal.talinterpreter, line 516, in no_tag Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 754, in do_insertStructure_tal UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 4: ordinal not in range(128) Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
Re: [ZPT] Working with encoded values in more recent versions of ZPT
Am 21.08.2007, 05:27 Uhr, schrieb Andreas Jung [EMAIL PROTECTED]: See http://www.zope.org/Collectors/Zope/2339 Thanks. So this means I don't need to write any additional tests? Glad to know you've resolved it. Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
[ZPT] ZPT encoding for non-web pages
Hi, I've recently experienced trouble when using ZPT for templates for e-mail. I know there is the option for an explicit encoding but these templates are for a CMF so are in the file system and it seems the standard encoding is latin-1 (or latin-9) for such files so I need to encode the pages manually. Is there any way to change this? Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt
Re: [ZPT] PageTemplate.pt_context signature
Am 16.01.2008, 19:29 Uhr, schrieb Thomas Lotze [EMAIL PROTECTED]: Is there some reason for PageTemplate.pt_context to accept arbitrary keyword arguments, but ignore them? It seems to me that it would be cleaner to not accept those arguments in the first place. Alternatively, they might just be added to the context returned by this method, just like the specified args and options parameters. This is actually described as a possible reason for subclassing in readme.txt. Not sure what you mean. Can you provide an example? Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 ___ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt