1. Ludia
  2. Untitled project
  3. dynamodb-mapper

Commits

Jean-Tiare Le Bigot  committed 4f5e707 Merge

done overview part of the documentation

  • Participants
  • Parent commits cacb4dc, ab741a3
  • Branches default

Comments (0)

Files changed (5)

File .hgtags

View file
 c2554662c08016e84b7b882bdcd5c16b8da8b2f6 1.4.2
 754277898e0b0bd76a4f33e2236ec5fe0cf3fbee 1.4.3
 d72628aecca4bf866145d3f2424475c975626c7a 1.5.0
+ce23d59bbbc2361d8db0f1362aca4f552c7120cc 1.6.0

File CHANGES.rst

View file
 ===================
-DynamoDBMaper 1.6.0
+DynamoDBMapper 1.6.1
 ===================
 
-This page documents all user visible changes included between DynamoDBMaper
+This section documents all user visible changes included between DynamoDBMapper
+versions 1.5.0 and versions 1.6.0
+
+Additions
+---------
+
+- log all successful queries
+
+Known bugs
+----------
+
+- #7 Can't save models where a datetime field is nested in a dict/list
+
+===================
+DynamoDBMapper 1.6.0
+===================
+
+This section documents all user visible changes included between DynamoDBMapper
 versions 1.5.0 and versions 1.6.0
 
 Additions
 
 - support for default values in a ``__defaults__`` dict
 - specify instances members via global ``__init__ **kwargs``
+- autogenerated API documentation
 
 Changes
 -------
 - factorized default value code
 - enforce batch size 100 limit
 - full inline documentation
+- fixed issue: All transactions fail if they have a bool field set to False
 - 99% test coverage
 
 Removal

File docs/pages/overview.rst

View file
 
 .. include:: ../_include/intro.rst
 
+Requirements
+============
+
+The documentation currently assumes that you're running Boto 2.3.0 or later.
+If you're not, then the API for query and scan changes. You will have to supply
+raw condition dicts, as is done in boto itself.
+
+Also note that Boto 2.3.1 or later is required for autoincrement_int hash keys.
+Earlier versions will fail.
+
 Features
 ========
 
 - Protection against the 'lost update' syndrom
 - New table creation
 - Framework agnostic
-- Exposes most BOTO functionalities
+- Log all successful database access
 
 .. TODO: add links to related documentation
 
 =================
 
 - Dates nested in a dict or set can not be saved as ``datetime`` does not support
-    JSON serialization.
+    JSON serialization. (issue #7)
 
 Quick example
 =============
+
+Setup Dynamodb-mapper
+---------------------
+
+Instalation
+
+>>> pip install dynamodb-mapper
+
+Set you Amazon's API credential in ``~/.boto``
+
+.. code-block:: ini
+
+    [Credentials]
+    aws_access_key_id = <your access key>
+    aws_secret_access_key = <your secret key>
+
+For advance configuration, please see the `official Boto documentation <http://docs.pythonboto.org/en/latest/boto_config_tut.html>`_.
+
+
+Example model: DoomMap
+----------------------
+
+::
+
+    from dynamodb_mapper.model import DynamoDBModel
+
+
+    class DoomMap(DynamoDBModel):
+        __table__ = "doom_map"
+        __hash_key__ = "episode"
+        __range_key__ = "map"
+        __schema__ = {
+            "episode": int,
+            "map": int,
+            "name": unicode,
+            "cheats": set,
+        }
+        __defaults__ = {
+            "cheats": set(['Konami']),
+        }
+
+
+Initial Table creation
+----------------------
+::
+
+    conn = ConnectionBorg()
+    conn.create_table(DoomMap, 10, 10, wait_for_active=True)
+
+
+Model Usage
+-----------
+
+::
+
+    e1m1 = DoomMap()
+    e1m1.episode = 1
+    e1m1.map = 1
+    e1m1.name = u"Hangar"
+    e1m1.cheats = set(["idkfa", "iddqd", "idclip"])
+    e1m1.save()
+
+
+    # Later on, retrieve that same object from the DB...
+    e1m1 = DoomMap.get((1, 1))
+
+    # query on hash+range-keyed tables
+    e1_maps = DoomMap.query(hash_key=1)
+
+    from boto.dynamodb.condition import GT
+    e1_maps_after_5 = DoomMap.query(
+        hash_key=1,
+        range_key_condition=GT(5))

File dynamodb_mapper/model.py

View file
         if hash_key_type is autoincrement_int:
             self._create_autoincrement_magic_item(table)
 
+        dblog.debug("Created table %s(%s, %s)", cls.__table__, hash_key_name, range_key_name)
+
         return table
 
     def get_table(self, name):
                     range_key=r_value,
                     consistent_read=consistent_read)
 
-        dblog.debug("[GET] %s(%s, %s)", cls.__table__, h_value, r_value)
+        dblog.debug("Got item (%s, %s) from table %s", h_value, r_value, cls.__table__)
 
         return cls.from_dict(item)
 
 
         res = batch_list.submit()
 
-        dblog.debug("[BATCH GET] %s", cls.__table__)
+        dblog.debug("Sent a batch get on table %s", cls.__table__)
 
         return [
             cls.from_dict(d) for d in res[u"Responses"][cls.__table__][u"Items"]
                 consistent_read=consistent_read,
                 scan_index_forward=not reverse)
 
-        dblog.debug("[QUERY] %s(%s, %s)", cls.__table__, h_value, range_key_condition)
+        dblog.debug("Queried (%s, %s) on table %s", h_value, range_key_condition, cls.__table__)
 
         return (cls.from_dict(d) for d in res)
 
 
         res = table.scan(scan_filter)
 
-        dblog.debug("[QUERY] %s(%s)", cls.__table__, scan_filter)
+        dblog.debug("Scanned table %s with filter %s", cls.__table__, scan_filter)
 
         return (
             cls.from_dict(d)
                 # Unhandled exception
                 raise
 
+        hash_key_value = getattr(self, hash_key)
+        range_key_value = getattr(self, hash_key, None)
+        dblog.debug("Saved (%s, %s) in table %s allow_overwrite=%s", hash_key_value, range_key_value, cls.__table__, allow_overwrite)
+
     def delete(self):
         """Delete the current object from the database."""
         cls = type(self)
 
         table = ConnectionBorg().get_table(cls.__table__)
         Item(table, hash_key_value, range_key_value).delete()
+
+        dblog.debug("Deleted (%s, %s) from table %s", hash_key_value, range_key_value, cls.__table__)

File setup.cfg

View file
 [metadata]
 name = dynamodb-mapper
-version = 1.6.0
+version = 1.6.1
 summary = Object mapper for Amazon DynamoDB
 description_file = README.rst
 author = Max Noel