Re: [Zope] Accessing .gif on disk with Python Product?
From: Martijn Pieters [EMAIL PROTECTED] I still think something else was broken, SiteAccess should (and does, as far as I know) stay away from SCRIPT_NAME. Yep. Environment/CGI variables are left alone by the virtual hosting machinery; only Zope-specific ones are altered. An example of a virtual hosting setup which won't work with SCRIPT_NAME: Apache on machine www.foo.com proxies requests for /Zope/* to machine z.foo.com:8080. In this case SCRIPT_NAME is blank, and the src of an image on http://www.foo.com/Zope/page constructed with it would resolve to http://www.foo.com/image.gif, rather than http://www.foo.com/Zope/image.gif. This is not a contrived example -- people are doing this. SCRIPT_NAME will work in simple cases, but BASE1 ought to work in all cases, and using it is a better habit to have in general. Cheers, Evan @ digicool 4-am ___ 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] Accessing .gif on disk with Python Product?
On Tue, Aug 08, 2000 at 12:45:02PM -0400, Evan Simpson wrote: From: Martijn Pieters [EMAIL PROTECTED] I still think something else was broken, SiteAccess should (and does, as far as I know) stay away from SCRIPT_NAME. Yep. Environment/CGI variables are left alone by the virtual hosting machinery; only Zope-specific ones are altered. An example of a virtual hosting setup which won't work with SCRIPT_NAME: Apache on machine www.foo.com proxies requests for /Zope/* to machine z.foo.com:8080. In this case SCRIPT_NAME is blank, and the src of an image on http://www.foo.com/Zope/page constructed with it would resolve to http://www.foo.com/image.gif, rather than http://www.foo.com/Zope/image.gif. This is not a contrived example -- people are doing this. SCRIPT_NAME will work in simple cases, but BASE1 ought to work in all cases, and using it is a better habit to have in general. We better file a Collector item on this then, as the current Zope Management Interface uses it still. -- Martijn Pieters | Software Engineermailto:[EMAIL PROTECTED] | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ | ZopeStudio: http://www.zope.org/Products/ZopeStudio - ___ 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] Accessing .gif on disk with Python Product?
From: Martijn Pieters [EMAIL PROTECTED] SCRIPT_NAME will work in simple cases, but BASE1 ought to work in all cases, and using it is a better habit to have in general. We better file a Collector item on this then, as the current Zope Management Interface uses it still. Done. I also tacked on a proposal to add BASE_PATHn and URL_PATHn variables to ease the transition. Cheers, Evan @ digicool 4-am ___ 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] Accessing .gif on disk with Python Product?
On Mon, Aug 07, 2000 at 11:21:53AM -0300, Performance.net Strategic Internet Solutions wrote: I am writing a python product and want to display a GIF file in some of the manage_pages. It is not meant to be the "icon" property of the class, just an image to be included in DTML. I included it in my class as follows: chooser = ImageFile('images/chooser.gif',globals()), but when I call it in DTML (dtml-var chooser) I get the following: ImageFile instance at 014F1D90 I thought maybe I could use an instance of the Image class: chooser = OFS.Image('images/chooser.gif',globals()), but this doesn't seem to work. How do you create an instance of an Image in a Python Product? ImageFile objects do not (like ZODB stored Image objects) generate an IMG tag when called. Image object, when called, generate an IMG tag that points the browser to the correct address to retrieve tha actual image. With an ImageFile object, you need to construct the tag yourself. If this class has an instance foo, with this ImageFile attribute chooser, and the instance foo is stored in the root of your Zope ZODB, you need to point the browser to http://yoursever/foo/chooser. So your DTML needs to generate the following HTML: img src="http://yoursever/foo/chooser" I don't know enough about your DTML, but if it is another attribute of the same class, you could use one of the URLx REQUEST variables or something to construct the URL for the image. Also, absolute_url() called on the foo instance may also work for a base URL. Hope this helps. -- Martijn Pieters | Software Engineermailto:[EMAIL PROTECTED] | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ | ZopeStudio: http://www.zope.org/Products/ZopeStudio - ___ 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] Accessing .gif on disk with Python Product?
- Original Message - From: "Martijn Pieters" [EMAIL PROTECTED] To: "Performance.net Strategic Internet Solutions" [EMAIL PROTECTED] Cc: "ZOPE Mailing List" [EMAIL PROTECTED] Sent: Monday, August 07, 2000 12:19 PM Subject: Re: [Zope] Accessing .gif on disk with Python Product? On Mon, Aug 07, 2000 at 11:21:53AM -0300, Performance.net Strategic Internet Solutions wrote: I am writing a python product and want to display a GIF file in some of the manage_pages. It is not meant to be the "icon" property of the class, just an image to be included in DTML. I included it in my class as follows: chooser = ImageFile('images/chooser.gif',globals()), but when I call it in DTML (dtml-var chooser) I get the following: ImageFile instance at 014F1D90 I thought maybe I could use an instance of the Image class: chooser = OFS.Image('images/chooser.gif',globals()), but this doesn't seem to work. How do you create an instance of an Image in a Python Product? ImageFile objects do not (like ZODB stored Image objects) generate an IMG tag when called. Image object, when called, generate an IMG tag that points the browser to the correct address to retrieve tha actual image. With an ImageFile object, you need to construct the tag yourself. If this class has an instance foo, with this ImageFile attribute chooser, and the instance foo is stored in the root of your Zope ZODB, you need to point the browser to http://yoursever/foo/chooser. So your DTML needs to generate the following HTML: img src="http://yoursever/foo/chooser" I don't know enough about your DTML, but if it is another attribute of the same class, you could use one of the URLx REQUEST variables or something to construct the URL for the image. Also, absolute_url() called on the foo instance may also work for a base URL. Hope this helps. -- Martijn Pieters | Software Engineermailto:[EMAIL PROTECTED] | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ | ZopeStudio: http://www.zope.org/Products/ZopeStudio - Okay, I've done the following: # Create the method in the .py Class File chooserIcon=ImageFile('images/chooserIcon.gif',globals()), # Call from the .dtml File img src="dtml-var absolute_url/chooserIcon" border=0 absolute_url() works and the URL points correctly to http://myserver/foo/chooserIcon, but if I type in that URL directly, I get a "Not Found" error as though the method does not exist. I've double-checked that the image is there and named correctly, so it's not a syntax thing. Perhaps I need to convert it to an "Image" object something like below? # this doesn't work but illustrates the idea chooserIcon = Image( ImageFile('images/chooserIcon.gif',globals() ) Help! =:) Kevin ___ 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] Accessing .gif on disk with Python Product?
On Mon, Aug 07, 2000 at 01:12:03PM -0300, Performance.net Strategic Internet Solutions wrote: On Mon, Aug 07, 2000 at 11:21:53AM -0300, Performance.net Strategic Internet Solutions wrote: I am writing a python product and want to display a GIF file in some of the manage_pages. It is not meant to be the "icon" property of the class, just an image to be included in DTML. I included it in my class as follows: chooser = ImageFile('images/chooser.gif',globals()), but when I call it in DTML (dtml-var chooser) I get the following: ImageFile instance at 014F1D90 I thought maybe I could use an instance of the Image class: chooser = OFS.Image('images/chooser.gif',globals()), but this doesn't seem to work. How do you create an instance of an Image in a Python Product? ImageFile objects do not (like ZODB stored Image objects) generate an IMG tag when called. Image object, when called, generate an IMG tag that points the browser to the correct address to retrieve tha actual image. With an ImageFile object, you need to construct the tag yourself. If this class has an instance foo, with this ImageFile attribute chooser, and the instance foo is stored in the root of your Zope ZODB, you need to point the browser to http://yoursever/foo/chooser. So your DTML needs to generate the following HTML: img src="http://yoursever/foo/chooser" I don't know enough about your DTML, but if it is another attribute of the same class, you could use one of the URLx REQUEST variables or something to construct the URL for the image. Also, absolute_url() called on the foo instance may also work for a base URL. Hope this helps. Okay, I've done the following: # Create the method in the .py Class File chooserIcon=ImageFile('images/chooserIcon.gif',globals()), # Call from the .dtml File img src="dtml-var absolute_url/chooserIcon" border=0 absolute_url() works and the URL points correctly to http://myserver/foo/chooserIcon, but if I type in that URL directly, I get a "Not Found" error as though the method does not exist. I've double-checked that the image is there and named correctly, so it's not a syntax thing. Perhaps I need to convert it to an "Image" object something like below? # this doesn't work but illustrates the idea chooserIcon = Image( ImageFile('images/chooserIcon.gif',globals() ) Help! =:) Hmm.. This is how Product Icons are stored, that is, as ImageFile objects. At product init time, a ImageFile objetcs is created for the Product icon and stroed in the special misc_ structure for later access. Have a look through the Product initialisation code, which is started up in OFS/Application.py::install_products(). -- Martijn Pieters | Software Engineermailto:[EMAIL PROTECTED] | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ | ZopeStudio: http://www.zope.org/Products/ZopeStudio - ___ 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] Accessing .gif on disk with Python Product?
Right you are, here's how I solved it: # __init.py__ for myProduct misc_={ 'chooserIcon': ImageFile('images/chooserIcon.gif',globals()), } # DTML file img src="dtml-var absolute_url/misc_/myProduct/chooserIcon" border=0 Thanks! Kevin - Original Message - From: "Martijn Pieters" [EMAIL PROTECTED] To: "Performance.net Strategic Internet Solutions" [EMAIL PROTECTED] Cc: "ZOPE Mailing List" [EMAIL PROTECTED] Sent: Monday, August 07, 2000 1:15 PM Subject: Re: [Zope] Accessing .gif on disk with Python Product? On Mon, Aug 07, 2000 at 01:12:03PM -0300, Performance.net Strategic Internet Solutions wrote: On Mon, Aug 07, 2000 at 11:21:53AM -0300, Performance.net Strategic Internet Solutions wrote: I am writing a python product and want to display a GIF file in some of the manage_pages. It is not meant to be the "icon" property of the class, just an image to be included in DTML. I included it in my class as follows: chooser = ImageFile('images/chooser.gif',globals()), but when I call it in DTML (dtml-var chooser) I get the following: ImageFile instance at 014F1D90 I thought maybe I could use an instance of the Image class: chooser = OFS.Image('images/chooser.gif',globals()), but this doesn't seem to work. How do you create an instance of an Image in a Python Product? ImageFile objects do not (like ZODB stored Image objects) generate an IMG tag when called. Image object, when called, generate an IMG tag that points the browser to the correct address to retrieve tha actual image. With an ImageFile object, you need to construct the tag yourself. If this class has an instance foo, with this ImageFile attribute chooser, and the instance foo is stored in the root of your Zope ZODB, you need to point the browser to http://yoursever/foo/chooser. So your DTML needs to generate the following HTML: img src="http://yoursever/foo/chooser" I don't know enough about your DTML, but if it is another attribute of the same class, you could use one of the URLx REQUEST variables or something to construct the URL for the image. Also, absolute_url() called on the foo instance may also work for a base URL. Hope this helps. Okay, I've done the following: # Create the method in the .py Class File chooserIcon=ImageFile('images/chooserIcon.gif',globals()), # Call from the .dtml File img src="dtml-var absolute_url/chooserIcon" border=0 absolute_url() works and the URL points correctly to http://myserver/foo/chooserIcon, but if I type in that URL directly, I get a "Not Found" error as though the method does not exist. I've double-checked that the image is there and named correctly, so it's not a syntax thing. Perhaps I need to convert it to an "Image" object something like below? # this doesn't work but illustrates the idea chooserIcon = Image( ImageFile('images/chooserIcon.gif',globals() ) Help! =:) Hmm.. This is how Product Icons are stored, that is, as ImageFile objects. At product init time, a ImageFile objetcs is created for the Product icon and stroed in the special misc_ structure for later access. Have a look through the Product initialisation code, which is started up in OFS/Application.py::install_products(). -- Martijn Pieters | Software Engineermailto:[EMAIL PROTECTED] | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ | ZopeStudio: http://www.zope.org/Products/ZopeStudio - ___ 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] Accessing .gif on disk with Python Product?
On Mon, Aug 07, 2000 at 01:38:56PM -0300, Kevin Howe wrote: Right you are, here's how I solved it: # __init.py__ for myProduct misc_={ 'chooserIcon': ImageFile('images/chooserIcon.gif',globals()), } # DTML file img src="dtml-var absolute_url/misc_/myProduct/chooserIcon" border=0 misc_ is a root level object. Using absolute_url you are acquiring it into your Instance URL, which is not necessary (and will hamper off-server caching). Use dtml-SCRIPT_NAME; instead (which will give you the absolute url of the root object in all cases): img src="dtml-SCRIPT_URL;/misc_/myProduct/chooserIcon" border=0 -- Martijn Pieters | Software Engineermailto:[EMAIL PROTECTED] | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ | ZopeStudio: http://www.zope.org/Products/ZopeStudio - ___ 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] Accessing .gif on disk with Python Product?
From: Martijn Pieters [EMAIL PROTECTED] misc_ is a root level object. Using absolute_url you are acquiring it into your Instance URL, which is not necessary (and will hamper off-server caching). Use dtml-SCRIPT_NAME; instead (which will give you the absolute url of the root object in all cases): img src="dtml-SCRIPT_URL;/misc_/myProduct/chooserIcon" border=0 I sugget using "dtml-BASE1;", since SCRIPT_NAME doesn't work well with virtual hosting. Cheers, Evan @ digicool 4-am ___ 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] Accessing .gif on disk with Python Product?
Martijn Pieters wrote: On Mon, Aug 07, 2000 at 04:23:36PM -0400, Evan Simpson wrote: From: Martijn Pieters [EMAIL PROTECTED] misc_ is a root level object. Using absolute_url you are acquiring it into your Instance URL, which is not necessary (and will hamper off-server caching). Use dtml-SCRIPT_NAME; instead (which will give you the absolute url of the root object in all cases): img src="dtml-SCRIPT_URL;/misc_/myProduct/chooserIcon" border=0 I sugget using "dtml-BASE1;", since SCRIPT_NAME doesn't work well with virtual hosting. I don't see this would make a difference; Zope is passed the base URL at which it takes over the URL. A SiteAccess object may only influence parts of the URL that come _after_ this base. http://zopeintherooturl/foo, where foo is a Zope object, has SCRIPT_NAME='/', while http://zopeinasuburl/zope/foo, has SCRIPT_NAME='/zope/'. Zope may remove the foo from the URL because of some Virtual Host rule, SCRIPT_NAME will still be valid. Sorry, I'd have to agree with Evan on this one. I'm pretty sure I've had SiteAccess not play nicely wih SCRIPT_NAME whereas BASE1 works fine... cheers, Chris ___ 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 )