diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py index 5c14e0a61680123a1d26a865c0e75f8fd684cf14..77dcaf8b83552e4e182f4c7506d65229eff240e2 100755 --- a/product/ERP5Type/Base.py +++ b/product/ERP5Type/Base.py @@ -59,6 +59,8 @@ import pickle from cStringIO import StringIO from email.MIMEBase import MIMEBase from email import Encoders +from socket import gethostname, gethostbyaddr +import random from zLOG import LOG @@ -1206,6 +1208,30 @@ class Base( CopyContainer, PortalContent, Base18, ActiveObject, ERP5PropertyMana psyco.bind(getObjectMenu) + security.declareProtected(Permissions.ModifyPortalContent, 'setGuid') + def setGuid(self): + """ + This generate a global and unique id + It will be defined like this : + full dns name + portal_name + uid + random + the guid should be defined only one time for each object + """ + if not hasattr(self, 'guid'): + guid = '' + # Set the dns name + guid += gethostbyaddr(gethostname())[0] + guid += '_' + self.portal_url.getPortalPath() + guid += '_' + str(self.uid) + guid += '_' + str(random.randrange(1,2147483600)) + setattr(self,'guid',guid) + + security.declareProtected(Permissions.AccessContentsInformation, 'getGuid') + def getGuid(self): + """ + Get the global and unique id + """ + return getattr(self,'guid',None) + class TempBase(Base): """ If we need Base services (categories, edit, etc) in temporary objects