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.

datasource.py 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #
  2. # This file is part of Lodel 2 (https://github.com/OpenEdition)
  3. #
  4. # Copyright (C) 2015-2017 Cléo UMS-3287
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as published
  8. # by the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. ## @package lodel.plugins.dummy_datasource.datasource This module contains the main class of the datasource, implementing the basic operations one can perform.
  20. from lodel.context import LodelContext
  21. LodelContext.expose_modules(globals(), {
  22. 'lodel.plugin.datasource_plugin': ['AbstractDatasource']})
  23. ## @brief Datasource class, inherited from @ref lodel.plugin.datasource.AbstractDatasource
  24. class DummyDatasource(AbstractDatasource):
  25. ##
  26. # @param conn_args list
  27. # @param conn_kwargs dict
  28. def __init__(self, *conn_args, **conn_kwargs):
  29. self.conn_args = conn_args
  30. self.conn_kwargs = conn_kwargs
  31. ## @brief Provides a new unique numeric ID
  32. # @param emcomp LeObject subclass (not instance) : The class against whom we have to be unique
  33. # @return an integer
  34. def new_numeric_id(self, emcomp):
  35. pass
  36. ## @brief returns a selection of documents from the datasource
  37. # @param target Emclass
  38. # @param field_list list
  39. # @param filters list : List of filters
  40. # @param relational_filters list : List of relational filters (default value : None)
  41. # @param order list : List of column to order. ex: order = [('title', 'ASC'),] (default value : None)
  42. # @param group list : List of tupple representing the column to group together. ex: group = [('title', 'ASC'),] (default value : None)
  43. # @param limit int : Number of records to be returned (default value : None)
  44. # @param offset int: used with limit to choose the start record (default value : 0)
  45. # @param instanciate bool : If true, the records are returned as instances, else they are returned as dict (default value : True)
  46. # @return list
  47. def select(self, target, field_list, filters, relational_filters=None, order=None, group=None, limit=None, offset=0,
  48. instanciate=True):
  49. pass
  50. ## @brief Deletes records according to given filters
  51. # @param target Emclass : class of the record to delete
  52. # @param filters list : List of filters
  53. # @param relational_filters list : List of relational filters
  54. # @return int : number of deleted records
  55. def delete(self, target, filters, relational_filters):
  56. return 0
  57. ## @brief updates records according to given filters
  58. # @param target Emclass : class of the object to insert
  59. # @param filters list : List of filters
  60. # @param relational_filters list : List of relational filters
  61. # @param upd_datas dict : datas to update (new values)
  62. # @return int : Number of updated records
  63. def update(self, target, filters, relational_filters, upd_datas):
  64. return 0
  65. ## @brief Inserts a record in a given collection
  66. # @param target Emclass : class of the object to insert
  67. # @param new_datas dict : datas to insert
  68. # @return the inserted uid
  69. def insert(self, target, new_datas):
  70. return 0
  71. ## @brief Inserts a list of records in a given collection
  72. # @param target Emclass : class of the objects inserted
  73. # @param datas_list list : list of dict
  74. # @return list : list of the inserted records' ids
  75. def insert_multi(self, target, datas_list):
  76. return 0