Custom id genaration on copy/paste of ZClass
Hi All, I created my own ZClass which has a generated id, when I copy & paste the ZClass in the same folder I want a new id generated for the copy and not the automatic 'copy_of' id. I looked at CopySupport.py and it states: def _get_id(self, id): # Allow containers to override the generation of # object copy id by attempting to call its _get_id # method, if it exists. n=0 if (len(id) > 8) and (id[8:]=='copy_of_'): n=1 orig_id=id while 1: if self._getOb(id, None) is None: return id id='copy%s_of_%s' % (n and n+1 or '', orig_id) n=n+1 Is it possible te override this method in a ZClass to create my own id's Greetings Ralph
On Wednesday 18 Sep 2002 11:19 am, Ralph vd Houdt wrote:
Hi All,
I created my own ZClass which has a generated id, when I copy & paste the ZClass in the same folder I want a new id generated for the copy and not the automatic 'copy_of' id. I looked at CopySupport.py and it states:
def _get_id(self, id): # Allow containers to override the generation of # object copy id by attempting to call its _get_id # method, if it exists. n=0 if (len(id) > 8) and (id[8:]=='copy_of_'): n=1 orig_id=id while 1: if self._getOb(id, None) is None: return id id='copy%s_of_%s' % (n and n+1 or '', orig_id) n=n+1
Is it possible te override this method in a ZClass to create my own id's
This method begins with a _ so you cant modify it through the web. You could easily add this to a Python base class of your ZClass.
participants (2)
-
Ralph vd Houdt -
Toby Dickenson