Commit 64695b86 authored by Vincent Pelletier's avatar Vincent Pelletier

IdTool: "self" is the tool itself.

Also, avoid a few single-use variables.
Also, use modern exception raising syntax.
parent ca125dac
...@@ -87,27 +87,23 @@ class IdTool(BaseTool): ...@@ -87,27 +87,23 @@ class IdTool(BaseTool):
Use the low-level to create a site without catalog Use the low-level to create a site without catalog
""" """
assert reference assert reference
id_tool = self.getPortalObject().portal_ids
id_last_generator = None id_last_generator = None
version_last_generator = 0 version_last_generator = 0
for generator in id_tool.objectValues(): for generator in self.objectValues():
if generator.getReference() == reference: if generator.getReference() == reference:
version = generator.getVersion() version = generator.getVersion()
if version > version_last_generator: if version > version_last_generator:
id_last_generator = generator.getId() id_last_generator = generator.getId()
version_last_generator = generator.getVersion() version_last_generator = version
if id_last_generator is None: if id_last_generator is None:
raise KeyError, 'The generator %s is not present' % (reference,) raise KeyError(repr(reference))
return id_last_generator return id_last_generator
def _getLatestGeneratorValue(self, id_generator): def _getLatestGeneratorValue(self, id_generator):
""" """
Return the last generator with the reference Return the last generator with the reference
""" """
id_tool = self.getPortalObject().portal_ids return self._getOb(self._getLatestIdGenerator(id_generator))
last_id_generator = self._getLatestIdGenerator(id_generator)
last_generator = id_tool._getOb(last_id_generator)
return last_generator
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'generateNewId') 'generateNewId')
......
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