1""" 2A basic version of chaise that just uses enriched dictionaries as the documents. 3 4:class:`BasicLoader`, :class:`BasicSession`, and :class:`BasicPool` do not do 5any migration handling. 6 7:class:`DictRegistry` should be paired with :class:`~chaise.CouchSession` and 8:class:`~chaise.SessionPool` if you want some basic document type handling. 9""" 10 11from.importDocumentRegistry,CouchSession,SessionPool 12 13
[docs] 14classDocument(dict): 15""" 16 A dictionary with some CouchDB attributes 17 """ 18 19#: Document ID 20id:str|None=None 21 22#: Document revision 23rev:str|None=None 24 25#: Has the document been deleted? (ie, is this a tombstone?) 26deleted:bool=False 27 28#: Attachment information, if requested 29attachments:dict|None=None 30 31#: List of conflicts, if requested 32conflicts:list|None=None 33 34# List of deleted conflicts, if requested 35deleted_conflicts:list|None=None 36 37#: 38local_seq:str|None=None 39 40#: 41revs_info:list|None=None 42 43#: 44revisions:dict|None=None 45 46def__repr__(self): 47returnf"<{type(self).__name__}{self.id!r}@{self.rev!r}{' '.join(f'{k}={v!r}'fork,vinself.items())}>"
48 49
[docs] 50classBasicLoader: 51""" 52 Provides loading without worrying about types or migrations. 53 """ 54
[docs] 69defdumpj(self,doc:Document)->dict: 70return( 71doc 72|({"_id":doc.id}ifdoc.idisnotNoneelse{}) 73|({"_rev":doc.rev}ifdoc.revisnotNoneelse{}) 74|{ 75"_deleted":doc.deleted, 76# The rest of it is informational not editable directly 77} 78)