- id = Utf8Utils.desacc(id)
- id = bad_url_chars.sub('-', id)
- # If allow_dup is false, an error will be raised if an object
- # with the given id already exists. If allow_dup is true,
- # only check that the id string contains no illegal chars;
- # check_valid_id() will be called again later with allow_dup
- # set to false before the object is added.
-
- makeRandomId = False
- if id in ('.', '..'):
- makeRandomId = True
- if id.startswith('_'):
- id = id.lstrip('_')
- if id.startswith('aq_'):
- id = id[3:]
-
- while id.endswith('__') :
- id = id[:-1]
- if not allow_dup:
- obj = getattr(self, id, None)
- if obj is not None:
- # An object by the given id exists either in this
- # ObjectManager or in the acquisition path.
- flags = getattr(obj, '__replaceable__', NOT_REPLACEABLE)
- if hasattr(aq_base(self), id):
- # The object is located in this ObjectManager.
- if not flags & REPLACEABLE:
- makeRandomId = True
- # else the object is replaceable even if the UNIQUE
- # flag is set.
- elif flags & UNIQUE:
- makeRandomId = True
- if id == 'REQUEST':
- makeRandomId = True
-
- if makeRandomId is True :
- id = str(randrange(2,10000)) + id
- return id
-
-
+ id = Utf8Utils.desacc(id)
+ id = bad_url_chars.sub('-', id)
+ # If allow_dup is false, an error will be raised if an object
+ # with the given id already exists. If allow_dup is true,
+ # only check that the id string contains no illegal chars;
+ # check_valid_id() will be called again later with allow_dup
+ # set to false before the object is added.
+
+ makeRandomId = False
+ if id in ('.', '..'):
+ makeRandomId = True
+ if id.startswith('_'):
+ id = id.lstrip('_')
+ if id.startswith('aq_'):
+ id = id[3:]
+
+ while id.endswith('__') :
+ id = id[:-1]
+ if not allow_dup:
+ obj = getattr(self, id, None)
+ if obj is not None:
+ # An object by the given id exists either in this
+ # ObjectManager or in the acquisition path.
+ flags = getattr(obj, '__replaceable__', NOT_REPLACEABLE)
+ if hasattr(aq_base(self), id):
+ # The object is located in this ObjectManager.
+ if not flags & REPLACEABLE:
+ makeRandomId = True
+ # else the object is replaceable even if the UNIQUE
+ # flag is set.
+ elif flags & UNIQUE:
+ makeRandomId = True
+ if id == 'REQUEST':
+ makeRandomId = True
+
+ if makeRandomId is True :
+ id = str(randrange(2,10000)) + id
+ return id
+
+