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
On 07 Aug 2001 19:04:42 +0100, Mario Valente wrote:
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.
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.
[snip details]
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.
This looks useful, but I have some questions: - Acquisition works according to a 'containment before context' rule. The object that has been 'cloned' here arguably now has two containments. Which one gets used? - If I set a proxy role on the cloned object, does it get the same proxy role in it's original container? - What does PARENTS evaluate to? - If the clone is in a location where it wouldn't be able to acquire something, but the original is, can the clone still acquire that something? Thanks, Michael Bernstein.
Hi! I haven't tested your patch yet, but in theory it works fine for me. Though it is quite a hack ;-) Shane did something similar with his Symlik product, which still is on zope.org, but not linked at any more. If you want to look at it: It's here: http://www.zope.org/Members/hathawsh/Symlink <disclaimer>WARNING: THIS IS NOT FOR USE IN PRODUCTION SYSTEMS!</disclaimer> Shane's symlinks have the same conceptual problem you have: They look exactly like the original objects. Your approach seems to be more straightforward in terms of the user interface because it makes use of the copy&paste, which is really cool. I am currently working on more or less the same thing for Kontentor 2 (previews maybe next week!). I've implemented my own session-based copy support (just stores the path of the object to copy, doesn't know about multiple copy yet), because I didn't like the cookie thing. My "symlinks" are real objects that just hold the path to the linked object. When called, they do: def __call__(self, mode='view', REQUEST=None): ''' ''' linkAsList = string.split(self.link, '/') object = self.restrictedTraverse(linkAsList) return object.__call__(REQUEST) So when I edit the symlink, I don't get the original object, but just the form to change the link path. But that's exactly what I want. It would be no problem to add another edit link in the Kontentor frontend that opens the original object instead. Links to the references of an object are actually impossible without a major hack. What I'll do instead is use the catalog to find all symlink objects whose "link" attribute equals the absolute_url of the parent object. That will do it for me. In the newest SmartSections (which will be Kontentor's editing frontend), you can copy and paste (or symlink-paste) objects (Headers, Images, Text blocks, News items etc.) around in the site. Really cool. It will also get a version-based editing and reviewing framework. I'm using versions because so I can combine changes in more than one object to an actual review request (which will, if approved, just commit the version). With CMF you can only add one object at a time. Cheers Joachim
At 02:29 08-08-2001 +0200, Joachim Werner wrote:
I am currently working on more or less the same thing for Kontentor 2 (previews maybe next week!). I've implemented my own session-based copy support (just stores the path of the object to copy, doesn't know about multiple copy yet), because I didn't like the cookie thing. My "symlinks" are real objects that just hold the path to the linked object.
So when I edit the symlink, I don't get the original object, but just the form to change the link path. But that's exactly what I want. It would be no problem to add another edit link in the Kontentor frontend that opens the original object instead.
That was also one of my possible avenues of exploration to solve the problem. But it was too much work and....
I haven't tested your patch yet, but in theory it works fine for me. Though it is quite a hack ;-)
... I preferred the quick hack ;-)
In the newest SmartSections (which will be Kontentor's editing frontend), you can copy and paste (or symlink-paste) objects (Headers, Images, Text
This is cool. I have to find some time to try out Kontentor, SmartSections and DBObjects. They seem interesting solutions to lots of the stuff that we have to do. C U! -- MV
Juste a quick note:
linkAsList = string.split(self.link, '/') object = self.restrictedTraverse(linkAsList)
restrictedTraverse does the split itself if it receives a string, you don't need to do it yourself :) Bye, Florent Guillaume Nuxeo
linkAsList = string.split(self.link, '/') object = self.restrictedTraverse(linkAsList)
restrictedTraverse does the split itself if it receives a string, you don't need to do it yourself :)
Thanks! I just wasn't sure about that yet when I wrote those lines in the middle of the night ;-) Joachim
participants (4)
-
Florent Guillaume -
Joachim Werner -
Mario Valente -
Michael R. Bernstein