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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. ##@defgroup lodel2_leapi LeAPI
  2. #@brief Lodel2 Editorial API
  3. #
  4. #Provide access to datas via objects as defined in the Editorial Model
  5. ##@package lodel.leapi
  6. #@brief Lodel2 Editorial API
  7. #
  8. # Defines an API to access to objects as described by
  9. #@ref lodel.editorial_model "Editorial Model"
  10. ##@page lodel2_leapi_page LeAPI
  11. #@ingroup lodel2_leapi
  12. #
  13. # @section lodel2_leapi_base LeAPI (Lodel Editorial API)
  14. #
  15. # LeAPI is an API that provide access to datas as defined in an
  16. #@ref lodel2_em "Editorial Model".
  17. #
  18. #@subsection lodel2_leapi_gen LeAPI dynamic code & LeFactory
  19. #
  20. #LeAPI python code is programmaticaly generated by
  21. #@ref lodel.leapi.lefactory "LeFactory". LeFactory generates
  22. #@ref lodel.leapi.leobject.LeObject "LeObject" child classes.
  23. #
  24. #@par Example
  25. #<pre>
  26. #
  27. # from lodel.leapi.leobject import LeObject
  28. # from lodel.leapi.datahandlers.base_classes import DataField
  29. # from lodel.plugin.hooks import LodelHook
  30. #
  31. # class Abstract_Object(LeObject):
  32. # _abstract = True
  33. # _fields = None
  34. # _uid = []
  35. # _ro_datasource = None
  36. # _rw_datasource = None
  37. # _datasource_name = 'default'
  38. # _child_classes = None
  39. #
  40. #
  41. # class User(LeObject):
  42. # _abstract = False
  43. # _fields = None
  44. # _uid = ['id']
  45. # _ro_datasource = None
  46. # _rw_datasource = None
  47. # _datasource_name = 'default'
  48. # _child_classes = None
  49. #
  50. #
  51. # class Object(Abstract_Object):
  52. # _abstract = True
  53. # _fields = None
  54. # _uid = ['lodel_id']
  55. # _ro_datasource = None
  56. # _rw_datasource = None
  57. # _datasource_name = 'default'
  58. # _child_classes = None
  59. #
  60. #
  61. # class Entry(Object):
  62. # _abstract = True
  63. # _fields = None
  64. # _uid = ['lodel_id']
  65. # _ro_datasource = None
  66. # _rw_datasource = None
  67. # _datasource_name = 'default'
  68. # _child_classes = None
  69. #
  70. #
  71. # class Entitie(Object):
  72. # _abstract = True
  73. # _fields = None
  74. # _uid = ['lodel_id']
  75. # _ro_datasource = None
  76. # _rw_datasource = None
  77. # _datasource_name = 'default'
  78. # _child_classes = None
  79. #
  80. #
  81. # class Person(Object):
  82. # _abstract = False
  83. # _fields = None
  84. # _uid = ['lodel_id']
  85. # _ro_datasource = None
  86. # _rw_datasource = None
  87. # _datasource_name = 'default'
  88. # _child_classes = None
  89. #
  90. # class Text(Entitie):
  91. # _abstract = True
  92. # _fields = None
  93. # _uid = ['lodel_id']
  94. # _ro_datasource = None
  95. # _rw_datasource = None
  96. # _datasource_name = 'default'
  97. # _child_classes = None
  98. #
  99. #
  100. # class Publication(Entitie):
  101. # _abstract = False
  102. # _fields = None
  103. # _uid = ['lodel_id']
  104. # _ro_datasource = None
  105. # _rw_datasource = None
  106. # _datasource_name = 'default'
  107. # _child_classes = None
  108. #
  109. # Abstract_Object._set__fields({})
  110. # Abstract_Object._child_classes = (Section, Text, Object, Entry, Collection, Text_Person, Entitie, Indextheme, Person, Indexabs, Publication, Subsection,)
  111. # User._set__fields({
  112. # 'firstname': DataField.from_name('varchar')(**{ 'internal': False }),
  113. # 'lastname': DataField.from_name('varchar')(**{ 'internal': False }),
  114. # 'classname': DataField.from_name('LeobjectSubclassIdentifier')(**{ 'internal': True }),
  115. # 'login': DataField.from_name('varchar')(**{ 'internal': True, 'uniq': True }),
  116. # 'id': DataField.from_name('uniqid')(**{ 'internal': True }),
  117. # 'password': DataField.from_name('password')(**{ 'internal': False })})
  118. # User._child_classes = tuple()
  119. # Object._set__fields({
  120. # 'date_update': DataField.from_name('datetime')(**{ 'now_on_update': True, 'internal': True }),
  121. # 'lodel_id': DataField.from_name('uniqid')(**{ 'internal': True }),
  122. # 'help_text': DataField.from_name('text')(**{ 'internal': True }),
  123. # 'date_create': DataField.from_name('datetime')(**{ 'internal': True, 'now_on_create': True })})
  124. # Object._child_classes = (Section, Text, Entry, Collection, Text_Person, Entitie, Indextheme, Person, Indexabs, Publication, Subsection,)
  125. # Entry._set__fields({
  126. # 'date_update': DataField.from_name('datetime')(**{ 'now_on_update': True, 'internal': True }),
  127. # 'lodel_id': DataField.from_name('uniqid')(**{ 'internal': True }),
  128. # 'help_text': DataField.from_name('text')(**{ 'internal': True }),
  129. # 'date_create': DataField.from_name('datetime')(**{ 'internal': True, 'now_on_create': True })})
  130. # Entry._child_classes = tuple()
  131. # Entitie._set__fields({
  132. # 'date_update': DataField.from_name('datetime')(**{ 'now_on_update': True, 'internal': True }),
  133. # 'lodel_id': DataField.from_name('uniqid')(**{ 'internal': True }),
  134. # 'help_text': DataField.from_name('text')(**{ 'internal': True }),
  135. # 'date_create': DataField.from_name('datetime')(**{ 'internal': True, 'now_on_create': True })})
  136. # Entitie._child_classes = (Section, Text, Text_Person, Collection, Publication, Subsection,)
  137. # Person._set__fields({
  138. # 'date_update': DataField.from_name('datetime')(**{ 'now_on_update': True, 'internal': True }),
  139. # 'firstname': DataField.from_name('varchar')(**{ }),
  140. # 'lodel_id': DataField.from_name('uniqid')(**{ 'internal': True }),
  141. # 'linked_texts': DataField.from_name('list')(**{ 'nullable': True, 'default': None, 'allowed_classes': [Text], 'back_reference': (Text, 'linked_persons') }),
  142. # 'help_text': DataField.from_name('text')(**{ 'internal': True }),
  143. # 'lastname': DataField.from_name('varchar')(**{ }),
  144. # 'fullname': DataField.from_name('Concat')(**{ 'field_list': ['firstname', 'lastname'], 'immutable': True }),
  145. # 'classname': DataField.from_name('LeobjectSubclassIdentifier')(**{ 'internal': True }),
  146. # 'alias': DataField.from_name('set')(**{ 'nullable': True, 'default': None, 'allowed_classes': [Person] }),
  147. # 'date_create': DataField.from_name('datetime')(**{ 'internal': True, 'now_on_create': True })})
  148. # Person._child_classes = tuple()
  149. # Text._set__fields({
  150. # 'date_update': DataField.from_name('datetime')(**{ 'now_on_update': True, 'internal': True }),
  151. # 'subtitle': DataField.from_name('varchar')(**{ 'nullable': True, 'default': None }),
  152. # 'lodel_id': DataField.from_name('uniqid')(**{ 'internal': True }),
  153. # 'help_text': DataField.from_name('text')(**{ 'internal': True }),
  154. # 'linked_persons': DataField.from_name('list')(**{ 'nullable': True, 'default': None, 'allowed_classes': [Person], 'back_reference': (Person, 'linked_texts') }),
  155. # 'indexes': DataField.from_name('list')(**{ 'nullable': True, 'default': None, 'allowed_classes': [Indexabs], 'back_reference': (Indexabs, 'texts') }),
  156. # 'title': DataField.from_name('varchar')(**{ 'nullable': True }),
  157. # 'date_create': DataField.from_name('datetime')(**{ 'internal': True, 'now_on_create': True })})
  158. # Text._child_classes = (Section, Subsection,)
  159. # Publication._set__fields({
  160. # 'date_update': DataField.from_name('datetime')(**{ 'now_on_update': True, 'internal': True }),
  161. # 'classname': DataField.from_name('LeobjectSubclassIdentifier')(**{ 'internal': True }),
  162. # 'lodel_id': DataField.from_name('uniqid')(**{ 'internal': True }),
  163. # 'collection': DataField.from_name('link')(**{ 'back_reference': (Collection, 'publications') }),
  164. # 'help_text': DataField.from_name('text')(**{ 'internal': True }),
  165. # 'date_create': DataField.from_name('datetime')(**{ 'internal': True, 'now_on_create': True })})
  166. # Publication._child_classes = tuple()
  167. #
  168. # #List of dynamically generated classes
  169. # dynclasses = [Abstract_Object, User, Object, Entry, Entitie, Person, Indexabs, Text, Publication, Collection, Indextheme, Text_Person, Section, Subsection]
  170. # #Dict of dynamically generated classes indexed by name
  171. # dynclasses_dict = {'Abstract_Object': Abstract_Object, 'User': User, 'Object': Object, 'Entry': Entry, 'Entitie': Entitie, 'Person': Person, 'Indexabs': Indexabs, 'Text': Text, 'Publication': Publication, 'Collection': Collection, 'Indextheme': Indextheme, 'Text_Person': Text_Person, 'Section': Section, 'Subsection': Subsection}
  172. #
  173. #
  174. # ##@brief Return a dynamically generated class given it's name
  175. # #@param name str : The dynamic class name
  176. # #@return False or a child class of LeObject
  177. # def name2class(name):
  178. # if name not in dynclasses_dict:
  179. # return False
  180. # return dynclasses_dict[name]
  181. #
  182. #
  183. # ##@brief Return a dynamically generated class given it's name
  184. # #@note Case insensitive version of name2class
  185. # #@param name str
  186. # #@retrun False or a child class of LeObject
  187. # def lowername2class(name):
  188. # name = name.lower()
  189. # new_dict = {k.lower():v for k,v in dynclasses_dict.items()}
  190. # if name not in new_dict:
  191. # return False
  192. # return new_dict[name]
  193. #
  194. #
  195. # ##@brief Trigger dynclasses datasources initialisation
  196. # @LodelHook("lodel2_plugins_loaded")
  197. # def lodel2_dyncode_datasources_init(self, caller, payload):
  198. # for cls in dynclasses:
  199. # cls._init_datasources()
  200. # from lodel.plugin.hooks import LodelHook
  201. # LodelHook.call_hook("lodel2_dyncode_loaded", __name__, dynclasses)
  202. #
  203. #
  204. #
  205. #</pre>
  206. #