Hello, Is it possible to use a DTML-In to display all DTML Documents in a folder exept the one's with a centain value in a property ? Example. DTML Document one with property a=bc DTML Document two with property a=de DTML Document three with property a=bc Now I want to use DTML-IN to display all the dtml documents except the ones with property a=de. I also use the size and batchsize property to create links to the next 10 documents..... If I use an if statement the next 10 can be 9 ore less 9 items because there could be one ore more documents with a=de. Who can help me ? regards, Martin Koekenberg
Martin Koekenberg schrieb:
Hello,
Is it possible to use a DTML-In to display all DTML Documents in a folder exept the one's with a centain value in a property ?
Example.
DTML Document one with property a=bc DTML Document two with property a=de DTML Document three with property a=bc
Now I want to use DTML-IN to display all the dtml documents except the ones with property a=de. I also use the size and batchsize property to create links to the next 10 documents..... If I use an if statement the next 10 can be 9 ore less 9 items because there could be one ore more documents with a=de.
Just drop this DTML... or at least get help from python: return [doc for doc in context.objectValues('DTML Document') if doc.getProperty('a')!='de'] (python script or the like would be your friend - also it makes it possible to replace the quite costy objectValues() call with ZCatalog query w/o changing your presentation code) Regards Tino
Hallo, I can create a dtml-in filte with the following code: return [doc for doc in context.objectValues('DTML Document') if doc.getProperty('a')!='de'] How can I do the same with a date or time ? Regards, Martin Koekenberg -----Original Message----- From: Tino Wildenhain <tino@wildenhain.de> To: Martin Koekenberg <martin@digital-adventures.nl> Cc: zope@zope.org Date: Wed, 08 Mar 2006 14:43:41 +0100 Subject: Re: [Zope] DTML-In with filter Martin Koekenberg schrieb:
Hello,
Is it possible to use a DTML-In to display all DTML Documents in a folder exept the one's with a centain value in a property ?
Example.
DTML Document one with property a=bc DTML Document two with property a=de DTML Document three with property a=bc
Now I want to use DTML-IN to display all the dtml documents except the ones with property a=de. I also use the size and batchsize property to create links to the next 10 documents..... If I use an if statement the next 10 can be 9 ore less 9 items because there could be one ore more documents with a=de.
Just drop this DTML... or at least get help from python: return [doc for doc in context.objectValues('DTML Document') if doc.getProperty('a')!='de'] (python script or the like would be your friend - also it makes it possible to replace the quite costy objectValues() call with ZCatalog query w/o changing your presentation code) Regards Tino
--On 3. Mai 2006 12:17:36 +0200 Martin Koekenberg <martin@digital-adventures.nl> wrote:
Hallo, I can create a dtml-in filte with the following code:
return [doc for doc in context.objectValues('DTML Document') if doc.getProperty('a')!='de']
Using "return" in DTML does not make sense. Writing such code in DTML is bad-style. Use Pythonscript for this code and call the script from DTML (btw. better user ZPT).
How can I do the same with a date or time ?
What does that mean? -aj -- ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany Web: www.zopyx.com - Email: info@zopyx.com - Phone +49 - 7071 - 793376 E-Publishing, Python, Zope & Plone development, Consulting
Hello Andreas, I use this code in a Python script and call this script within a DTML-IN statement. What I need is a script to get only items with a date in the future, today or in the past. The objects are DTML Documents with a date property field. Regards Martin Koekenberg -----Original Message----- From: Andreas Jung <lists@zopyx.com> To: Martin Koekenberg <martin@digital-adventures.nl>, zope@zope.org Date: Wed, 03 May 2006 12:20:33 +0200 Subject: Re: [Zope] DTML-In with date/time filter --On 3. Mai 2006 12:17:36 +0200 Martin Koekenberg <martin@digital-adventures.nl> wrote:
Hallo, I can create a dtml-in filte with the following code:
return [doc for doc in context.objectValues('DTML Document') if doc.getProperty('a')!='de']
Using "return" in DTML does not make sense. Writing such code in DTML is bad-style. Use Pythonscript for this code and call the script from DTML (btw. better user ZPT).
How can I do the same with a date or time ?
What does that mean? -aj -- ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany Web: www.zopyx.com - Email: info@zopyx.com - Phone +49 - 7071 - 793376 E-Publishing, Python, Zope & Plone development, Consulting
You are going to have to loop thru the documents and use 'getProperty' to access the date property field on the document. Then you will need to compare the date value (the Zope Book V2.6 has a good description of dates/time usage) to see if it is in the range you need. You could use a python script to do this loop/compare and return a list of document ids which you could then display via your DTML-in stmt. If you have a lot of documents this could be a very expensive approach. You might want to have a look at ZCatalog. hth Jonathan ----- Original Message ----- From: Martin Koekenberg To: zope@zope.org Sent: Wednesday, May 03, 2006 8:47 AM Subject: Re: [Zope] DTML-In with date/time filter Hello Andreas, I use this code in a Python script and call this script within a DTML-IN statement. What I need is a script to get only items with a date in the future, today or in the past. The objects are DTML Documents with a date property field. Regards Martin Koekenberg -----Original Message----- From: Andreas Jung <lists@zopyx.com> To: Martin Koekenberg <martin@digital-adventures.nl>, zope@zope.org Date: Wed, 03 May 2006 12:20:33 +0200 Subject: Re: [Zope] DTML-In with date/time filter --On 3. Mai 2006 12:17:36 +0200 Martin Koekenberg <martin@digital-adventures.nl> wrote:
Hallo, I can create a dtml-in filte with the following code:
return [doc for doc in context.objectValues('DTML Document') if doc.getProperty('a')!='de']
Using "return" in DTML does not make sense. Writing such code in DTML is bad-style. Use Pythonscript for this code and call the script from DTML (btw. better user ZPT).
How can I do the same with a date or time ?
What does that mean? -aj -- ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany Web: www.zopyx.com - Email: info@zopyx.com - Phone +49 - 7071 - 793376 E-Publishing, Python, Zope & Plone development, Consulting _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Martin Koekenberg wrote at 2006-5-3 14:47 +0200:
I use this code in a Python script and call this script within a DTML-IN statement. What I need is a script to get only items with a date in the future, today or in the past. The objects are DTML Documents with a date property field.
Assuming, your property contains a date, you can uses something like (to get things with dates in the future): now = container.ZopeTime() # see the "DateTime" documentation for other times return [obj for obj in context.objectValues() if obj.getProperty(...) > now ] -- Dieter
Dieter Maurer wrote:
Martin Koekenberg wrote at 2006-5-3 14:47 +0200:
I use this code in a Python script and call this script within a DTML-IN statement. What I need is a script to get only items with a date in the future, today or in the past. The objects are DTML Documents with a date property field.
Assuming, your property contains a date, you can uses something like (to get things with dates in the future):
now = container.ZopeTime() # see the "DateTime" documentation for other times return [obj for obj in context.objectValues() if obj.getProperty(...) > now
I'm fairly sure he'll want to change that if statement to: if not obj.getProperty(...).latestTime().isPast() cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
+-------[ Martin Koekenberg ]---------------------- | Hello, | | Is it possible to use a DTML-In to display all DTML Documents in a folder exept | the one's with a centain value in a property ? | | Example. | | DTML Document one with property a=bc | DTML Document two with property a=de | DTML Document three with property a=bc | | Now I want to use DTML-IN to display all the dtml documents except the ones | with property a=de. | I also use the size and batchsize property to create links to the next 10 | documents..... If I use an if statement the next 10 can be 9 ore less 9 items | because there could be one ore more documents with a=de. | | Who can help me ? Pseudo-code (dtml-like) <dtml-in "someListOfThings"> <dtml-with thecurrentitem> <dtml-unless "a=='de'"> <dtml-var thecurrentitem> </dtml-unless> </dtml-with> </dtml-in> Or you could write a python script that filtered out the ones you wanted and call the python script to return the list of things to display, which is probably a much better idea. -- Andrew Milton akm@theinternet.com.au
participants (7)
-
Andreas Jung -
Andrew Milton -
Chris Withers -
Dieter Maurer -
Jonathan -
Martin Koekenberg -
Tino Wildenhain