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 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. # @param filters
  14. # @param relational_filters
  15. def update(self, lodel_id, checked_data, filters, relational_filters):
  16. print ("DummyDatasource.update: ", lodel_id, checked_data, filters, relational_filters)
  17. return True
  18. ## @brief create a new LeObject
  19. # @param letype LeType
  20. # @param leclass LeClass
  21. # @param data dict: a dictionnary of field:value to save
  22. # @return lodel_id int: new lodel_id of the newly created LeObject
  23. def insert(self, letype, leclass, **datas):
  24. print("DummyDatasource.insert: ", letype, leclass, datas)
  25. return 42
  26. ## @brief delete an existing LeObject
  27. # @param lodel_id int | (int): lodel_id of the object(s) to delete
  28. # @param filters list : list of tuples formatted as (FIELD, OPERATOR, VALUE)
  29. # @param relational_filters list
  30. # @return okay bool: True on success, it will raise on failure
  31. def delete(self, lodel_id, filters, relational_filters):
  32. print("DummyDatasource.delete: ", lodel_id)
  33. return True
  34. ## @brief search for a collection of objects
  35. # @param emclass LeClass : LeClass instance
  36. # @param emtype LeType : LeType instance
  37. # @param field_list list : list of fields to get from the datasource
  38. # @param filters list : list of tuples formatted as (FIELD, OPERATOR, VALUE)
  39. # @param relational_filters list
  40. # @return responses ({string:*}): a list of dict with field:value
  41. def get(self, emclass, emtype, field_list, filters, relational_filters):
  42. print("DummyDatasource.get: ", emclass, emtype, field_list, filters, relational_filters)
  43. return []