On Wed, 16 Aug 2000, Marcin Kasperski wrote:
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)">
Hmm. I've only done this kind of thing by calling the add method of the class, where you could pass in, say, title=title. I'm not sure how you'd do it with createInObjectManager. Although you might try wrapping the whole thing in <dtml-with REQUEST>. The REQUEST title may be getting overridden by another title property that happens to be blank.
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?
Maybe. You'd have to look at the source code and see if can handle being called as a subroutine. If not, somebody ought to refactor it <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).
As someone else said, the method has to be parameterless (yours probably appears to be). This also means that it can't depend on having a name space around (that usually gets passed implicitly to dtml methods), including REQUEST, since Catalog won't have that to pass it in most indexing scenarios. At first glance I'd think your code would work, but I can think of two other things you could try: <dtml-return body>, and defining an external method instead and just have it just do "return self.body".
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.
Ah, yes, changing the base class of a ZClass is hard. There's a hold-onto-your-pants recipie for doing it, but it's not for the faint of heart. Check the HowTo's if you are curious. Depending on the complexity of the objects, you could write an external method that would write the data out to a file in some format, and another to read the data back in and use it to instantiate new objects of the desired type. I did this once with a 60K database of objects <wry grin>. I *could* send you that source code as an example, if you want. I based the re-load code on the "adding ZClass object programatically" howto.
Write an external method to do all the object creation, property copying, and old object deletion.
What about some sample code?
I haven't done it myself, so I don't have any sample code for this (but see above). --RDM