[Zope] How to convert string to object?
Thu, 13 Mar 2003 11:20:42 +0100
Edward & all,
thanks, this is definitely good idea how to create content based web-sites
using ZPTs. I did my tests to create site structure, and it works fine, but
I have few issues (maybe you will be able to help, if you are creating the
sites this way?):
- Let's say the "content" file inside the folders is my own object,
inheritted from e.g. DTML document (so it has some additional properties
like time and date, but in the base it's HTML).
- Let's say when user clicks on some "EDIT" link (this link would be
located outside content file of course, so it will be in ZPT's index_html),
it should run some different method of the "content" object (which would
for example open edit form - BUT inside the edit template). Do you have any
ideas how to do this best way?
This is how I solved it under your example (but I don't feel this would be
Zope's standard way and I have few issues, see below):
The EDIT and CONTENT located in ZPT index_html from your example I created
or table or what not containing whatever you want to appear before the
<a href="content/editForm" tal:attributes="href
tal:string="<iframe width=100% height=600
or table or what not containing whatever you want to appear after the
It works somehow, but these are my issues:
o) I had to use <IFRAME..> to create new "frame" editing instead of using
'tal:content="structure here/content/editForm"' for edit, because this way
did NOT get the additional properties from my custom object! (I don't know
o) I don't know how to do tal:contidion with the if-then-else system
(that's why the first condition in <span
tal:condition="not:exists:here/REQUEST/form/edit_me" and the second one is
directly the opposite: <span
o) I'm looking for some way of changing my object to get the index_html
template directly from inside the object, to not use the ?edit_me=1
parameter, is there any way?
Does anyone have any ideas how to improve this? (or also any link to good
documentation about ZPT connected with creating custom product classes
would be appreciated; I have read ZopeBook, but was not able to find
solutions for these here, maybe I've overseen something?) Thanks a lot in
On 07 Mar 2003 00:07:32 -0600, Edward Muller <email@example.com> wrote:
> If your asking that question there is a possibility that you don't
> understand zope acquisition. Which is all right ... I think we all
> didn't get it at one point.
> I assume you want to use index_html as a template (or wrapper) for the
> content in some deeper folder?
> If so all you need to do (sorry this is in zpt ... don't use dtml much
> in a zpt in your root folder ..
> or table or what not containing whatever you want to appear before the
> <div tal:content="structure here/content"/>
> or table or what not containing whatever you want to appear after the
> Now just create folders ... and stick a file (dtml or zpt or python
> script or whatever) called 'content' wherever you want it to appear.
> So if I had a folder layout like the following:
> I would put a zpt (or dtml document/method) called 'content' in the
> /articles/linux/2003/03/07/01 folder.
> And when I surfed to:
> I would get the content file 'wrapped' with the index_html somewhere up
> the folder 'path'.
> You can further customize things by using macros and slots and all the
> zpt goodies. Plus if you ever need to 'override' your index_html file
> deeper in you folder 'tree' just create a new one at the highest level
> you want to start using it.
> Hope this helps
> On Thu, 2003-03-06 at 08:49, Lubos Culen wrote:
>> Maybe this is more Python question, but because I'm using it with Zope,
>> I'm posting it here.
>> Let's suppose I have DTML Method called e.g. 'index_html' . It has one
>> input parameter 'obj' which contains name of existing file object inside
>> the directory tree. For example, the index_html file would be called as:
>> Then in folder www.mysite.com/path/path/to/object/file in this example
>> would be the DTML document I'd like to be displayed. I have to make
>> proper code in the index_html file do do this.
>> I tried do following in index_html:
>> <dtml-var obj>
>> But this echoes only plain text ('path.to.object.file') and not the
>> object's content. I need to find some way how to convert this string to
>> object, so Zope (or Python) can understand it as an object and display
>> its content. Is there some way?
>> Thanks a lot for any answer!