Re: [Zope] Best way to subclass DTML Document and some other ZClassesquestions

2000-08-16 Thread Marcin Kasperski

"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 
  Documents (where  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)

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Best way to subclass DTML Document and some other ZClassesquestions

2000-08-16 Thread R. David Murray

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


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Best way to subclass DTML Document and some other ZClassesquestions

2000-08-14 Thread R. David Murray

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.

 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.

 3) Can I influence property editing screens (what I want is to increase
 some edit boxes)?

As far as I know (until Martjin finishes his skinnable support) you
can only do that by wholesale replacing the editing screen with
your own form.  Or by modifying the source.

 I created also some classes which do not inherit DTML Document or DTM
 method. I have questions about such a configuration:
 
 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.

 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)? 

 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 
 Documents (where  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.

 7) And what if you were to change something a little - say detect that
 some property belongs to custom propertysheet and put it there instead
 on putting on standard DTML Document propertysheet?

Easy to do in external method python code.

 Regards and thanks in advance for any hints and references

I think my answers are a little bit too cryptic to be immediately
useful.  Maybe someone else will give specifics, otherwise I
hope they serve as useful hints.

--RDM


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )