[Zope] Custom id genaration on copy/paste of ZClass
Toby Dickenson
tdickenson@geminidataloggers.com
Wed, 18 Sep 2002 11:32:07 +0100
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 t=
he
> ZClass in the same folder I want a new id generated for the copy and no=
t
> 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=3D0
> if (len(id) > 8) and (id[8:]=3D=3D'copy_of_'):
> n=3D1
> orig_id=3Did
> while 1:
> if self._getOb(id, None) is None:
> return id
> id=3D'copy%s_of_%s' % (n and n+1 or '', orig_id)
> n=3Dn+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.=20