Browse Source

List of existting datahandlers

prieto 7 years ago
parent
commit
a958d9cf1f
2 changed files with 20 additions and 5 deletions
  1. 5
    5
      editorial_models/em_simple.py
  2. 15
    0
      lodel/leapi/datahandlers/base_classes.py

+ 5
- 5
editorial_models/em_simple.py View File

@@ -272,7 +272,7 @@ article.new_field(  'author_note',
272 272
                     group = editorial_group,
273 273
                     data_handler = 'text'
274 274
 )
275
-# Classe Review 
275
+# Classe Review
276 276
 review = em.new_class( 'review',
277 277
                         display_name = 'Review',
278 278
                         group = editorial_group,
@@ -439,7 +439,7 @@ issue.new_field(    'print_pub_date',
439 439
                     },
440 440
                   data_handler = 'datetime',
441 441
                   group = editorial_group,
442
-)     
442
+)
443 443
 issue.new_field(    'e_pub_date',
444 444
                     display_name = {
445 445
                         'eng': 'Electronic publication date',
@@ -447,7 +447,7 @@ issue.new_field(    'e_pub_date',
447 447
                     },
448 448
                   data_handler = 'datetime',
449 449
                   group = editorial_group,
450
-)  
450
+)
451 451
 issue.new_field(    'abstract',
452 452
                     display_name = {
453 453
                         'eng': 'Abstract',
@@ -455,7 +455,7 @@ issue.new_field(    'abstract',
455 455
                     },
456 456
                   data_handler = 'text',
457 457
                   group = editorial_group,
458
-) 
458
+)
459 459
 issue.new_field(    'collection',
460 460
                     display_name = {
461 461
                         'eng': 'Collection',
@@ -691,7 +691,7 @@ user.new_field(
691 691
     group = user_group, data_handler = 'password', internal = False)
692 692
 
693 693
 
694
-#em.save('xmlfile', filename = 'examples/em_test.xml')
694
+em.save('xmlfile', filename = 'editorial_models/em_simple.xml')
695 695
 pickle_file = 'examples/em_simple.pickle'
696 696
 em.save('picklefile', filename = pickle_file)
697 697
 print("Output written in %s" % pickle_file)

+ 15
- 0
lodel/leapi/datahandlers/base_classes.py View File

@@ -253,6 +253,21 @@ class DataHandler(MlNamedObject):
253 253
             raise NameError("No data handlers named '%s'" % (name,))
254 254
         return all_handlers[name]
255 255
 
256
+    # @brief List all datahandlers
257
+    # @return
258
+    @classmethod
259
+    def list_data_handlers(cls):
260
+        cls.load_base_handlers()
261
+        all_handlers = dict(cls._base_handlers, **cls.__custom_handlers)
262
+        list_dh = dict()
263
+        for hdl in all_handlers:
264
+            list_dh[hdl] = (display_name=hdl.display_name, \
265
+                            help_text=hdl.help_text, nullable=hdl.nullable, \
266
+                            internal=hdl.internal, immutable=hdl.immutable, \
267
+                            primary_key=hdl.primary_key, options=self.options_spec)
268
+
269
+        return list_dh
270
+
256 271
     ## @brief Return the module name to import in order to use the datahandler
257 272
     # @param data_handler_name str : Data handler name
258 273
     # @return a str

Loading…
Cancel
Save