Photo Product fix/question/suggestion
Question: I have a class "FoobarInfo" that has an "image" property. This property holds the ID of an image to be rendered in FoobarInfo's index_html method. Therefore, in the index_html I was doing this: <img class="fooimage" alt="[Image for <dtml-var name>]" src=<dtml-var image> > And this works just spiffy. However, I want to use the Photo Product instead of the Image class. The code above works for Photo, too, but it does not take advantage of Photo's features. Now, normally you would insert the following into a document to render the image and use the feature I want (specifically, a user's preferred display size): <dtml-var "blah(REQUEST, pdcookie='1')"> Where "blah" is the ID of the Photo instance you want to insert. My problem is that I'm not sure how to say "blah should be the object referred to by my image property", and I'm also not sure how to set the class and alt text in this usage (putting them after pdcookie didn't work). I've tried all sorts of weird stuff with _, getitem, dtml-with, dtml-let, but to no avail. Alternately, figuring out how to use this "pdcookie" feature from a normal <img> tag would work too. (I also tried deriving my class from Image or Photo and adding my extra Info properties, but that was even harder to figure out. At least this way it sort-of works.) Fixing the default Image Formats: The __init__.py file that the Photo Product supplies for PIL only supports the GIF image type by default, which is weird behavior these days. I thought it was a bug at first. ;-) To enable other formats, open the __init__.py that you put in PIL's directory, and add the desired Image plugins onto the import list. Mine looks like so, now: import Image, ImageFile, ImageDraw, _imaging, GifImagePlugin, JpegImagePlugin, PngImagePlugin This seems to work fine. All of the plugins are in PIL's directory, so look there to figure out whether one is available for a given format. (I plan to remove GifImagePlugin, because frankly I never use GIF if I can avoid it). Suggestion: As far as the Photo Product itself is concerned, I think that the default size for thumbnails is way too huge. 128x128 seems more alike a preview size than a thumbnail (I would put the latter at more like 32x32 or 64x64). I know I can fix it (says so right in the docs), but I thought I might put in my 2 cents on that ;-) - Gregor vorlon#iglou.com http://anime.at/gregordyne http://www.skysys.org/~gregor Anime, Amber, 3d, Mage, Eidolon, Miscellany
I'll answer the last first, I have been developing a product called ZPhotoAlbum which subclasses a ZCatalog to provide full-text, indexed searches on your online photo database. I hope that the ZPhotoAlbum will support a property that will be used by ZPhoto (think of Photo plus properties like title, description, photographer, datestamp, etc.) to create the default display settings for EVERY ZPhoto in the ZPhotoAlbum. This should be available real-soon-now, as well as an example site for which I am building this beast. As such, folks that want RAW image processing capabilities, could use the Photo product. Folks that want an online photo album could use ZPhotoAlbum out of the box and browse away. Folks that want an online database for their photos which link into a new system would have a little bit of work, but that would be at the ZClass and DTML level. I'll take the rest of these one at a time.
My problem is that I'm not sure how to say "blah should be the object
referred
to by my image property", and I'm also not sure how to set the class and alt text in this usage (putting them after pdcookie didn't work). I've tried all sorts of weird stuff with _, getitem, dtml-with, dtml-let, but to no avail.
This should work: <dtml-var "blah(REQUEST, class='fooimage', alt='[Can't use dtml tags inside dtml tags]', pdcookie='1')"> You can say exaclty the same thing using a syntax similar to image. <dtml-var "blah.tag(REQUEST, class='fooimage', alt='[so use tricky python to get the job done.]', pdcookie='1')"> The order of the extra tags does not matter, but the single quotes matter alot. I wish I could think of the python expression to grab your <dtml-var name> and stuff it into your alt string, but I am suffering from sleep deprivation. Let me know right away if this doesn't work for you.
Alternately, figuring out how to use this "pdcookie" feature from a normal <img> tag would work too.
Actually, you don't need the pdcookie feature at all. The photo object ALWAYS checks for the presence of its cookie, if it finds it, it will render to the preferred size, unless overridden by dtml.
(I also tried deriving my class from Image or Photo and adding my extra Info properties, but that was even harder to figure out. At least this way it sort-of works.)
Yes. I imagine it would be. That seems to be the rub of object-oriented programming, trying to build software that mimics that objects that we experience in real life. I doubt I would figure it out either.
Fixing the default Image Formats: To enable other formats, open the __init__.py that you put in PIL's
directory,
and add the desired Image plugins onto the import list. Mine looks like so, now:
import Image, ImageFile, ImageDraw, _imaging, GifImagePlugin, JpegImagePlugin, PngImagePlugin
This seems correct to me. Thanks for your suggestion. I have had other input on this as well. I think that leaving the file blank will also have the desired result. Curiously, the blank __init__.py is installed in my Zope installations, but I have something different in the Photo product, so lets call it a bug. In the near future, I plan to package PIL seperately or package PIL INSIDE of Photo, to avoid the issues with PIL installation. Actually, I don't know which packaging scheme is better, package PIL with Photo or package PIL outside Photo. I know of several products tthat require this. Photo, Poll, Dataminer, and a couple that I can't remember the name of...
Suggestion: As far as the Photo Product itself is concerned, I think that the default size for thumbnails is way too huge. 128x128 seems more alike a preview size than a thumbnail (I would put the latter at more like 32x32 or 64x64). I know I can fix it (says so right in the docs), but I thought I might put in my 2 cents on that ;-)
Sure, but I need a 128x128 size. Actually, I have had many people request to set their default WITHOUT editing the source. This problem seems similiar to changing the default skeleton in the DTML methods and documents. In other words, it should be possible using the Zope debugger -- yet I don't even have a clue on how to get started with that. I look forward to your input. Drew
----- Original Message ----- From: "Andrew Lahser" <andrew@apl-software.com> To: "Gregor" <vorlon@iglou.com>; <zope@zope.org> Sent: Monday, January 10, 2000 9:00 PM Subject: Re: Photo Product fix/question/suggestion
I'll answer the last first, I have been developing a product called ZPhotoAlbum which subclasses a ZCatalog to provide full-text, indexed searches on your online photo database.
Well, it's not exactly an online photo database that I was making per se, but I guess once it's out I'll see whether it would suffice.
This should work: <dtml-var "blah(REQUEST, class='fooimage', alt='[Can't use dtml tags inside dtml tags]', pdcookie='1')">
Zope spits out the following: Expression (Python) Syntax error: invalid syntax , for tag <dtml-var "blah(REQUEST, class='fooimage', alt='[Can't use dtml tags inside dtml tags]', pdcookie='1')">, on line 6 of index_html It gives the same error if I use the other version.
Let me know right away if this doesn't work for you.
The *major* problem I am suffering is that I don't know what "blah" is in my method, so the above doesn't work. The ZClass FooImage has a property "image". Inside the image property for a given instance, I stick the ID of the proper photo object. My DTML is in the index_html method of FooImage. I don't know how to tell DTML to grab the object referred to by "image" (as opposed to the string CONTENTS of the "image" property, which is what it does right now, I assume). If I just plug in the Property name as in "image(REQUEST", then it gives a "call of non-function" error.
Alternately, figuring out how to use this "pdcookie" feature from a normal <img> tag would work too.
Actually, you don't need the pdcookie feature at all. The photo object ALWAYS checks for the presence of its cookie, if it finds it, it will render to the preferred size, unless overridden by dtml.
I wasn't very clear, and I realized it right after I sent the email. I want to display the little HTML menu for setting the pdcookie.
Yes. I imagine it would be. That seems to be the rub of object-oriented programming, trying to build software that mimics that objects that we experience in real life. I doubt I would figure it out either.
Well, I always understood OOP to be based on that principle. Inherit from an object to get the functionality of the object. Zope seems to make that rather difficult.
Actually, I don't know which packaging scheme is better, package PIL with Photo or package PIL outside Photo. I know of several products tthat require this. Photo, Poll, Dataminer, and a couple that I can't remember the name of...
Put up a version with and a version without PIL, and let users decide which they need. Or put up a version of PIL that automatically decompresses to the right location, but is still a separate file.
Sure, but I need a 128x128 size.
Yup. I changed the preview size to 128x128, and shrunk thumbnail to 32x32 (though that may be TOO small. Maybe 48x48 would be better).
Actually, I have had many people request to set their default WITHOUT editing the source.
I was gonna suggest that too, but I figured my post was long enough, and I thought you were already aware of it. ;-)
Is there a list dedacater to us newbe's and our silly questions?
On Mon, Jan 10, 2000 at 08:34:31PM -0500, Gregor wrote:
Question: I have a class "FoobarInfo" that has an "image" property. This property holds the ID of an image to be rendered in FoobarInfo's index_html method.
Therefore, in the index_html I was doing this:
<img class="fooimage" alt="[Image for <dtml-var name>]" src=<dtml-var image> >
And this works just spiffy. However, I want to use the Photo Product instead of the Image class. The code above works for Photo, too, but it does not take advantage of Photo's features. Now, normally you would insert the following into a document to render the image and use the feature I want (specifically, a user's preferred display size):
<dtml-var "blah(REQUEST, pdcookie='1')"> <dtml-var "_.getitem(blah, 0).__call__(REQUEST, pdcookie='1')">
_.getitem(x, 0) returns a reference to an item without calling it. _[x] gets a reference to an item and then calls it, returning a string when you want a Photo instance. -- Stephen Pitts smpitts@midsouth.rr.com webmaster - http://www.mschess.org
participants (4)
-
Andrew Lahser -
Gregor -
Mica Fine -
Stephen Pitts