Skip to main content

API for storing and retrieving Atom entries.

Project description

This module defines a simple API for storing and retrieving Atom entries in different storage backends. Entries are defined using a JSON-like syntax:

>>> import datetime
>>> entry = {'id'     : 'http://example.com/1',
...          'title'  : 'My first entry',
...          'updated': datetime.datetime.utcnow(),
...         }

The module comes with a shelve backend:

>>> from atomstorage import EntryManager
>>> em = EntryManager('shelve://file.db')
>>> em.create_entry(entry)
{'updated': datetime.datetime(2006, 8, 15, 16, 27, 7, 960677),
 'id': 'http://example.com/1',
 'title': 'My first entry'}

New backends can be easily added by creating a module and setting an atomstorage.backend entry point. A SQLite backend is currently being developed.

The API defines a few methods the entry manager should have. To retrieve all entries, sorted by time (last to first):

>>> entries = em.get_entries()

The last 10 entries:

>>> entries = em.get_entries(10)

Retrieve the entry with id “1”:

>>> entry = em.get_entry("1")

Delete the same entry:

>>> em.delete_entry("1")

Get all entries from August 2006:

>>> entries = em.get_entries_by_date(2006, 8)

Or from the “tech” category:

>>> entries = em.get_entries_by_category("tech")

To search for entries mentioning “Python”:

>>> entries = em.search("Python")

The API is by no means final. Comments, suggestions, patches and critics are welcome.

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

atomstorage-0.1.1dev.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

atomstorage-0.1.1dev-py2.4.egg (8.1 kB view details)

Uploaded Source

File details

Details for the file atomstorage-0.1.1dev.tar.gz.

File metadata

File hashes

Hashes for atomstorage-0.1.1dev.tar.gz
Algorithm Hash digest
SHA256 48f357d082b5736ac468cc79041d963859015730fdc71ab248354b8ac017dabe
MD5 12c9eb498262a889bcb2e8dc00c1546b
BLAKE2b-256 fd29cf92cd957bec08d45845d360f7e1df380f9cd9a9d60fb95ca417599385a9

See more details on using hashes here.

Provenance

File details

Details for the file atomstorage-0.1.1dev-py2.4.egg.

File metadata

File hashes

Hashes for atomstorage-0.1.1dev-py2.4.egg
Algorithm Hash digest
SHA256 3480cb7575f10c85e5599ec3d77367a767af5394bdd690db903e22fc8d42620b
MD5 77474d4c8a1727526f10186c6d33df60
BLAKE2b-256 d169e37de188326f6d870c633f2a924377e82a112d5d2671211ab667a84688d7

See more details on using hashes here.

Provenance

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