Browse Source

List of existting datahandlers

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

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

253
             raise NameError("No data handlers named '%s'" % (name,))
253
             raise NameError("No data handlers named '%s'" % (name,))
254
         return all_handlers[name]
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
     ## @brief Return the module name to import in order to use the datahandler
271
     ## @brief Return the module name to import in order to use the datahandler
257
     # @param data_handler_name str : Data handler name
272
     # @param data_handler_name str : Data handler name
258
     # @return a str
273
     # @return a str

Loading…
Cancel
Save