formal package¶
Submodules¶
formal.database module¶
Changes notice¶
This file has been changed by the Hackerfleet Community and this notice has been added in accordance to the Apache License 2.0
Description¶
Interface to pymongo and sqlalchemy
-
exception
NotConnected
[source]¶ Bases:
RuntimeError
Raised when a query is made without being connected to the database
-
connect
(database, username=None, password=None, host='localhost', port=27017)[source]¶ Connect to a database.
formal.exceptions module¶
Changes notice¶
This file has been changed by the Hackerfleet Community and this notice has been added in accordance to the Apache License 2.0
-
exception
InvalidReloadException
[source]¶ Bases:
Exception
Thrown when we attempt to call reload() on a model that is not in the database.
formal.model_base module¶
Changes notice¶
This file has been changed by the Hackerfleet Community and this notice has been added in accordance to the Apache License 2.0
-
class
ModelBase
(original_fields=None, from_find=False, *args, **kwargs)[source]¶ Bases:
object
This class serves as a base class for the main model types in formal: Model, and TwistedModel.
-
__init__
(original_fields=None, from_find=False, *args, **kwargs)[source]¶ Creates an instance of the object.
-
cast
(fields, schema=None)[source]¶ Cast the fields from Mongo into our format - necessary to convert floats into ints since Javascript doesn’t support ints.
-
formal.model_mongodb module¶
Changes notice¶
This file has been changed by the Hackerfleet Community and this notice has been added in accordance to the Apache License 2.0
-
class
Model
(original_fields=None, from_find=False, *args, **kwargs)[source]¶ Bases:
formal.model_base.ModelBase
The Mongodb object model class
-
classmethod
bulk_create
(objects, *args, **kwargs)[source]¶ Create a number of objects (yay performance).
-
classmethod
collection
()[source]¶ Get the pymongo collection object for this model. Useful for features not supported by formal like aggregate queries and map-reduce.
-
classmethod
count
(object_filter=None)[source]¶ Counts the number of items: - not the same as pymongo’s count, this is the equivalent to:
-
classmethod
find
(*args, **kwargs)[source]¶ Grabs a set of elements from the DB. Note: This returns a generator, so you can’t to do an efficient count. To get a count, use the count() function which accepts the same arguments as find() with the exception of non-query fields like sort, limit, skip.
-
classmethod
formal.model_sqlalchemy module¶
SQL Support for Formal
-
class
Model
(original_fields=None, from_find=False, *args, **kwargs)[source]¶ Bases:
object
The SQL object model class
-
__init__
(original_fields=None, from_find=False, *args, **kwargs)[source]¶ Creates an instance of the object.
-
classmethod
bulk_create
(objects, *args, **kwargs)[source]¶ Create a number of objects (yay performance).
-
cast
(fields, schema=None)[source]¶ Cast the fields from Mongo into our format - necessary to convert floats into ints since Javascript doesn’t support ints.
-
classmethod
collection
()[source]¶ Get the pymongo collection object for this model. Useful for features not supported by formal like aggregate queries and map-reduce.
-
classmethod
database_name
()[source]¶ Get the database associated with this class. Meant to be overridden in subclasses.
-
classmethod
find
(*args, **kwargs)[source]¶ Grabs a set of elements from the DB. Note: This returns a generator, so you can’t do an efficient count. To get a count, use the count() function which accepts the same arguments as find() with the exception of non-query fields like sort, limit, skip.
-