[Zope] Shallow copies/links/references

Mario Valente mvalente@ruido-visual.pt
Tue, 07 Aug 2001 19:04:42 +0100


  Hi:

  OK everyone, I've managed to get object links to work.

  As discussed previously by others (re: object references) and
 asked by myself: I had the need to be able to refer to objects
 from different points of the folder hierarchy without duplicating
 those objects.

  Yes I know that can be done *programatically*. That is not the
 idea.

  The idea is to have a folder with differente widgets/components
 and to be able to copy and paste references to those widgets
 throughout the folder hierarchy. Of course that the usual copy/paste
 is not OK, since that *duplicates* the objects and as such further
 changes to the original object wont be reflected in the copies.

  With something like this + Ordered Folders you are able to have
 an index_html that just renders the objects within a folder and you
 can then drop objects/widgets into the folder to produce a page.


  What I did:

  - edited CopySupport.py
  - copied the manage_pasteObjects method to a manage_pasteMonikers
    method
  - commented the #ob=ob._getCopy(self)  line  (the duplicate object part)
  - added a "Paste Ref" button to the lib/python/OFS/dtml/main.dtml file that
    calls the pasteMonikers method

  """
  <input class="form-element" type="submit" name="manage_pasteMonikers:method"
   value="Paste Ref." />
  """

 
   It works. It does what I want/need. When you change a reference, the 
 original also changes. When you change the original, the references change.
  You can delete either the reference or the original and all is OK.


   Issues/TODO

   - find a way to distinguish references from the original (tried to change
    the meta_type at paste time but no luck). At least the meta_type/icon
should
    change to provide a visual cue.
   - provide tool(s) to find impact of changing a reference. Provide a link
from a
    reference object to the original. Provide a link from an object to its
several
    references.

  Comments and experiences are welcome.

  C U!

  -- Mario Valente