Docs for ScalarList and NumberRange

This commit is contained in:
Konsta Vesterinen
2013-04-03 13:01:45 +03:00
parent fcd5d380ae
commit 4d0c3500e4
4 changed files with 51 additions and 2 deletions

View File

@@ -4,6 +4,13 @@ Changelog
Here you can see the full list of changes between each SQLAlchemy-Utils release.
0.8.1 (2013-04-02)
^^^^^^^^^^^^^^^^^^
- Removed unnecessary print statement form ScalarList
- Documentation for ScalarList and NumberRange
0.8.0 (2013-04-02)
^^^^^^^^^^^^^^^^^^

View File

@@ -51,6 +51,49 @@ You can easily set up integer lists too:
session.commit()
NumberRange
-----------
NumberRangeType provides way for saving range of numbers into database.
Example ::
from sqlalchemy_utils import NumberRangeType, NumberRange
class Event(Base):
__tablename__ = 'user'
id = db.Column(db.Integer, autoincrement=True)
name = db.Column(db.Unicode(255))
estimated_number_of_persons = db.Column(NumberRangeType)
party = Event(name=u'party')
# we estimate the party to contain minium of 10 persons and at max
# 100 persons
party.estimated_number_of_persons = NumberRange(10, 100)
print party.estimated_number_of_persons
# '10-100'
NumberRange supports some arithmetic operators:
::
meeting = Event(name=u'meeting')
meeting.estimated_number_of_persons = NumberRange(20, 40)
total = (
meeting.estimated_number_of_persons +
party.estimated_number_of_persons
)
print total
# '30-140'
API Documentation
-----------------

View File

@@ -24,7 +24,7 @@ class PyTest(Command):
setup(
name='SQLAlchemy-Utils',
version='0.8.0',
version='0.8.1',
url='https://github.com/kvesteri/sqlalchemy-utils',
license='BSD',
author='Konsta Vesterinen',

View File

@@ -98,7 +98,6 @@ class ScalarList(types.TypeDecorator):
# Convert list of values to unicode separator-separated list
# Example: [1, 2, 3, 4] -> u'1, 2, 3, 4'
if value:
print value
if any(self.separator in unicode(item) for item in value):
raise ScalarListException(
"List values can't contain string '%s' (its being used as "