Alan Warren wrote:
On 11/18/05, Chris Withers <[EMAIL PROTECTED]> wrote:

Alan Warren wrote:

single image into a folder.  So, I have a folder called view.  When an
image is viewed the URL looks like

The code looks like this:
<span tal:define="imgName python:request['URL2'][len(request['URL3']+1:]">
   <span tal:define="global imgObj python:path('here/'+imgName)"></span>



This is really contorted. Why do you use URL2 and URL3?

To extract just the id of the image being viewed.  The relative path
from the template that presents the image to the image being presented
will always match that pattern.


Is imgObj not just 'here' anyway?

Not in a manner I could easily work with, view is a folder containing
index_html (the page template in question), and a handful of other
page templates and scripts -- all of which are specific actions a user
may wish to perform on a single image -- rather than on a whole album.

*sigh* I can see why you want this, but I'd loose the 'view' folder and just have the methods somewhere acquirable...

in fact, I'd just rename your index_html to 'view'.

Then you can just replace all instances of imgObj with 'context'

Why do you do a global define?

Because I'm godless.


The question I was trying to answer wasn't about some coding style
issue, but rather about how to convert a string path to an object at

You should very rarely have to do this. If you end up doing this, big alarm belsl should start ringing ;-)



Simplistix - Content Management, Zope & Python Consulting
Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to