Re: [Zope] "Picture of the day" product
Timothy Wilson <wilson@visi.com> 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.:: <dtml-in "Catalog( meta_type='Image' , effective=( ZopeTime().earliestTime(), ZopeTime().latestTime() ) , effective_usage='range:min:max' # other query parms here, including any sorting... )"> <dtml-if sequence-start> <dtml-var "Catalog.getobject( data_record_id_ )"> </dtml-if> </dtml-in> 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 tseaver@digicool.com Digital Creations "Zope Dealers" http://www.zope.org
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.::
<dtml-in "Catalog( meta_type='Image' -- 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? -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/ wilson@visi.com | <dtml-var pithy_quote> | http://linux.com/
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.::
<dtml-in "Catalog( meta_type='Image' -- 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 tseaver@digicool.com Digital Creations "Zope Dealers" http://www.zope.org
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/ wilson@visi.com | <dtml-var pithy_quote> | http://linux.com/
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.::
<dtml-in "Catalog( meta_type='Image' -- 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/ wilson@visi.com | <dtml-var pithy_quote> | http://linux.com/
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.::
<dtml-in "Catalog( meta_type='Image' , effective=( ZopeTime().earliestTime(), ZopeTime().latestTime() ) , effective_usage='range:min:max' # other query parms here, including any sorting... )"> <dtml-if sequence-start> <dtml-var "Catalog.getobject( data_record_id_ )"> </dtml-if> </dtml-in>
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. -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/ wilson@visi.com | <dtml-var pithy_quote> | http://linux.com/
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.::
<dtml-in "Catalog( meta_type='Image' , effective=( ZopeTime().earliestTime(), ZopeTime().latestTime() ) , effective_usage='range:min:max' # other query parms here, including any sorting... )"> <dtml-if sequence-start> <dtml-var "Catalog.getobject( data_record_id_ )"> </dtml-if> </dtml-in>
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:: <dtml-in expr="theCatalog( meta_type='Photo' , display_date=ZopeTime() , display_date_usage='range:max' , sort_on='display_date' , sort_order='reverse' )"> 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 tseaver@digicool.com Digital Creations "Zope Dealers" http://www.zope.org
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::
<dtml-in expr="theCatalog( meta_type='Photo' , display_date=ZopeTime() , display_date_usage='range:max' , sort_on='display_date' , sort_order='reverse' )">
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/ wilson@visi.com | <dtml-var pithy_quote> | http://linux.com/
On Mon, 29 Jan 2001, 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::
<dtml-in expr="theCatalog( meta_type='Photo' , display_date=ZopeTime() , display_date_usage='range:max' , sort_on='display_date' , sort_order='reverse' )">
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.
Oops! ZopeTime is acquired from the application object; in a PythonScript, it should be called via the 'context' binding: context.ZopeTime()
Thanks again. I should have those pictures up in no time.
Great! Tres. -- =============================================================== Tres Seaver tseaver@digicool.com Digital Creations "Zope Dealers" http://www.zope.org
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::
<dtml-in expr="theCatalog( meta_type='Photo' , display_date=ZopeTime() , display_date_usage='range:max' , sort_on='display_date' , sort_order='reverse' )">
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
participants (3)
-
Jim Washington -
Timothy Wilson -
Tres Seaver