DateTime, Zope DateTime and PostGres
If some of you had problems converting date results from a PostGres DB, then I hope the following lines will help you out: Problem 1. Since the PyGreSQL Adapter is derived from the standard PyGres Module, it will return Dates as Strings. Thats annoying, but the developer of the pygres module is working at the problem. 2. The DateTime module that comes with Zope is not complete. It does not contain the very important Parser. Solution: 1. You can download and compile the full mxDateTime module. You will have an entire directory called DateTime. Rename it (to avoid conflicts with Zope's DateTime) to something like DateTimeNew. Now copy the directory into ZopeDir/lib/python/. You will be now able to call DateTimeNew from the modules you write for External Methods. 2. Create a module in ZopeDir/Extensions. For example: mymodule.py There you can put code like: import DateTimeNew def format_date_string(date_string, format): date = DateTimeNew.Parser.DateTimeFromString(date_string) return date.strftime(format) 3. Let's say the external method in Zope has the same name as the module function. You can then use it like that, assuming you have a Z SQL method called qry_get_date_of_data that gets all values from column 'created': <dtml-in qry_get_date_of_data> <dtml-var "format_date_string(created, '%a %b %d, %Y %H:%M:%S')"><br> </dtml-in> I hope that helps. I agree, it is a hack, but better then nothing. stephan -- Stephan Richter iXL - Software Designer and Engineer
Where can I downloade the mxDateTime module ? Andreas Stephan Richter wrote:
If some of you had problems converting date results from a PostGres DB, then I hope the following lines will help you out:
Problem 1. Since the PyGreSQL Adapter is derived from the standard PyGres Module, it will return Dates as Strings. Thats annoying, but the developer of the pygres module is working at the problem. 2. The DateTime module that comes with Zope is not complete. It does not contain the very important Parser.
Solution: 1. You can download and compile the full mxDateTime module.
^^^^^^^^^^^^^^^^^ ...
You can download it directly from the python home page. here is the direct URL: http://starship.python.net/~lemburg/mxDateTime.html Just follow the installation instructions. stephan On Mon, 09 Aug 1999, you wrote:
Where can I downloade the mxDateTime module ?
Andreas
Stephan Richter wrote:
If some of you had problems converting date results from a PostGres DB, then I hope the following lines will help you out:
Problem 1. Since the PyGreSQL Adapter is derived from the standard PyGres Module, it will return Dates as Strings. Thats annoying, but the developer of the pygres module is working at the problem. 2. The DateTime module that comes with Zope is not complete. It does not contain the very important Parser.
Solution: 1. You can download and compile the full mxDateTime module.
^^^^^^^^^^^^^^^^^ ...
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev ) -- Stephan Richter iXL - Software Designer and Engineer
participants (2)
-
Andreas -
Stephan Richter