hapcat.types¶
Hapcat database model custom types.
-
class
hapcat.types.GUID(*args, **kwargs)[source]¶ Bases:
sqlalchemy.sql.type_api.TypeDecoratorA platform-independent GUID type.
This uses PostgreSQL’s UUID type, otherwise using CHAR(32), storing as stringified hex values.
This is taken from the SQLAlchemy examples with minor modifications.
-
__module__= 'hapcat.types'¶
-
impl¶ alias of
sqlalchemy.sql.sqltypes.CHAR
-
load_dialect_impl(dialect)[source]¶ Return a
TypeEngineobject corresponding to a dialect.This is an end-user override hook that can be used to provide differing types depending on the given dialect. It is used by the
TypeDecoratorimplementation oftype_engine()to help determine what type should ultimately be returned for a givenTypeDecorator.By default returns
self.impl.
-
process_bind_param(value, dialect)[source]¶ Receive a bound parameter value to be converted.
Subclasses override this method to return the value that should be passed along to the underlying
TypeEngineobject, and from there to the DBAPIexecute()method.The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.
This operation should be designed with the reverse operation in mind, which would be the process_result_value method of this class.
Parameters: - value – Data to operate upon, of any type expected by
this method in the subclass. Can be
None. - dialect – the
Dialectin use.
- value – Data to operate upon, of any type expected by
this method in the subclass. Can be
-
process_result_value(value, dialect)[source]¶ Receive a result-row column value to be converted.
Subclasses should implement this method to operate on data fetched from the database.
Subclasses override this method to return the value that should be passed back to the application, given a value that is already processed by the underlying
TypeEngineobject, originally from the DBAPI cursor methodfetchone()or similar.The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.
Parameters: - value – Data to operate upon, of any type expected by
this method in the subclass. Can be
None. - dialect – the
Dialectin use.
This operation should be designed to be reversible by the “process_bind_param” method of this class.
- value – Data to operate upon, of any type expected by
this method in the subclass. Can be
-