Re: [Zope] DTML-In with date/time filter

2006-05-04 Thread Chris Withers

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

___
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 )


[Zope] DTML-In with date/time filter

2006-05-03 Thread Martin Koekenberg

 
   
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 
[EMAIL PROTECTED]To: Martin Koekenberg 
[EMAIL PROTECTED]Cc: zope@zope.orgDate: Wed, 08 
Mar 2006 14:43:41 +0100Subject: 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 - alsoit makes it possible to replace the quite costy 
objectValues()call with ZCatalog query w/o changing your presentation 
code)RegardsTino

___
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 )


Re: [Zope] DTML-In with date/time filter

2006-05-03 Thread Andreas Jung



--On 3. Mai 2006 12:17:36 +0200 Martin Koekenberg 
[EMAIL PROTECTED] 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: [EMAIL PROTECTED] - Phone +49 - 7071 - 793376
E-Publishing, Python, Zope  Plone development, Consulting


pgpZMOmKPCgL4.pgp
Description: PGP signature
___
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 )


Re: [Zope] DTML-In with date/time filter

2006-05-03 Thread Martin Koekenberg

 
 
HelloAndreas, 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 
[EMAIL PROTECTED]To: Martin Koekenberg 
[EMAIL PROTECTED], zope@zope.orgDate: Wed, 03 May 
2006 12:20:33 +0200Subject: Re: [Zope] DTML-In with date/time filter
 --On 
3. Mai 2006 12:17:36 +0200 Martin Koekenberg 
[EMAIL PROTECTED] 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 DTMLis 
bad-style. Use Pythonscript for this code and call the script fromDTML 
(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: 
[EMAIL PROTECTED] - Phone +49 - 7071 - 793376E-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 )


Re: [Zope] DTML-In with date/time filter

2006-05-03 Thread Jonathan
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 [EMAIL PROTECTED]
To: Martin Koekenberg [EMAIL PROTECTED], 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
[EMAIL PROTECTED] 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: [EMAIL PROTECTED] - 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 ) 


___
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 )


Re: [Zope] DTML-In with date/time filter

2006-05-03 Thread Dieter Maurer
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
___
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 )