Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

pypm install gocept.sequence

How to install gocept.sequence

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install gocept.sequence
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.31 Available View build log
Windows (64-bit)
0.31 Available View build log
Mac OS X (10.5+)
0.31 Available View build log
Linux (32-bit)
0.31 Available View build log
Linux (64-bit)
0.31 Available View build log
ZPL 2.1
Lastest release
version 0.31 on Jan 5th, 2011

This package lets you generate a persistent sequence. That means in practice, that you can generate sequent numbers without having to worry about storing the last generated number. This is done by gocept.sequence within the annotation of an object you provide.


>>> import Persistence
>>> import zope.annotation.interfaces
>>> from zope.interface import implements

We need a testobject, where the SequenceGenerator stores his data:

>>> class Dummy(Persistence.Persistent):
...     implements(zope.annotation.interfaces.IAttributeAnnotatable)
>>> test_object = zope.annotation.interfaces.IAnnotations(Dummy())

You get a SequenceGenerator by adapting to ISequenceGenerator:

>>> from gocept.sequence.interfaces import ISequenceGenerator
>>> seq_gen = ISequenceGenerator(test_object)

You get a sequence like this:

>>> seq_gen.getNextValue()
>>> seq_gen.getNextValue()
>>> seq_gen.getNextValue()

You can also set the generator to a value:

>>> seq_gen.setNextValue(1)
>>> seq_gen.getNextValue()
>>> seq_gen.setNextValue(5)
>>> seq_gen.getNextValue()
>>> seq_gen.getNextValue()
>>> seq_gen.getNextValue()
>>> seq_gen.getNextValue()

But setNextValue only accepts integer arguments:

>>> seq_gen.setNextValue('1')
Traceback (most recent call last):
ValueError: setNextValue expected Integer, <type 'str'> found.
>>> seq_gen.setNextValue(3.14)
Traceback (most recent call last):
ValueError: setNextValue expected Integer, <type 'float'> found.
0.4 (unreleased)
0.31 (2008-07-21)

System Message: WARNING/2 (<string>, line 82)

Title underline too short.

0.31 (2008-07-21)
  • added migration code and tests for the bugfix of release 0.3
  • added README text and CHANGELOG
0.3 (2008-07-21)
  • fixed a bug with Plone, where the dot in the annotation key caused an access

System Message: WARNING/2 (<string>, line 92)

Bullet list ends without a blank line; unexpected unindent.

error - improved readability of test cases

  • initial release

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:3

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.