Re: [Zope] Zclasses derived from ZCatalog
Tom Schwaller <tom.schwaller@linux-magazin.de> wrote:
http://www.zope.org/Members/Zen/tips/tip_ZCatalogInZClass
shows nicely how to add a ZCatalog in a ContainerClass. How does one implement the same functionality when deriving a class A from ZCatalog:
A(ZCatalog) -- B(CatalogAware)
Check out my How-To, http://www.zope.org/Members/tseaver/inherit_ZCatalog
How to modify <dtml-with "Catalog"> <dtml-call "manage_addColumn('area',REQUEST,RESPONSE,URL1)"> ?
Just call the method (of the ZCatalog-derived class): <dtml-call "manage_addColumn( 'area', REQUEST, RESPONSE, URL1 )">
<dtml-with _catalog> will not work.
Right, attributes/methods starting with "_" are invisible to DTML.
Then I'd like to add B-Objects, which are CatalogAware, to the A-Catalog.
Right now I use only one instance of the A-class (Books) and add the Books (type B) by writing:
<dtml-with "Book.createInObjectManager(REQUEST['id'], REQUEST)"> <dtml-call "propertysheets.buchdaten.manage_editProperties(REQUEST)"> <dtml-call unindex_object> <dtml-call "manage_editCataloger('Books', REQUEST)"> <dtml-call reindex_object> </dtml-with>
which is nonsense, but works for one Book-Folder with a defined name.
I like deriving from ZCatalog, so the users do not see the Catalog (otherwise one could delete it) and the ContainerClass (Books) is the catalog of its members (Book).
Any hints?
This is essentially what I am doing -- I just tried adding a DTMLMethod named "Catalog" to the ZCatalog-derived class, which just returns this() -- IT WORKS! -- ========================================================= Tres Seaver tseaver@palladion.com 713-523-6582 Palladion Software http://www.palladion.com
Tres Seaver wrote:
Tom Schwaller <tom.schwaller@linux-magazin.de> wrote:
http://www.zope.org/Members/Zen/tips/tip_ZCatalogInZClass
shows nicely how to add a ZCatalog in a ContainerClass. How does one implement the same functionality when deriving a class A from ZCatalog:
A(ZCatalog) -- B(CatalogAware)
Check out my How-To, http://www.zope.org/Members/tseaver/inherit_ZCatalog
cool, thanks a lot. PARENTS[1].id is what I was looking for :-) (I forgot the .id)
How to modify <dtml-with "Catalog"> <dtml-call "manage_addColumn('area',REQUEST,RESPONSE,URL1)"> ?
Just call the method (of the ZCatalog-derived class):
<dtml-call "manage_addColumn( 'area', REQUEST, RESPONSE, URL1 )">
ok, I'll try that...
<dtml-with _catalog> will not work.
Right, attributes/methods starting with "_" are invisible to DTML.
I like deriving from ZCatalog, so the users do not see the Catalog (otherwise one could delete it) and the ContainerClass (Books) is the catalog of its members (Book).
Any hints?
This is essentially what I am doing -- I just tried adding a DTMLMethod named "Catalog" to the ZCatalog-derived class, which just returns this() -- IT WORKS!
Could you explain that with code? I'm not exactly shure hoh you do that. With that you do not need <dtml-call "manage_editCataloger( PARENTS[1].id, REQUEST )"> anymore. Is that right? You should ad this very cool trick to your howto (this will be my number 1. Zope magic Trick for this week :-)) -- Tom
Tom Schwaller wrote:
Tres Seaver wrote:
<snip>
This is essentially what I am doing -- I just tried adding a DTMLMethod named "Catalog" to the ZCatalog-derived class, which just returns this() -- IT WORKS!
Could you explain that with code? I'm not exactly shure hoh you do that.
With that you do not need
<dtml-call "manage_editCataloger( PARENTS[1].id, REQUEST )">
anymore. Is that right? You should ad this very cool trick to your howto (this will be my number 1. Zope magic Trick for this week :-))
Add a DTML Method named "Catalog" to the ZClass derived from ObjectManager and ZCatalog. its body should be: <dtml-return "this()"> The CatalogAware ZClass instances search up the acquisition tree for on object named Catalog to register with -- they find the method as an attribute of their container, and use it instead. CAVEAT: I haven't yet figured out how to use the Catalog-method inside other DTML, e.g., <dtml-in "Catalog( meta_type='BarBaz' )"> ... </dtml-in> doesn't work. I'll think on it some more. -- ========================================================= Tres Seaver tseaver@palladion.com 713-523-6582 Palladion Software http://www.palladion.com
At 14:22 03/11/99 , Tres Seaver wrote:
Add a DTML Method named "Catalog" to the ZClass derived from ObjectManager and ZCatalog. its body should be:
<dtml-return "this()">
The CatalogAware ZClass instances search up the acquisition tree for on object named Catalog to register with -- they find the method as an attribute of their container, and use it instead.
I like this one!
CAVEAT:
I haven't yet figured out how to use the Catalog-method inside other DTML, e.g.,
<dtml-in "Catalog( meta_type='BarBaz' )"> ... </dtml-in>
doesn't work. I'll think on it some more.
<dtml-in "_['Catalog'](meta_type='BarBaz')"> will work, but not with a real Catalog object, only your DTML trickery. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
Martijn Pieters wrote:
CAVEAT:
I haven't yet figured out how to use the Catalog-method inside other DTML, e.g.,
<dtml-in "Catalog( meta_type='BarBaz' )"> ... </dtml-in>
doesn't work. I'll think on it some more.
<dtml-in "_['Catalog'](meta_type='BarBaz')">
will work, but not with a real Catalog object, only your DTML trickery.
Hmm, I can't seem to make that work: ZClass Foo( ObjectManager, ZCatalog ) \ ZClass Bar( CatalogAware, ObjectManager ) \ ZClass Baz( CatalogAware ) I can add Bars and Bazzes within a Foo, and they show up in its manage_catalogView. I tried defining a DTML method using your syntax in either Foo or Bar to (say) list all the Bazzes, like so: <dtml-var standard_html_header> <UL> <dtml-in "_['Catalog'](meta_type='Baz')"> <LI> <dtml-var id> </dtml-in> </UL> <dtml-var standard_html_footer> But I can't execute it -- I get "You are not authorized to access Catalog". If I tweak the permission map a bit for Foo (Access Content Information->Access Content Information), I then get "You are not authorized to access this". So, I give the Catalog method a "Manager" proxy. Now, I get: Error Type: AttributeError Error Value: __getitem__ -- ========================================================= Tres Seaver tseaver@palladion.com 713-523-6582 Palladion Software http://www.palladion.com
At 16:31 03/11/99 , Tres Seaver wrote:
Martijn Pieters wrote:
CAVEAT:
I haven't yet figured out how to use the Catalog-method inside other DTML, e.g.,
<dtml-in "Catalog( meta_type='BarBaz' )"> ... </dtml-in>
doesn't work. I'll think on it some more.
<dtml-in "_['Catalog'](meta_type='BarBaz')">
will work, but not with a real Catalog object, only your DTML trickery.
Hmm, I can't seem to make that work:
ZClass Foo( ObjectManager, ZCatalog ) \ ZClass Bar( CatalogAware, ObjectManager ) \ ZClass Baz( CatalogAware )
I can add Bars and Bazzes within a Foo, and they show up in its manage_catalogView. I tried defining a DTML method using your syntax in either Foo or Bar to (say) list all the Bazzes, like so:
<dtml-var standard_html_header>
<UL> <dtml-in "_['Catalog'](meta_type='Baz')"> <LI> <dtml-var id> </dtml-in> </UL>
<dtml-var standard_html_footer>
But I can't execute it -- I get "You are not authorized to access Catalog". If I tweak the permission map a bit for Foo (Access Content Information->Access Content Information), I then get "You are not authorized to access this".
So, I give the Catalog method a "Manager" proxy. Now, I get:
Error Type: AttributeError Error Value: __getitem__
-- ========================================================= Tres Seaver tseaver@palladion.com 713-523-6582 Palladion Software http://www.palladion.com
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope
(Related lists - please, no cross posts or HTML encoding!
To receive general Zope announcements, see: http://lists.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://lists.zope.org/mailman/listinfo/zope-dev )
-- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
I hate it when I slip on the keyboard and sent a completely unedited email out.. At 16:31 03/11/99 , Tres Seaver wrote:
Hmm, I can't seem to make that work:
ZClass Foo( ObjectManager, ZCatalog ) \ ZClass Bar( CatalogAware, ObjectManager ) \ ZClass Baz( CatalogAware )
I can add Bars and Bazzes within a Foo, and they show up in its manage_catalogView. I tried defining a DTML method using your syntax in either Foo or Bar to (say) list all the Bazzes, like so:
<dtml-var standard_html_header>
<UL> <dtml-in "_['Catalog'](meta_type='Baz')"> <LI> <dtml-var id> </dtml-in> </UL>
<dtml-var standard_html_footer>
But I can't execute it -- I get "You are not authorized to access Catalog". If I tweak the permission map a bit for Foo (Access Content Information->Access Content Information), I then get "You are not authorized to access this".
So, I give the Catalog method a "Manager" proxy. Now, I get:
Error Type: AttributeError Error Value: __getitem__
Erm... bother. And the traceback is? -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
Martijn Pieters wrote:
I hate it when I slip on the keyboard and sent a completely unedited email out..
At 16:31 03/11/99 , Tres Seaver wrote:
Hmm, I can't seem to make that work:
ZClass Foo( ObjectManager, ZCatalog ) \ ZClass Bar( CatalogAware, ObjectManager ) \ ZClass Baz( CatalogAware )
I can add Bars and Bazzes within a Foo, and they show up in its manage_catalogView. I tried defining a DTML method using your syntax in either Foo or Bar to (say) list all the Bazzes, like so:
<dtml-var standard_html_header>
<UL> <dtml-in "_['Catalog'](meta_type='Baz')"> <LI> <dtml-var id> </dtml-in> </UL>
<dtml-var standard_html_footer>
But I can't execute it -- I get "You are not authorized to access Catalog". If I tweak the permission map a bit for Foo (Access Content Information->Access Content Information), I then get "You are not authorized to access this".
So, I give the Catalog method a "Manager" proxy. Now, I get:
Error Type: AttributeError Error Value: __getitem__
Erm... bother. And the traceback is?
DOH! My bad! <!-- Traceback (innermost last): File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 214, in publish_module File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 179, in publish File /usr/local/Zope/lib/python/Zope/__init__.py, line 201, in zpublisher_exception_hook (Object: CatalogAware) File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 165, in publish File /usr/local/Zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: list_bazzes) File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: list_bazzes) File /usr/local/Zope/lib/python/OFS/DTMLMethod.py, line 145, in __call__ (Object: list_bazzes) File /usr/local/Zope/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: list_bazzes) File /usr/local/Zope/lib/python/DocumentTemplate/DT_In.py, line 672, in renderwob (Object: _['Catalog'](meta_type='Baz')) AttributeError: (see above) --> -- ========================================================= Tres Seaver tseaver@palladion.com 713-523-6582 Palladion Software http://www.palladion.com
At 17:27 3-11-99 , Tres Seaver wrote:
Erm... bother. And the traceback is?
DOH! My bad!
How about _.getitem('Catalog', 1)(meta_type='Bar') or <dtml-with Catalog> <dtml-in "searchResults(meta_type='Bar')"> </dtml-with> -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | T: +31 35 7502100 F: +31 35 7502111 | mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ---------------------------------------------
Martijn Pieters wrote:
At 17:27 3-11-99 , Tres Seaver wrote:
Erm... bother. And the traceback is?
DOH! My bad!
How about
_.getitem('Catalog', 1)(meta_type='Bar')
That gives the same AttributeError (__getitem__).
or
<dtml-with Catalog> <dtml-in "searchResults(meta_type='Bar')"> </dtml-with>
That works. COOL! I'll update my How-To to use this technique instead. -- ========================================================= Tres Seaver tseaver@palladion.com 713-523-6582 Palladion Software http://www.palladion.com
participants (3)
-
Martijn Pieters -
Tom Schwaller -
Tres Seaver