Package couchdbkit :: Module loaders :: Class BaseDocsLoader
[hide private]
[frames] | no frames]

Class BaseDocsLoader

source code

object --+
         |
        BaseDocsLoader

Baseclass for all doc loaders. Subclass this and override `get_docs` to implement a custom loading mechanism. You can then sync docs and design docs to the db with the `sync` function.

A very basic example for a loader that looks up a json file on the filesystem could look like this:

   from couchdbkit import BaseDocsLoader
   import os
   import anyjson

   class MyDocsLoader(BaseDocsLoader):

       def __init__(self, path):
           self.path = path

       def get_docs(self,):
           if not os.path.exists(path):
               raise DocsPathNotFound
           with file(path) as f:
               source = anyjson.deserialize(f.read().decode('utf-8'))
           return source
Instance Methods [hide private]
 
get_docs(self) source code
 
sync(self, dbs, atomic=True, verbose=False) source code
 
_put_attachment(self, db, doc, content, filename, content_length=None, verbose=False) source code
 
encode_attachments(self, db, design_doc, new_doc, verbose=False) source code
 
send_attachments(self, db, design_doc, verbose=False) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__