ó FRTc@sPddlmZddlmZdefd„ƒYZdefd„ƒYZdS(iÿÿÿÿ(tdeepcopy(t DynamizertNEWVALUEcBseZRS((t__name__t __module__(((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb2/items.pyRstItemcBseZdZded„Zd„Zd„Zd„Zd„Z d„Z d„Z dd„Z d „Z d „Zd „ZeZd „Zdd „Zd„Zd„Zd„Zd„Zd„Zdd„Zd„Zd„Zd„Zd„Zed„Zd„ZRS(s An object representing the item data within a DynamoDB table. An item is largely schema-free, meaning it can contain any data. The only limitation is that it must have data for the fields in the ``Table``'s schema. This object presents a dictionary-like interface for accessing/storing data. It also tries to intelligently track how data has changed throughout the life of the instance, to be as efficient as possible about updates. Empty items, or items that have no data, are considered falsey. cCsm||_||_i|_||_tƒ|_|jdkrKi|_n|jrit|jƒ|_ndS(sà Constructs an (unsaved) ``Item`` instance. To persist the data in DynamoDB, you'll need to call the ``Item.save`` (or ``Item.partial_save``) on the instance. Requires a ``table`` parameter, which should be a ``Table`` instance. This is required, as DynamoDB's API is focus around all operations being table-level. It's also for persisting schema around many objects. Optionally accepts a ``data`` parameter, which should be a dictionary of the fields & values of the item. Optionally accepts a ``loaded`` parameter, which should be a boolean. ``True`` if it was preexisting data loaded from DynamoDB, ``False`` if it's new data from the user. Default is ``False``. Example:: >>> users = Table('users') >>> user = Item(users, data={ ... 'username': 'johndoe', ... 'first_name': 'John', ... 'date_joined': 1248o61592, ... }) # Change existing data. >>> user['first_name'] = 'Johann' # Add more data. >>> user['last_name'] = 'Doe' # Delete data. >>> del user['date_joined'] # Iterate over all the data. >>> for field, val in user.items(): ... print "%s: %s" % (field, val) username: johndoe first_name: John date_joined: 1248o61592 N(ttablet_loadedt _orig_datat_dataRt _dynamizertNoneR(tselfRtdatatloaded((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb2/items.pyt__init__s*       cCs|jj|dƒS(N(R tgetR (R tkey((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb2/items.pyt __getitem__PscCs||j|>> user.needs_save() False >>> user['first_name'] = 'Johann' >>> user.needs_save() True RRR N(R R)tFalsetlentTrue(R R t needs_savetkind((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb2/items.pyR-˜s cCst|jƒ|_dS(sM Marks an ``Item`` instance as no longer needing to be saved. Example: >>> user.needs_save() False >>> user['first_name'] = 'Johann' >>> user.needs_save() True >>> user.mark_clean() >>> user.needs_save() False N(RR R(R ((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb2/items.pyt mark_cleanµscCsdS(sß DEPRECATED: Marks an ``Item`` instance as needing to be saved. This method is no longer necessary, as the state tracking on ``Item`` has been improved to automatically detect proper state. N((R ((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb2/items.pyt mark_dirtyÇscCsgi|_x<|jdiƒjƒD]"\}}|jj|ƒ||||jkr||jkr t ||d>> user['last_name'] = 'Doh!' # Only the last name field will be sent to DynamoDB. >>> user.partial_save() R@RA( R8RKR*RtremovetKeyErrorRDRt _update_itemR/(R RRER@t fieldnameRRAtreturned((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb2/items.pyt partial_saveps     cCsk|jƒ r| rtS|jƒ}d}|tkrE|jƒ}n|jj|d|ƒ}|jƒ|S(sU Saves all data to DynamoDB. By default, this attempts to ensure that none of the underlying data has changed. If any fields have changed in between when the ``Item`` was constructed & when it is saved, this call will fail so as not to cause any data loss. If you're sure possibly overwriting data is acceptable, you can pass an ``overwrite=True``. If that's not acceptable, you may be able to use ``Item.partial_save`` to only write the changed field data. Optionally accepts an ``overwrite`` parameter, which should be a boolean. If you provide ``True``, the item will be forcibly overwritten within DynamoDB, even if another process changed the data in the meantime. (Default: ``False``) Returns ``True`` on success, ``False`` if no save was performed. Example:: >>> user['last_name'] = 'Doh!' # All data on the Item is sent to DynamoDB. >>> user.save() # If it fails, you can overwrite. >>> user.save(overwrite=True) RAN(R-R*RFR RDRt _put_itemR/(R t overwriteRERARP((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb2/items.pytsavežs   cCs|jƒ}|jj|S(sª Deletes the item's data to DynamoDB. Returns ``True`` on success. Example:: # Buh-bye now. >>> user.delete() (R8Rt delete_item(R R7((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb2/items.pytdeleteËs N(RRt__doc__R R*RRRRRRRRRRRt __nonzero__R)R-R/R0R4R8R;RDR#RFRKRQRTRV(((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb2/items.pyR s66           $     4  $ . -N(tcopyRtboto.dynamodb2.typesRtobjectRR(((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb2/items.pyts