Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Generates a sequence

Project description

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)

- 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
- improved readability of test cases


- initial release

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gocept.sequence, version 0.31
Filename, size File type Python version Upload date Hashes
Filename, size gocept.sequence-0.31.tar.gz (5.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page