1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2025-12-03 17:26:54 +01:00

Forgotten files

This commit is contained in:
Yann 2016-06-10 14:38:52 +02:00
commit ca3fa4cc27
4 changed files with 93 additions and 0 deletions

27
lodel/exceptions.py Normal file
View file

@ -0,0 +1,27 @@
#-*- coding: utf-8 -*-
class LodelException(Exception):
pass
class LodelExceptions(LodelException):
##@brief Instanciate a new exceptions handling multiple exceptions
# @param msg str : Exception message
# @param exceptions dict : A list of data check Exception with concerned field (or stuff) as key
def __init__(self, msg = "Unknow error", exceptions = None):
self._msg = msg
self._exceptions = dict() if exceptions is None else exceptions
def __repr__(self):
return self.__str__()
def __str__(self):
msg = self._msg
for_iter = self._exceptions.items() if isinstance(self._exceptions, dict) else enumerate(self.__exceptions)
for obj, expt in for_iter:
msg += "\n\t{expt_obj} : ({expt_name}) {expt_msg}; ".format(
expt_obj = obj,
expt_name=expt.__class__.__name__,
expt_msg=str(expt)
)
return msg

0
plugins/__init__.py Normal file
View file

View file

@ -0,0 +1,53 @@
#-*- coding:utf-8 -*-
class DummyDatasource(object):
def __init__(self, *conn_args, **conn_kwargs):
self.conn_args = conn_args
self.conn_kwargs = conn_kwargs
## @brief returns a selection of documents from the datasource
# @param target_cls Emclass
# @param field_list list
# @param filters list : List of filters
# @param rel_filters list : List of relational filters
# @param order list : List of column to order. ex: order = [('title', 'ASC'),]
# @param group list : List of tupple representing the column to group together. ex: group = [('title', 'ASC'),]
# @param limit int : Number of records to be returned
# @param offset int: used with limit to choose the start record
# @param instanciate bool : If true, the records are returned as instances, else they are returned as dict
# @return list
def select(self, target_cls, field_list, filters, rel_filters=None, order=None, group=None, limit=None, offset=0,
instanciate=True):
pass
##@brief Deletes records according to given filters
#@param target Emclass : class of the record to delete
#@param filters list : List of filters
#@param relational_filters list : List of relational filters
#@return int : number of deleted records
def delete(self, target, filters, relational_filters):
pass
## @brief updates records according to given filters
#@param target Emclass : class of the object to insert
#@param filters list : List of filters
#@param rel_filters list : List of relational filters
#@param upd_datas dict : datas to update (new values)
#@return int : Number of updated records
def update(self, target, filters, relational_filters, upd_datas):
pass
## @brief Inserts a record in a given collection
# @param target Emclass : class of the object to insert
# @param new_datas dict : datas to insert
# @return the inserted uid
def insert(self, target, new_datas):
pass
## @brief Inserts a list of records in a given collection
# @param target Emclass : class of the objects inserted
# @param datas_list list : list of dict
# @return list : list of the inserted records' ids
def insert_multi(self, target, datas_list):
pass

View file

@ -0,0 +1,13 @@
#-*- coding: utf-8 -*-
##@brief Abtract class for migration handlers
class DummyMigrationHandler(object):
def __init__(self, *args, **kwargs):
pass
def register_change(self, model, uid, initial_state, new_state):
pass
def register_model_state(self, em, state_hash):
pass