Commits

Anonymous committed 99b0e80

schema definition documentation

Comments (0)

Files changed (4)

 
 *.pyc
 *.egg
-*.orig
 dynamodb_mapper.egg-info
 
 build
  - Boto = 2.6.0
  - AWS account
 
- We assume you've correctly set your Boto credentials.
+Highlights
+==========
+
+- Python <--> DynamoDB type mapping
+- Deep schema definition and validation with ``Onctuous`` (new in 1.8.0)
+- Multi-target transaction (new in 1.6.0)
+- Sub-transactions (new in 1.6.2)
+- Migration engine (new in 1.7.0)
+- Smart conflict detection (new in 1.7.0)
+- Full low-level chunking abstraction for ``scan``, ``query`` and ``get_batch``
+- Default values
+- Auto-inc hash_key
+- Framework agnostic
+
 
 Example usage
 =============
 
+We assume you've correctly set your Boto credentials or use ``ddbmock``.
 
 Quick install
 -------------
 Want to contribute, report a but of request a feature ? The development goes on
 at Ludia's BitBucket account:
 
+Dynamodb-mapper
+---------------
+
 - **Report bugs**: https://bitbucket.org/Ludia/dynamodb-mapper/issues
 - **Fork the code**: https://bitbucket.org/Ludia/dynamodb-mapper/overview
+- **Download**: http://pypi.python.org/pypi/dynamodb-mapper
+
+Onctuous
+--------
+
+- **Full documentation**: https://onctuous.readthedocs.org/en/latest
+- **Report bugs**: https://bitbucket.org/Ludia/onctuous/issues
+- **Download**: http://pypi.python.org/pypi/onctuous

docs/api/model.rst

 a single database. It is highly recommended to namespace your tables with a name
 of the form ``<application>-<env>-<model>``.
 
+Deep schema definition and validation with Onctuous
+---------------------------------------------------
+
+Onctous (http://pypi.python.org/pypi/onctuous) has been integrated into
+DynamoDB-Mapper as part of 1.8.0 release cycle.
+
+Before writing any validator relying on Onctuous, there is a crucial point to
+take into account. Validators are ran when loading from DynamoDB *and* when saving
+to DynamoDB. ``Save`` stores the output of the validators while reading functions feeds the
+validators with raw DynamoDB values that is to say, the serialized output of the
+validators.
+
+Hence, validators must be accept both serialized and already de-serialized input.
+As of Onctuous 0.5.2, ``Coerce`` can safely do that as it checks the type before
+attempting anything.
+
+To sum up, schema entries of the form
+
+ - base type (``int``, ``unicode``, ``float``, ``dict``, ``list``, ...) works seamlessly.
+ - ``datetime`` type: same special behavior as before
+ - ``[validators]`` and ``{'keyname': validators}`` are automatically (de-)serialized
+ - callable validators (``All``, ``Range``, ...) MUST accept both serialized and de-serialized input
+
+Here is a basic schema example using deep validation:
+
+::
+
+    from dynamodb_mapper.model import DynamoDBModel
+    from onctuous.validators import Match, Length, All, Coerce
+    from datetime import datetime
+
+    class Article(DynamoDBModel):
+        __table__ = "Article"
+        __hash_key__ = "slug"
+        __schema__ = {
+            # Regex validation. Input and output are unicode so no coercion problem
+            "slug": Match("^[a-z0-9-]+$"),
+
+            # Regular title and body definition
+            "title": unicode,
+            "body": unicode,
+
+            # Special case for dates. Not that you would have to handle
+            # (de-)serialization yourself if you wanted to apply condition
+            "published_date": datetime,
+
+            # list of tags. I force unicode as an example even though it is not
+            # strictly speaking needed here
+            "tags": [All(Coerce(unicode), Length(min=3, max=15))],
+        }
+
 .. _auto-increment-when-to-use:
 
 Using auto-incrementing index

docs/pages/overview.rst

  - Boto = 2.6.0
  - AWS account
 
-Features
-========
+Highlights
+==========
 
 - Python <--> DynamoDB type mapping
-- dict and lists serialization
-- default values
-- Multi-target transaction support with auto-retry (new in 1.6.0)
+- Deep schema definition and validation with ``Onctuous`` (new in 1.8.0)
+- Multi-target transaction (new in 1.6.0)
 - Sub-transactions (new in 1.6.2)
-- Single object migration engine (new in 1.7.0)
+- Migration engine (new in 1.7.0)
+- Smart conflict detection (new in 1.7.0)
+- Full low-level chunking abstraction for ``scan``, ``query`` and ``get_batch``
+- Default values
 - Auto-inc hash_key
-- Protection against the 'lost update' syndrom (refactored in 1.7.0)
-- Full low-level chunking abstraction for ``scan``, ``query`` and ``get_batch``
-- New table creation
 - Framework agnostic
-- Log all successful database access
 
 .. TODO: add links to related documentation
 
 Logging
 =======
 
-Dynamodb-mapper uses 3 "logging" loggers:
+Dynamodb-mapper uses 3 loggers:
 
 - model
 - model.database-access
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.