Regarding my previous proposal.....

>  I would like to propose my "Paste Reference"/symlink hack for
> inclusion into Zope 2.6


  And referring to my previous msg.....

At 19:04 07-08-2001 +0100, Mario Valente wrote:
>  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.

>  - 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"
>   value="Paste Ref." />
>  """

>   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
>    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
>    references.

   I have now solved the issues/TODO. I now have implemented a way
 to distinguish references from the original. Links have a name like
 "copy_of_XXXX" but instead its "shortcut_to_XXX" and they also have
 a different metatype and a different icon. There's also crude management
 screens to get to the original object.

  Here's the *major* hack :-) (its such a kludge that even I am shocked :-)
  But it serves to demonstrate the purpose.

  Like previously described I edited CopySupport.py and created a
 new method called pasteMonikers. This method is accessed by the
 interface button referred above.

  The coding difference is that this method now creates a *new* object
 (instead of copying the old one, which is the semantics of usual Copy/Paste,
  and instead of using the original object, which is the semantics of the
  PasteReference I created and described before).

  This is the relevant piece of code:

                ob = SimpleItem.ItemShortcut(ob)

                self._setObject(id, ob)

                ob = self._getOb(id)

  As you can see a new id is created for the new object (method 
 _get_linkid is identical to method get_id but returns ids with the
 format "shortcut_to_%s") and a new object of class ItemShortcut
 is created and pasted into the current folder.

  The ItemShortcut class was created at the SimpleItem.py file
 and its basically a Proxy pattern.
  This is the relevant code, added at the end of SimpleItem.py:

class ItemShortcut(SimpleItem):
        """Proxying class for shortcut implementation
        meta_type = "Shortcut"
        icon     ='shortcut.gif'

        manage_options= SimpleItem.manage_options + (
        manage_options= SimpleItem.manage_options + (
        #__ac_permissions__=(('View', ()),)
        __ac_permissions__=(('View', ('__call__', '')),)

        def __init__(self, obj=None):
                self.__obj__ = obj

        def __repr__(self):
                return "Proxy for "+`self.__obj__`

        def index_html(self):
                """Proxying class for shortcut implementation
                return self.__obj__.__call__()

        def manage_properties(self):
                """Proxying class for shortcut implementation
                return """<HTML><head></head>
                        Shortcut for """+`self.__obj__`+"""
                        <a href="""+`self.__obj__.absolute_url()`+""">View
original object</a>
href="""+self.__obj__.absolute_url()+"""/manage_workspace>Edit original

   Once again, this is just proof of concept, and should be correctly
 (read 'nicely' :-) implemented for Zope 2.6.

  C U!

  -- Mario Valente

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

Reply via email to