[ZDP] BackTalk to Document The Zope Book (2.6 Edition)/Using Zope
Page Templates
webmaster at zope.org
webmaster at zope.org
Thu Jan 8 20:46:11 EST 2004
A comment to the paragraph below was recently added via http://zope.org/Documentation/Books/ZopeBook/2_6Edition/ZPT.stx#2-70
---------------
You can also fix the date formatting problems with a little
Python. Create a script named 'file_date' in your 'FileLib'
folder::
## Script (Python) "file_date"
##
"""
Return modification date as string YYYY/MM/DD
"""
date=context.bobobase_modification_time()
return "%s/%s/%s" % (date.year(), date.month(), date.day())
% Anonymous User - Nov. 4, 2003 10:58 am:
We are learning about TAL!!!
% Anonymous User - Nov. 20, 2003 9:59 am:
The name of the Python script is file_date
The script was called by passing the value item/file_date to the tal:content attribute
(tal:content="item/file_date")
Because of the way the script was called, the builtin object context now references item which references a
file?
bobobase_modification_time() is another standards built in method?
date=context.bobobase_modification_time() calls this method on the file which is referenced by item which is
referenced by context?
The rest is just fancy formatting?
Am I on the right track?
% Anonymous User - Dec. 2, 2003 11:25 pm:
You are on the right track.
% Anonymous User - Jan. 8, 2004 8:46 pm:
Regarding "bobobase_modification_time() is another standards built in method?" and "The rest is just fancy
formatting?":
To say the first thing, it might not be correctly formulated, but I think you have the right idea.
bobobase_modification_time() is a method that can be called on any Zope object (since 'context' can take any
Zope object as its value). Further, it returns a Python object which is apparently an abstraction of a date.
I don't know the name of the python class that this object instantiates, but objects of this class provide at
least three methods (year(), month(), day()) which return string values. So yes, the fancy formatting part,
the return statement, expects three string variables, which are provided by those three methods of the date
object.
More information about the ZDP
mailing list