Skip to main content

Generates a persistent sequence

Project description

This project is a fork of gocept.sequence (http://pypi.python.org/pypi/gocept.sequence/) originally created by Daniel Havlik and Sebastian Wehrmann.

cykooz.sequence

Generates a persistent sequence.

Sequences

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

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

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

You get a SequenceGenerator by adapting to ISequenceGenerator:

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

You get a sequence like this:

>>> seq_gen.getNextValue()
1
>>> seq_gen.getNextValue()
2
>>> seq_gen.getNextValue()
3

You can also set the generator to a value:

>>> seq_gen.setNextValue(1)
>>> seq_gen.getNextValue()
1
>>> seq_gen.setNextValue(5)
>>> seq_gen.getNextValue()
5
>>> seq_gen.getNextValue()
6
>>> seq_gen.getNextValue()
7
>>> seq_gen.getNextValue()
8

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.

Changes

1.0.0 (2011-04-14)

  • Removed old migration code.

  • Removed the dependency from Persistence.

Project details


Download files

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

Source Distribution

cykooz.sequence-1.0.0.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file cykooz.sequence-1.0.0.tar.gz.

File metadata

File hashes

Hashes for cykooz.sequence-1.0.0.tar.gz
Algorithm Hash digest
SHA256 be0fd96bd927cf0e2835de8aa93557b42a59550a5a5ce4157c488008e5a360a5
MD5 31942d79859cf67479bb17e7df7bf2f0
BLAKE2b-256 eab3f7af3617c75c7f4fa8d7c7980012bf76f8e1c6312e13659577f2444a30df

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page