I'm working with the AddressBook example from the book, "Zope Bible". The example uses the following to conditionally display an edit link for an AddressBook entry in the object's index_html (rendered via a DTMLFile() object): <dtml-if "meta_type=='AddressBook Entry'"> | <a href="./editEntryForm">Edit Entry</a></dtml-if> However, this never renders an "Edit Entry" link because meta_type's value is 'AddressBook' (i.e. the type of the containing object) and not the expected value 'AddressBook Entry'. I've verified this by printing out the type of self.meta_type. How do I force the object's type to be referenced by the DTMLFile object? In case it matters, I'm using Zope 2.6.1 and Python 2.1 on OpenBSD 3.3. I've tried to invoke the Python debugger, but the ZODB can't even find the object in question.
Dario Alcocer wrote at 2004-1-1 13:47 -0800:
I'm working with the AddressBook example from the book, "Zope Bible". The example uses the following to conditionally display an edit link for an AddressBook entry in the object's index_html (rendered via a DTMLFile() object):
<dtml-if "meta_type=='AddressBook Entry'"> | <a href="./editEntryForm">Edit Entry</a></dtml-if>
However, this never renders an "Edit Entry" link because meta_type's value is 'AddressBook' (i.e. the type of the containing object) and not the expected value 'AddressBook Entry'. I've verified this by printing out the type of self.meta_type.
This means: either your "index_html" is "applied" to the "AddressBook" (and not an entry) or an "AddressBook Entry" does not have a "meta_type" attribute. -- Dieter
Dieter Maurer wrote:
Dario Alcocer wrote at 2004-1-1 13:47 -0800:
I'm working with the AddressBook example from the book, "Zope Bible". The example uses the following to conditionally display an edit link for an AddressBook entry in the object's index_html (rendered via a DTMLFile() object):
<dtml-if "meta_type=='AddressBook Entry'"> | <a href="./editEntryForm">Edit Entry</a></dtml-if>
However, this never renders an "Edit Entry" link because meta_type's value is 'AddressBook' (i.e. the type of the containing object) and not the expected value 'AddressBook Entry'. I've verified this by printing out the type of self.meta_type.
This means:
either your "index_html" is "applied" to the "AddressBook" (and not an entry)
I'm not sure what you mean, but the object *should* be an Entry object. The AddressBook class supports an addEntry method; the entries are store in a dictionary kept by AddressBook: class AddressBook(SimpleItem): "An AddressBook object" meta_type = "AddressBook" def addEntry(self, FirstName = "", MiddleInitial = "", LastName = "", REQUEST = ""): "Method to add entry to an AddressBook" id = self.LastEntryID = self.LastEntryID + 1 id = str(id) entry = Entry(id, FirstName, MiddleInitial, LastName) self.Entries[id] = entry self.__changed__(1) class Entry(Item, Persistent, Implicit): "Address Book Entry" meta_type = "AddressBook Entry" def __init__(self, id, FirstName, MiddleInitial, LastName): self.id = id self.editEntry(FirstName, MiddleInitial, LastName) index_html = DTMLFile('dtml/entryDetails', globals()) Does it matter that Entry inherits from Item and not from SimpleItem? Maybe the fact that Implicit is a base class means that meta_type is acquired from AddressBook.
or an "AddressBook Entry" does not have a "meta_type" attribute.
Nope, as you can see from above, the Entry class does in fact have a meta_type member. Any other hints you might have will be greatly appreciated.
Dieter Maurer wrote:
Dario Alcocer wrote at 2004-1-1 13:47 -0800:
I'm working with the AddressBook example from the book, "Zope Bible". The example uses the following to conditionally display an edit link for an AddressBook entry in the object's index_html (rendered via a DTMLFile() object):
<dtml-if "meta_type=='AddressBook Entry'"> | <a href="./editEntryForm">Edit Entry</a></dtml-if>
However, this never renders an "Edit Entry" link because meta_type's value is 'AddressBook' (i.e. the type of the containing object) and not the expected value 'AddressBook Entry'. I've verified this by printing out the type of self.meta_type.
This means:
either your "index_html" is "applied" to the "AddressBook" (and not an entry)
or an "AddressBook Entry" does not have a "meta_type" attribute.
Well, after searching through the "Zope Bible", I came up with the following work-around in the DTML file (patch attached.) Basically, I had to avoid using meta_type, but I'm still not sure why it doesn't work. I'm going to e-mail the authors to find out why. Thanks for your help.
participants (2)
-
Dario Alcocer -
Dieter Maurer