[Zope] Best way to subclass DTML Document and some other ZClasses questions

Dieter Maurer dieter@handshake.de
Wed, 16 Aug 2000 21:19:53 +0200 (CEST)


Marcin Kasperski writes:
 > >  > 1) How can I set standard DTML Document properties (title!) from my
 > >  > constructor? I created constructor form and constructor method, I
 > >  > succesfully prompt for and set all my properties but I do not know how
 > >  > to set properties belonging to DTML Document.
 > > Your ZClass inherits the methods of its base classes.
 > > You use the base classes methods to access their features.
 > > 
 > > In your specific case, you would use "manage_changeProperties"
 > > to change the DTML Document properties.
 > > "manage_changeProperties" is defined by "OFS.PropertyManager.PropertyManager".
 > 
 > What exactly should I write? ....
 > On which object (which property sheet) should I call
 > manage_editProperties to change document title?
On the object you want the title changed ....

Okay, let's admit: I am a bit confused.

  Above, I understood that your class derives from DTML Document.
  Then each instance of your class is an instance of DTML Document, too.
  You use the inherited methods in the same way you use the methods
  defined in your class.
  I.e. 

	<dtml-with mkNewObject(.....)>
	   <dtml-call "manage_changeProperties(.....)">
	</dtml-with>

  What confuses me: below your custom class does not seem to
  be derived from DTML Document.


 > >  > 2) Can I do anything to have single property screen which would behave
 > >  > as original DTML Document property screen but present both original
 > >  > properties and properties belonging to my custom property sheet?
 > > You can create your own ZClass "view" that does this.
 > 
 > So it is impossible to use original DTML Document property screen? I
 > like it.
You can use the source and extend it (slightly).


 > >  > 4) Can I do something to have ZCatalog PrincipiaSearch (i.e. full text
 > >  > search) to scan some property of my custom ZClass (say property body
 > >  > from propertysheet Basic)?
 > > You just define "Meta Data" or indexes for them.
 > 
 > Not exactly. I would like to have bodies of my DTML Documents and my
 > custom class (which does not subclass DTML Document) .body property
 > contents to be indexed with _the same_ full text index.
What should this "the same" mean?

 > I tried defining method PrincipiaSearchSource in my custom class but it
 > did not helped (ZCatalog did not indexed my objects in PrincipiaSearch
 > index - according to its status screen).
Any parameterless method (or any attribute) should work.

Maybe, your methods throws an exception. Then, it will not contribute
to the indexing. Test it in isolation.
 

 > >  > 5) Can I write index_html method of my custom class so it interpret DTML
 > >  > tags (like dtml-var substitution)?
 > > I do not understand this question:
 > > 
 > >   "index_html" has nothing to do with interpreting DTML tags.
 > 
 > Yes I know. In fact I ask 'what can I do to parse DTML in a method of
 > object which does not subclass DTML Document?'
 > 
 > >   When you want to interpret DTML tags, you will need to somehow
 > >   use DocumentTemplate instances.
 > 
 > And that 'somehow' is what I am asking for.
You either use the Zope wrapped Document Template objects
(DTML method/document) or you use the DocumentTemplate
directly in Python (external method, product, maybe Python method).

The DTML user guide contains a chapter on how to use Document Template
from Python.

 
 > The archives are not searchable :-(
You look at the wrong archives.

NIP archives the main Zope mailing lists.
*These* archives *are* searchable.



Dieter