Re: [Zope] "Picture of the day" product
Hi, Tim context.ZopeTime() or container.ZopeTime() ZopeTime is not in the PythonScript's namespace. It is available in most (all?) containers, however. -- Jim Washington Timothy Wilson wrote: > > On Mon, 29 Jan 2001, Tres Seaver wrote: > > > > I'd like to grab all instances with a display_date <= today's > > > date. I can't figure out exactly how to do that in DTML or a > > > Python Script. Once I have that list of instances, I'll simply > > > pull off the latest one as you suggested. > > > I don't know where it would be in the book it would be, but > > I do this something like:: > > > > > > > > The expression would be basically the same in a PythonScript:: > > > > return context.theCatalog( meta_type='Photo' > >, display_date=ZopeTime() > >, display_date_usage='range:max' > >, sort_on='display_date' > >, sort_order='reverse' > >) > > Great! The first DTML example works perfectly. The second, however, throws > up an error. In fact, I have yet to figure out how to use ZopeTime() in a > PythonScript. Do I have to pass anything in? > > I get: > > Error Type: NameError > Error Value: ZopeTime > > when I try it. > > -Tim ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] "Picture of the day" product
On Mon, 29 Jan 2001, Tres Seaver wrote: > > I'd like to grab all instances with a display_date <= today's > > date. I can't figure out exactly how to do that in DTML or a > > Python Script. Once I have that list of instances, I'll simply > > pull off the latest one as you suggested. > I don't know where it would be in the book it would be, but > I do this something like:: > > > > The expression would be basically the same in a PythonScript:: > > return context.theCatalog( meta_type='Photo' >, display_date=ZopeTime() >, display_date_usage='range:max' >, sort_on='display_date' >, sort_order='reverse' >) Great! The first DTML example works perfectly. The second, however, throws up an error. In fact, I have yet to figure out how to use ZopeTime() in a PythonScript. Do I have to pass anything in? I get: Error Type: NameError Error Value: ZopeTime when I try it. -Tim > Hope that helps! Thanks again. I should have those pictures up in no time. -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/ W. St. Paul, MN | | http://slashdot.org/ [EMAIL PROTECTED] || http://linux.com/ ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] "Picture of the day" product
On Mon, 29 Jan 2001, Timothy Wilson wrote: > On Wed, 17 Jan 2001, Tres Seaver wrote: > > > > What I'm not sure about is how to have Zope automatically > > > display the photo for a day, then archive it. Would a > > > boolean property of the ZClass work? Is it possible to have > > > Zope set the property of a ZClass instance at certain time? > > > Any thoughts on how this would be designed? > > > > This kind of thing is a "query-on-metadata" application; I > > would put all these images into a single folder (maybe > > chunked into subfolders by month?), mark them each with an > > 'effective' property (of type 'Date'), and then select the > > appropriate image via a catalog query, e.g.:: > > > >>, effective=( ZopeTime().earliestTime(), > > ZopeTime().latestTime() ) > >, effective_usage='range:min:max' > ># other query parms here, including any sorting... > >)"> > > > > > > > > > > > > Or you could just have the catalog fetch the images sorted by > > effective/descending, and then pick off the first one; this > > would keep an image around until supplanted by a newer one. > > Tres, I like this second solution. Each 'Photo' instance has a > display_date property (of type 'date') that should determine > when it's displayed (strangely enough :-) > > I'd like to grab all instances with a display_date <= today's > date. I can't figure out exactly how to do that in DTML or a > Python Script. Once I have that list of instances, I'll simply > pull off the latest one as you suggested. > > Would someone be willing to give an example of how to do this > in DTML and a PythonScript? I think it would be an interesting > comparison. BTW, there's nothing quite like this in the Zope > Book. Nearly all of the examples there are using form input. > Perhaps this type of Catalog searching could be expounded on > there. I don't know where it would be in the book it would be, but I do this something like:: The expression would be basically the same in a PythonScript:: return context.theCatalog( meta_type='Photo' , display_date=ZopeTime() , display_date_usage='range:max' , sort_on='display_date' , sort_order='reverse' ) Hope that helps! Tres. -- === Tres Seaver[EMAIL PROTECTED] Digital Creations "Zope Dealers" http://www.zope.org ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] "Picture of the day" product
On Thu, 18 Jan 2001, Tres Seaver wrote: > > > This kind of thing is a "query-on-metadata" application; I > > > would put all these images into a single folder (maybe > > > chunked into subfolders by month?), mark them each with an > > > 'effective' property (of type 'Date'), and then select the > > > appropriate image via a catalog query, e.g.:: > > > > > >> -- rest of example snipped -- Another followup: How 'bout using PIL to generate the thumbnail version that displays on the homepage as link to the fullsize picture and the archives? Would this be a logical place to begin experimenting with 2.3.0's new caching mechanism? Comments? -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/ W. St. Paul, MN | | http://slashdot.org/ [EMAIL PROTECTED] || http://linux.com/ ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] "Picture of the day" product
On Thu, 18 Jan 2001, Tres Seaver wrote: > Subclassing Image might be useful, but you could certainly > get by without if, if all you need is to add a property or > two: Images have a propertysheet to which you could add them. But if I use the standard Image meta type, wouldn't I have to create a 'display_date' property by hand each time I upload an image? I suppose it would be possible to create an HTML form that would add that property for me. I'm not sure I want to catalog every image on my site so another for creating a separate product would be that I could make it catalog-aware on its own. Comments? -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/ W. St. Paul, MN | | http://slashdot.org/ [EMAIL PROTECTED] || http://linux.com/ ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] "Picture of the day" product
On Wed, 17 Jan 2001, Timothy Wilson wrote: > On Wed, 17 Jan 2001, Tres Seaver wrote: > > > > What I'm not sure about is how to have Zope automatically > > > display the photo for a day, then archive it. Would a > > > boolean property of the ZClass work? Is it possible to have > > > Zope set the property of a ZClass instance at certain time? > > > Any thoughts on how this would be designed? > > > > This kind of thing is a "query-on-metadata" application; I > > would put all these images into a single folder (maybe > > chunked into subfolders by month?), mark them each with an > > 'effective' property (of type 'Date'), and then select the > > appropriate image via a catalog query, e.g.:: > > > >-- rest of example snipped -- > > Are you suggesting I use the standard Image class? What about > subclassing Image so I can add a display_date property and > whatever else I might need? Subclassing Image might be useful, but you could certainly get by without if, if all you need is to add a property or two: Images have a propertysheet to which you could add them. I suppose it is a matter of taste; I tend to avoid subclassing unless the object's behavior changes significantly. Tres. -- === Tres Seaver[EMAIL PROTECTED] Digital Creations "Zope Dealers" http://www.zope.org ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] "Picture of the day" product
On Wed, 17 Jan 2001, Tres Seaver wrote: > > What I'm not sure about is how to have Zope automatically display the photo > > for a day, then archive it. Would a boolean property of the ZClass work? Is > > it possible to have Zope set the property of a ZClass instance at certain > > time? Any thoughts on how this would be designed? > > This kind of thing is a "query-on-metadata" application; I would > put all these images into a single folder (maybe chunked into > subfolders by month?), mark them each with an 'effective' property > (of type 'Date'), and then select the appropriate image via a > catalog query, e.g.:: > > http://www.isd197.k12.mn.us/ | http://www.zope.org/ W. St. Paul, MN | | http://slashdot.org/ [EMAIL PROTECTED] || http://linux.com/ ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] "Picture of the day" product
Timothy Wilson <[EMAIL PROTECTED]> wrote: > > Hey everyone, > > I was looking at linux.com the today and I noticed their "Daily Photo." I > occurred to me that that would be a fun addition to the school's page that > I'm developing. My first thought would be to: > > * inherit from Image > * add caption, date taken, etc. properties > * create an archive of past photos > > What I'm not sure about is how to have Zope automatically display the photo > for a day, then archive it. Would a boolean property of the ZClass work? Is > it possible to have Zope set the property of a ZClass instance at certain > time? Any thoughts on how this would be designed? This kind of thing is a "query-on-metadata" application; I would put all these images into a single folder (maybe chunked into subfolders by month?), mark them each with an 'effective' property (of type 'Date'), and then select the appropriate image via a catalog query, e.g.:: Or you could just have the catalog fetch the images sorted by effective/descending, and then pick off the first one; this would keep an image around until supplanted by a newer one. Tres. -- === Tres Seaver[EMAIL PROTECTED] Digital Creations "Zope Dealers" http://www.zope.org ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] "Picture of the day" product
// What I'm not sure about is how to have Zope automatically // display the photo // for a day, then archive it. Would a boolean property of the // ZClass work? Is // it possible to have Zope set the property of a ZClass instance // at certain // time? Any thoughts on how this would be designed? Hi Tim, Here's some code I use with a simple NewsItem ZClass that only displays objects that have not yet "Expired". With a little modification, it could be used to test a "DisplayDate" value and if it matches the current date, the photo would be displayed. That way you could load a bunch of photos into your site at once and give them specific display dates. If more than one had the same date, they would both be shown. "Expires" is a property of my NewsItem ZClass that is of type "date". "Expires+1" just adds a day to the expiration date so that my news items are displayed up to, and including, their expiration date. The NewsItem ZClass has a meta type of "News Item," which is used in the "in" statement. "view" is a method of the ZClass that simply formats the NewsItem for displaying in the browser. Hope it helps... Eric. ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] "Picture of the day" product
On Wed, Jan 17, 2001 at 12:20:06PM -0600, Timothy Wilson wrote: > Hey everyone, > > I was looking at linux.com the today and I noticed their "Daily Photo." I > occurred to me that that would be a fun addition to the school's page that > I'm developing. My first thought would be to: > > * inherit from Image > * add caption, date taken, etc. properties > * create an archive of past photos > > What I'm not sure about is how to have Zope automatically display the photo > for a day, then archive it. Would a boolean property of the ZClass work? Is > it possible to have Zope set the property of a ZClass instance at certain > time? Any thoughts on how this would be designed? I'd pre-create the archive in advance. Use dates as Ids, and have the archive page only list past photos. The homepage would show the photo for today. Simple and sweet. Or you could use a Python Script/Python Method/External Method/DTML Method (whatever you prefer) called currentPhoto or something that does the calculation for you and return the correct object to the caller. -- Martijn Pieters | Software Engineer mailto:[EMAIL PROTECTED] | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ - ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] "Picture of the day" product
Hey everyone, I was looking at linux.com the today and I noticed their "Daily Photo." I occurred to me that that would be a fun addition to the school's page that I'm developing. My first thought would be to: * inherit from Image * add caption, date taken, etc. properties * create an archive of past photos What I'm not sure about is how to have Zope automatically display the photo for a day, then archive it. Would a boolean property of the ZClass work? Is it possible to have Zope set the property of a ZClass instance at certain time? Any thoughts on how this would be designed? -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/ W. St. Paul, MN | | http://slashdot.org/ [EMAIL PROTECTED] || http://linux.com/ ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )