Documentation for python-stdnet's DEVELOPMENT version. Get the release docs here.

API

High Level Functions

getdb

stdnet.getdb(backend=None, **kwargs)

get a BackendDataServer.

getcache

Interfaces

Backend data server

class stdnet.BackendDataServer(name=None, address=None, charset=None, namespace='', **params)

Generic interface for a backend databases.

It should not be initialised directly, the getdb() function should be used instead.

Parameters:
  • name – name of database, such as redis, mongo, etc..
  • address – network address of database server.
  • charset – optional charset encoding. Default utf-8.
  • namespace – optional namespace for keys.
  • params – dictionary of configuration parameters.

ATTRIBUTES

name

name of database

connection_string

The connection string for this backend. By calling getdb() with this value, one obtain a BackendDataServer connected to the same database as this instance.

client

The client handler for the backend database.

Query

The BackendQuery class for this backend.

default_manager

The default model Manager for this backend. If not provided, the stdnet.odm.Manager is used. Default None.

basekey(meta, *args)

Calculate the key to access model data.

Parameters:
  • meta – a stdnet.odm.Metaclass.
  • args – optional list of strings to prepend to the basekey.
Return type:

a native string

disconnect()

Disconnect the connection.

make_objects(meta, data, related_fields=None)

Generator of stdnet.odm.StdModel instances with data from database.

Parameters:
  • meta – instance of model stdnet.odm.Metaclass.
  • data – iterator over instances data.
structure(instance, client=None)

Create a backend stdnet.odm.Structure handler.

Parameters:
is_async()

Check if the backend handler is asynchronous.

setup_model(meta)

Invoked when registering a model with a backend. This is a chance to perform model specific operation in the server. For example, mongo db ensure indices are created.

clean(meta)

Remove temporary keys for a model

ping()

Ping the server

instance_keys(obj)

Return a list of database keys used by instance obj

auto_id_to_python(value)

Return a proper python value for the auto id.

setup_connection(address)

Callback during initialization. Implementation should override this function for customizing their handling of connection parameters. It must return a instance of the backend handler.

execute_session(session, callback)

Execute a stdnet.odm.Session in the backend server.

model_keys(meta)

Return a list of database keys used by model model

flush(meta=None)

Flush the database or drop all instances of a model/collection

Cache Server

Backend Structure

class stdnet.BackendStructure(instance, backend, client)

Interface for stdnet.odm.Structure backends.

instance

The stdnet.odm.Structure which this backend represents.

backend

The BackendDataServer

client

The client of the BackendDataServer

Asynchronous Components

Table Of Contents

Previous topic

Backend Servers

Next topic

Redis

This Page