[Zope] ZPT getFiles() from Python

Roger Ineichen r.ineichen@projekt01.ch
Fri, 26 Apr 2002 05:11:06 +0200


Hello
I have a problem with to port a PythonScript to Python. How can I use
this in a Python Method the Python 
The ZPT looks like:
_________________

<div tal:define="sort request/sort|string:id;
                     reverse request/reverse|python:0;
                     files python:here.getFiles(sort, reverse);
                     start request/start|python:0;
                     batch python:modules['ZTUtils'].Batch(files,
size=8, start=start);
                     previous python:batch.previous;
                     next python:batch.next">
_________________


Python Script looks like: getFiles(self, sort='id', reverse=0)
_________________
"""
Returns a list of files sorted by id, date, type or size.
"""
files=container.objectValues('File')

# build arguments for sequence.sort
if sort=='id':
    if not reverse:
        args=(('getId',),)
    else:
        args=(('getId', 'cmp', 'desc'),)
elif sort=='date':
    if not reverse:
        args=(('bobobase_modification_time',), ('getId',))
    else:
        args=(('bobobase_modification_time', 'cmp', 'desc'), ('getId',))
elif sort=='type':
    if not reverse:
        args=(('getContentType',), ('getId',))
    else:
        args=(('getContentType', 'cmp', 'desc'), ('getId',)) 
elif sort=='size':
    if not reverse:
        args=(('getSize', 'cmp', 'desc'), ('getId',))
    else:
        args=(('getSize',), ('getId',)) 


return sequence.sort(files, args)
_________________

How can I use the ZPT with a Python Method like: "def getFiles(self,
sort='id', reverse=0)"
How can I use sequence (with ZTUtils?)

Thanks

Roger Ineichen
___________________________

Projekt01 GmbH
www.projekt01.ch
Langackerstrasse 8
6330 Cham
phone  +41 (0)41 781 01 78
mobile +41 (0)79 340 52 32
fax    +41 (0)41 781 00 78
email  r.ineichen@projekt01.ch
___________________________
END OF MESSAGE