Commit ccbe8e6f authored by Sebastien Robin's avatar Sebastien Robin

added setter and getter for guid


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@340 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ec936b32
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment