[Zope] Best way to subclass DTML Document and some other
ZClassesquestions
Marcin Kasperski
Marcin.Kasperski@softax.com.pl
Wed, 16 Aug 2000 09:11:24 +0200
"R. David Murray" wrote:
>
> On Mon, 14 Aug 2000, Marcin Kasperski wrote:
> > 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.
>
> Pass it as an argument to the call that creates the DTML Document.
How?
Currently my constructor method contains
the following (mk_dtml_document is my custom class which subclasses DTML
Document, Extra is the name of my custom propertysheet):
<dtml-with
"mk_dtml_document.createInObjectManager(REQUEST['id'],REQUEST)">
<dtml-call "propertysheets.Extra.manage_editProperties(REQUEST)">
<dtml-comment> How can I change original title? </dtml-comment>
<dtml-call reindex_object>
</dtml-with>
title is present in REQUEST and is not set in created 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?
>
> Yep. You should be able to replicate everything the original
> constructor code does in your own code. Read The Source, Luke <grin>.
>
I hate replicating code. I love calling it. Couldn't it be done this
way?
> > 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 can add that property name as an index, and construct your
> search form so the search string is submitted to it (see the Advanced
> ZCatalog Searching HowTo). Or, you could define your own
> PrincipiaSearchSource method and return whatever value is appropriate.
> I *think* you should be able to define this as a method of your
> ZClass, but I've never tried that. I know it works from python <grin>.
I tried defining DTML Method with name PrincipiaSearchSource and
contents
<dtml-var body>
(body is my custom property name).
Next I clicked 'Update Catalog' in ZCatalog screen. Seems my attempt has
been ignored - the amount of objects indexed via PrincipiaSearchSource
(according to ZCatalog status screen) has not changed (those object are
succesfully indexed on title etc).
>
> > 5) Can I write index_html method of my custom class so it interpret DTML
> > tags (like dtml-var substitution)?
>
> I'm sure you can, but I don't know how <grin>. But if you are doing
> that, why not just subclass DTML-Method (or document)?
Because I have not done it previously and now I have about 100 objects
of this type and do not know how to perform such a change.
>
> > 6) What you, Zope gurus, would do if you were to find all the DTML
> > Documents in some directory tree and remove them, creating instead XXXX
> > Documents (where XXXX Document is some subclass of DTML Document) - and
> > keeping the document id, title, contents and properties without change?
>
> Write an external method to do all the object creation, property
> copying, and old object deletion.
>
What about some sample code?
Regards
-- Serwis nie tylko mieszkaniowy: http://www.mk.w.pl
|
| The cost of a few uncorrected non-critical human errors is less then
| the cost imposed by a process that tries to prevent them.
| (Booch,Martin,Newkirk)