sondra.application package¶
Submodules¶
Module contents¶
- class sondra.application.Application(suite, name=None)[source]¶
Bases: collections.abc.Mapping
An Application groups collections that serve a related purpose.
In addition to collections, methods and schemas can be exposed at the application level. Any exposed methods might be termed “library functions” in the sense that they apply to all collections, or configure the collections at a high level. Schemas exposed on the application level should be common to several collections or somehow logically “broader” than definitions at the document/collection level.
Application behave as Python dicts. The keys in the application’s dictionary are the slugs of the collections the application houses. In addition, applications are stored as items in a Suite’s dictionary. Thus to access the ‘Users’ collection in the ‘Auth’ application, one could start with the suite and work down thus:
> suite['auth']['users'] ... <Application object 0x...>
Also see the `webservices reference`_ for more on how to access applications and their schemas and methods over the web.
- db¶
str – The name of a RethinkDB database
- connection¶
str – The name of a RethinkDB connection in the application’s suite
- slug¶
str – read-only. The name of this application class, slugified (all lowercase, and separate words with -)
- anonymous_reads¶
bool=True – Override this attribute in your subclass if you want to disable anonymous queries for help and schema for this application and all its collections.
- definitions¶
dict – This should be a JSON serializable dictionary of schemas. Each key will be the name of that schema definiton in this application schema’s “definitions” object.
- schema[source]¶
dict – read-only. A JSON serializable schema definition for this application. In addition to the standard JSON-schema definitions, a dictionary of collection schema URLs and a list of methods are included as “collections” and “methods” respectively. The keys for the collection schemas are the slugged names of the collections themselves.
- full_schema[source]¶
dict – Same as schema, except that collections are fully defined instead of merely referenced in the “collections” sub-object.
..webservices reference: /docs/web-services.html
- anonymous_reads = True
- collections = ()¶
- connection = 'default'
- create_database()[source]¶
Create the db for the application.
If the db exists, log a warning.
Returns: None
- create_tables(*args, **kwargs)[source]¶
Create tables in the db for all collections in the application.
If the table exists, log a warning.
Signals sent:
- pre_create_tables(instance=``self``, args=``args``, kwargs=``kwargs``)
- Sent before tables are created
- post_create_tables(instance=``self``)
- Sent after the tables are created
Parameters: - *args – Sent to collection.create_table as vargs.
- **kwargs – Sent to collection.create_table as keyword args.
Returns: None
- db = 'default'
- definitions = {}
- drop_database()[source]¶
Drop the db for the application.
If the db exists, log a warning.
Returns: None
- drop_tables(*args, **kwargs)[source]¶
Create tables in the db for all collections in the application.
If the table exists, log a warning.
Signals sent:
- pre_delete_tables(instance=``self``, args=``args``, kwargs=``kwargs``)
- Sent before tables are created
- post_delete_tables(instance=``self``)
- Sent after the tables are created
Parameters: - *args – Sent to collection.delete_table as vargs.
- **kwargs – Sent to collection.delete_table as keyword args.
Returns: None
- exposed_methods = {}¶
- full_schema[source]
- help(out=None, initial_heading_level=0)[source]¶
Return full reStructuredText help for this class.
Parameters: - out (io) – An output, usually io.StringIO
- initial_heading_level (int) – 0-5, default 0. The heading level to start at, in case this is being included as part of a broader help scheme.
Returns: reStructuredText help.
Return type: (str)
- schema[source]
- schema_url[source]
- slug = None
- title = None¶
- url[source]
- exception sondra.application.ApplicationException[source]¶
Bases: builtins.Exception
Represents a misconfiguration in an Application class definition