No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dummy.py 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #-*- coding: utf-8 -*-
  2. ## dummy datasource for LeObject
  3. # This class has to be extended to apply to a real datasource
  4. # But it can be used as an empty and debug datasource
  5. class DummyDatasource(object):
  6. def __init__(self, module=None, *conn_args, **conn_kargs):
  7. self.module = module
  8. self.conn_args = conn_args
  9. self.conn_kargs = conn_kargs
  10. ## @brief update an existing LeObject
  11. # @param lodel_id (int) : list of lodel_id
  12. # @param checked_data dict
  13. def update(self, lodel_id, checked_data):
  14. print ("DummyDatasource.update: ", lodel_id, checked_data)
  15. return True
  16. ## @brief create a new LeObject
  17. # @param typename string
  18. # @param classname string
  19. # @param data dict: a dictionnary of field:value to save
  20. # @return lodel_id int: new lodel_id of the newly created LeObject
  21. def insert(self, typename, classname, **datas):
  22. print("DummyDatasource.insert: ", typename, classname, datas)
  23. return 42
  24. ## @brief delete an existing LeObject
  25. # @param lodel_id int | (int): lodel_id of the object(s) to delete
  26. # @return okay bool: True on success, it will raise on failure
  27. def delete(self, lodel_id):
  28. print("DummyDatasource.delete: ", lodel_id)
  29. return True
  30. ## @brief search for a collection of objects
  31. # @param emclass LeClass : LeClass instance
  32. # @param emtype LeType : LeType instance
  33. # @param field_list list : list of fields to get from the datasource
  34. # @param filters list : list of tuples formatted as (FIELD, OPERATOR, VALUE)
  35. # @param relational_filters
  36. # @return responses ({string:*}): a list of dict with field:value
  37. def get(self, emclass, emtype, field_list, filters, relational_filters):
  38. print("DummyDatasource.get: ", emclass, emtype, field_list, filters, relational_filters)
  39. return []