[Zope] ZClass Question

Albert Kinderman albert.kinderman@csun.edu
Fri, 01 Oct 1999 17:36:15 -0700


Kevin:

Great!  Thanks a lot!  Works like a charm! [I hate to think about how
much time I have wasted over the last two weeks.]

Here is a quick write-up for others taken from the example of KM|Net
News.

In your xProduct, create a DTML document (or method) with id default. 
This is at the same level as the xClass, xClass_add, xClass_addForm, and
xClassFactory.

In your xClass_add, include within the 

<dtml-with "xClass.createInObjectManager(REQUEST['id'], REQUEST)">

the lines

<dtml-call "REQUEST.set('data',default.document_src(REQUEST,RESPONSE))">
<dtml-call "manage_addDTMLDocument('default','',data)">
[changed in the obvious way for a DTML Method]

along with any property sheet management call (as explained in the
comment in the standard xClass_add).

Now when you create an instance of x, the document default will be
automatically created within the instance created.  Since default is
inside of the instance, I believe you must have ZObjectManager as one of
the base classes. [I haven't tried it without ZObjectManager as a base
class, but I know it works when you do.]

Thanks again.

Al

Kevin Dangoor wrote:
> 
> Hi,
> 
>     I had originally been thinking that ZClasses would allow you to override
> ZClass-level methods, etc. with methods at the instance level. But, this is
> not the case... and you're also not able to edit the methods for each
> instance, as you have found.
> 
>     I have a solution to this, and I should probably write it up in a HOWTO
> because this has come up a couple of times. If you download KM|Net News, you
> can see my solution pretty easily.
> 
>     In the KMArticleStore ZClass, there are methods labelled
> "default_article_header" and "default_article_footer", etc. The
> KMArticleStore_add method will automatically take the contents of those
> methods and copy them to the new instance. I have also added a view called
> "Defaults" which allows the user to easily restore the defaults. One side
> note: make sure you map the Access Contents Information property on your
> "default" methods.
> 
>     I'll try to write a complete howto about this in my copious free time.
> Hopefully, the paragraph above will point you where you want to go...
> 
> Kevin
> 
> -----Original Message-----
> From: Albert Kinderman <albert.kinderman@csun.edu>
> To: zope@zope.org <zope@zope.org>
> Date: Friday, October 01, 1999 2:40 PM
> Subject: [Zope] ZClass Question
> 
> >I have tried all sorts of permission combinations, but I can't seem to
> >get it right.  When I create an instance (agenda), the Contents page
> >appears empty (index_html and content are not listed), but when I view
> >the instance I see the page correctly with the default contents from the
> >agendaClass.  I would like "content" to appear on the Contents page of
> >the instance.  Clicking on "content" should take the content manager to
> >a set of pages that include Edit, Upload, Properties, and View. I do not
> >want the index_html to be editable.

-- 
Albert Kinderman             California State University, Northridge
Department of Management Science           albert.kinderman@csun.edu