[Zope] on dates

massimop at users.berlios.de massimop at users.berlios.de
Mon Oct 11 14:13:15 EDT 2004


On Mon, 2004-10-11 at 18:57 +0100, Cliff Ford wrote:
> You could try writing a wee Python script. This one gets the date from 
> the query:
> 
> for result in context.theQuery():
>      print result.theDate.strftime('%H:%M, %a %d %b, %Y')
> return printed
> 
> Then call the script from the template.
> 
> Alternatively, you could pass the date string to the Python script.
> 
> Actually, I call a dtml object from a template, and the dtml calls the 
> script (because the dtml has some extra HTML layout and the python does 
> the date formatting - so the template looks uncomplicated).
> 
> Cliff
> 

following your suggestion (if I've understood) I tried this script:

## Script (Python) "formatdate_py"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=d
##title=
##
# Import a standard function, and get the HTML request and response
objects.
from Products.PythonScripts.standard import html_quote
request = container.REQUEST
RESPONSE =  request.RESPONSE

return d.day


and then called it from a page template with:

<i tal:content="python: here.formatdate_py(item.data)"></i>

but it's sadly the same...

<<You are not allowed to access 'day' in this context>>

and it dosn't change if I pass 'item' to the script an access the field
'data' inside it


thanks for your help
massimo






More information about the Zope mailing list