[Zope3-Users] Problem with @@absolute_url

Christophe Combelles ccomb at free.fr
Mon Apr 30 16:16:20 EDT 2007


You should probably try to set the __parent__ of the adapter to the __parent__ 
of the adapted object (or to the object itself)

Christophe

Greg Baker a écrit :
> I have no idea how to get the absolute url of an adapted object, or even if 
> its possible.  If you can, please bear with me and I'll try to explain myself 
> clearly.
> 
> Consider this example (simple object and adapter):
> 
> class IStudent:
>     """Simple student object"""
>     studentNumber = StudentNumber(
>         title = _("Student Number"),
>         description = _("""The student's ID number."""),
>         required = True)
> 
> class IStudentPhoto:
>     """Adapts Student to IImage"""
> 
> 
> The unit tests for my class and adapter passes fine, so I know that doing 
> something like the following works...
> 
>     photo = StudentPhoto(Student("123456789"))
> 
> 
> My problem is that I want to display the photo in a browser but can't figure 
> out how.  I created a browser view helper in python, and it seems to work for 
> the most part:
> 
> class StudentDetails:
>     """Helper to return a student photo."""
>     def getPhoto(self):
>         student = self.context
>         return StudentPhoto(student)
> 
> In my page template, I can see that the IImage object is being created 
> correctly..
> 
> <div tal:define="photo view/getPhoto">
>     <span tal:content="photo">#</span>
> </div>
> 
> gives me <zope.app.file.image.Image object at 0xb75c6c6c>.  But to turn this 
> object into a URL so that I can put it in an <img> tag is beyond me.  When I 
> try to do an @@absolute_url on the photo object I get the error saying 
> there's not enough context.
> 
> Am I going about this the wrong way?  Is there some other thing I need to be 
> doing in order for there to be enough context?
> 
> Thanks for any help,
> Greg
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
> 
> 



More information about the Zope3-users mailing list