rendering images from an external product revisited
Hi, I have this class: class eba(Folder,SimpleItem.SimpleItem,Elem_base): "elements basis element" versie = '0.1' meta_type = 'eba' etc.... Eba can have eba_items: class Elem_base_item(ObjectManager,Implicit,Persistent,SimpleItem.SimpleItem): "Eba item" meta_type="eba_item" def __init__(self,id,kop,tekst,volgorde,auteur,status,slot,type, kopstijl,tekststijl,auto_br,datum): self.id=id self.kop=kop etc.... Users can add images to Elem_base_item through a form with with the method: def addImg(self,f_file,REQUEST=None): "voegt een afbeelding toe" self.manage_addImage('afbeelding',title='afbeelding',file=f_file) self._p_changed = 1 if REQUEST is not None: return self.editItemForm(REQUEST, manage_tabs_message='Afbeelding is toegevoegd' The indentation got a bit lost in copy/paste but this works all very well. I have this method wich returns all the eba_items: def listItems(self): "maakt lijst van items" orde=self.items.keys() lijst=[] for i in orde: lijst.append(self.items[str(i)]) return lijst The index_html for the product has the folowing DTML: <dtml-in "listItems()" sort="volgorde"> <tr><td class="<dtml-var kopstijl>"> <dtml-var kop> </td></tr> <tr><td class="<dtml-var tekststijl>"> <dtml-if afbeelding> <dtml-var "afbeelding.tag(align='left')"> </dtml-if> <dtml-var tekst newline_to_br> <dtml-if> </td></tr> </dtml-in> Kop and tekst wicht are properties of an eba_item are rendered perfectly. Afbeelding wich is the image wich a user can add not. I get the following traceback: Error Type: KeyError Error Value: SERVER_URL Troubleshooting Suggestions This resource may be trying to reference a nonexistent object or variable SERVER_URL. The URL may be incorrect. The parameters passed to this resource may be incorrect. A resource that this resource relies on may be encountering an error. For more detailed information about the error, please refer to the HTML source for this page. If the error persists please contact the site maintainer. Thank you for your patience. Traceback (innermost last): File C:\Program Files\WebSite251\lib\python\ZPublisher\Publish.py, line 150, in publish_module File C:\Program Files\WebSite251\lib\python\ZPublisher\Publish.py, line 114, in publish File C:\Program Files\WebSite251\lib\python\Zope\__init__.py, line 159, in zpublisher_exception_hook (Object: ebatest) File C:\Program Files\WebSite251\lib\python\ZPublisher\Publish.py, line 98, in publish File C:\Program Files\WebSite251\lib\python\ZPublisher\mapply.py, line 88, in mapply (Object: index_html) File C:\Program Files\WebSite251\lib\python\ZPublisher\Publish.py, line 39, in call_object (Object: index_html) File C:\Program Files\WebSite251\lib\python\OFS\DTMLMethod.py, line 127, in __call__ (Object: index_html) File C:\Program Files\WebSite251\lib\python\DocumentTemplate\DT_String.py, line 473, in __call__ (Object: index_html) File C:\Program Files\WebSite251\lib\python\DocumentTemplate\DT_With.py, line 76, in render (Object: test) File C:\Program Files\WebSite251\lib\python\Shared\DC\Scripts\Bindings.py, line 266, in __render_with_namespace__ (Object: index_html) File C:\Program Files\WebSite251\lib\python\Shared\DC\Scripts\Bindings.py, line 283, in _bindAndExec (Object: index_html) File C:\Program Files\WebSite251\lib\python\App\special_dtml.py, line 172, in _exec (Object: index_html) File C:\Program Files\WebSite251\lib\python\DocumentTemplate\DT_In.py, line 695, in renderwob (Object: listItems()) File C:\Program Files\WebSite251\lib\python\DocumentTemplate\DT_Util.py, line 159, in eval (Object: afbeelding.tag(align='left')) (Info: afbeelding) File <string>, line 0, in ? File C:\Program Files\WebSite251\lib\python\OFS\Image.py, line 736, in tag (Object: afbeelding) File C:\Program Files\WebSite251\lib\python\OFS\Traversable.py, line 48, in absolute_url (Object: afbeelding) KeyError: (see above) In my build management interface the images are rendered perfectly. But this interface doesn't work for the images with the listItems method. Any ideas? Henny
(try and get more to the point when askign for help, not everyone has time to read hundres of lines of narrative ;-) ) Henny van der Linde wrote:
Error Type: KeyError Error Value: SERVER_URL
File C:\Program Files\WebSite251\lib\python\ZPublisher\Publish.py, line
Upgrade Zope while you're at it, 2.5.1 is criminally old...
File C:\Program Files\WebSite251\lib\python\OFS\Traversable.py, line 48, in absolute_url (Object: afbeelding) KeyError: (see above)
You're not building correct acquisition wrapping for some of your objects. If you get any subjects from a dict with something like: obj = self.whatever[something] ...you need to do: object = self.whatever[something].__of__(self) Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (2)
-
Chris Withers -
Henny van der Linde