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.

__init__.py 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. __plugin_type__ = 'datasource'
  20. __plugin_name__ = 'mongodb_datasource'
  21. __version__ = '0.0.1'
  22. __plugin_type__ = 'datasource'
  23. __loader__ = "main.py"
  24. __confspec__ = "confspec.py"
  25. __author__ = "Lodel2 dev team"
  26. __fullname__ = "MongoDB plugin"
  27. ## @brief Activates the plugin
  28. #
  29. # @note This function can contain specific actions (like checks, etc ...) in
  30. # order to activate the plugin.
  31. #
  32. # @return bool|str : True if all the checks are OK, an error message if not
  33. def _activate():
  34. from lodel import buildconf # NOTE : this one do not have to pass through the context
  35. return buildconf.PYMONGO
  36. #
  37. # Doxygen comments
  38. #
  39. ## @defgroup plugin_mongodb_datasource MongoDB datasource plugin
  40. # @brief Doc about mongodb datasource
  41. ## @page plugin_mongodb_backref_complexity Reflexion on back reference complexity
  42. # @ingroup plugin_mongodb_bref_op
  43. #
  44. # There is a huge performance issue in the way we implemented references and
  45. # back references for mongodb datasource :
  46. #
  47. # For each write action (update, delete or insert) we HAVE TO run a select
  48. # on all concerned LeObject instances. Those methods' headers look like
  49. # <pre>def write_action(target_cls, filters, [datas])</pre>.
  50. #
  51. # We have no idea if all the modified objects are of the target class (they
  52. # can be of any target's child classes). So that means we have no idea of the
  53. # @ref base_classes.Reference "References" that will be modified by the action.
  54. #
  55. # Another problem is that when we run an update or a delete we have no idea
  56. # of the values that will be updated or deleted (we do not have the concerned
  57. # instances datas). As a result we cannot replace or delete the concerned
  58. # back references.
  59. #
  60. # In term of complexity the number of DB query looks like :
  61. # <pre>
  62. # With n the number of instances to modify :
  63. # queryO(n) ~= 2n ( n * select + n * update )
  64. # </pre>
  65. #
  66. # But it can go really bad, really fast if we take in consideration that
  67. # query's can be done on mixed classes or abstract classes. With :
  68. # - n : the number of LeObect child classes represented by the abstract class
  69. # - m : the number of LeObject child classes for each n
  70. # - o : the number of concerned back_reference classes for each m
  71. #
  72. # <pre>queryO(n,m,o) ~= n + (n*m) + (n*m*o) => n + n*m select and n*m*o updates</pre>
  73. #
  74. # All of this is really sad especially as the update and the delete will be
  75. # run on LeObject instances....
  76. #