[Erp5-report] r33148 seb - in /erp5/trunk/products/ERP5/interfaces: id_generator.py id_tool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Feb 26 13:37:29 CET 2010


Author: seb
Date: Fri Feb 26 13:37:28 2010
New Revision: 33148

URL: http://svn.erp5.org?rev=33148&view=rev
Log:
add interfaces for id tool and generators

Added:
    erp5/trunk/products/ERP5/interfaces/id_generator.py
    erp5/trunk/products/ERP5/interfaces/id_tool.py

Added: erp5/trunk/products/ERP5/interfaces/id_generator.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/interfaces/id_generator.py?rev=33148&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/interfaces/id_generator.py (added)
+++ erp5/trunk/products/ERP5/interfaces/id_generator.py [utf8] Fri Feb 26 13:37:28 2010
@@ -1,0 +1,78 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
+#                    Sebastien Robin <seb at nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsibility of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# guarantees and support are strongly advised to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+
+from zope.interface import Interface
+
+class IIdGenerator(Interface):
+  """
+  Rounding tool interface
+  """
+
+  def generateNewId(id_group=None, default=None):
+    """
+    Generate the next id in the sequence of ids of a particular group
+
+    Parameters :
+
+    id_group (string)
+      This is the name of a particular sequence if ids.
+
+    default (string or int or float, depending on the generator)
+       Default value of the sequence (optional).
+       The first time an id is generated for that sequence, this 
+       default will be returned.
+
+       If the default value is incompatible with the generator,
+       ValueError will be raised.
+
+    """
+
+  def generateNewIdList(id_group=None, default=None, id_count=1):
+    """
+    Generate a list of next ids in the sequence of ids of a particular group
+
+    Parameters :
+
+    id_group (string)
+      This is the name of a particular sequence if ids.
+
+    default (string or int or float, depending on the generator)
+       Default value of the sequence (optional).
+       The first time an id is generated for that sequence, this 
+       default will be returned.
+
+       If the default value is incompatible with the generator,
+       ValueError will be raised.
+
+    method
+       This allows to customize the way id are generated. This
+       method should take as parameter the previously generated
+       id (optional). By default, ids are managed like integers and
+       are increased one by one
+    """

Added: erp5/trunk/products/ERP5/interfaces/id_tool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/interfaces/id_tool.py?rev=33148&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/interfaces/id_tool.py (added)
+++ erp5/trunk/products/ERP5/interfaces/id_tool.py [utf8] Fri Feb 26 13:37:28 2010
@@ -1,0 +1,92 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
+#                    Sebastien Robin <seb at nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsibility of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# guarantees and support are strongly advised to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+
+from zope.interface import Interface
+
+class IIdTool(Interface):
+  """
+  Id Tool interface
+  """
+
+  def generateNewId(id_group=None, default=None, id_generator=None):
+    """
+    Generate the next id in the sequence of ids of a particular group
+
+    Parameters :
+
+    id_group (string)
+      This is the name of a particular sequence if ids.
+
+    default (string or int or float, depending on the generator)
+       Default value of the sequence (optional).
+       The first time an id is generated for that sequence, this 
+       default will be returned.
+
+       If the default value is incompatible with the generator,
+       ValueError will be raised.
+
+    id_generator (string)
+       Select an particular id generator (optional) by giving its
+       reference. This is not mandatory, a default generator will exist. 
+       Only id generator of type application can be selected.
+
+    Example :
+       my_new_id = portal_ids.generateNewId(id_group='sale_invoice',
+                              default=100)
+       # this can returns '154'
+    """
+
+  def generateNewIdList(id_group=None, default=None, id_count=1,
+      id_generator=None):
+    """
+    Generate a list of next ids in the sequence of ids of a particular group
+
+    Parameters :
+
+    id_group (string)
+      This is the name of a particular sequence if ids.
+
+    default (string or int or float, depending on the generator)
+       Default value of the sequence (optional).
+       The first time an id is generated for that sequence, this 
+       default will be returned.
+
+       If the default value is incompatible with the generator,
+       ValueError will be raised.
+
+    id_generator (string)
+       Select an particular id generator (optional) by giving its
+       reference. This is not mandatory, a default generator will exist. 
+       Only id generator of type application can be selected.
+
+    Example :
+       my_new_id_list = portal_ids.generateNewLengthIdList(id_group='sale_invoice',
+                              default=100, id_count=3)
+       # this can returns ['154', '155', '156']
+    """




More information about the Erp5-report mailing list