Brak opisu
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.

lodelsites_em.py 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/usr/bin/python3
  2. #-*- coding: utf-8 -*-
  3. from lodel.context import LodelContext
  4. LodelContext.init()
  5. from lodel.settings.settings import Settings as settings
  6. settings('globconf.d')
  7. from lodel.settings import Settings
  8. from lodel.editorial_model.components import *
  9. from lodel.editorial_model.exceptions import *
  10. from lodel.editorial_model.model import EditorialModel
  11. em = EditorialModel('LodelSites', 'LodelSites editorial model')
  12. base_group = em.new_group(
  13. 'base_group',
  14. display_name = 'Base group',
  15. help_text = 'Base group that implements base EM features (like classtype)'
  16. )
  17. em_lodel_site = em.new_class(
  18. 'LodelSite',
  19. group = base_group
  20. )
  21. em_lodel_site.new_field(
  22. 'id',
  23. display_name = 'Site id',
  24. help_text = 'Numeric uniq ID for a Lodel site',
  25. group = base_group,
  26. data_handler = 'uniqid',
  27. internal = True
  28. )
  29. em_lodel_site.new_field(
  30. 'shortname',
  31. display_text = 'lodelSiteShortName',
  32. help_text = 'Lodel site short string identifier',
  33. group = base_group,
  34. data_handler = 'regex',
  35. max_length = 16,
  36. regex = '^[0-9a-z_-]+$',
  37. uniq = True
  38. )
  39. em_lodel_site.new_field(
  40. 'name',
  41. display_name = 'lodelSiteName',
  42. help_text = 'Lodel site full name',
  43. group = base_group,
  44. data_handler = 'varchar'
  45. )
  46. em_lodel_site.new_field(
  47. 'extensions',
  48. display_text = 'lodeSiteExtensions',
  49. help_text = 'Lodel site extensions',
  50. group = base_group,
  51. data_handler = 'varcharlist',
  52. delimiter = ' '
  53. )
  54. em_lodel_site.new_field(
  55. 'em_groups',
  56. display_text = 'lodelSiteEmGroups',
  57. help_text = 'Lodel site EM groups',
  58. group = base_group,
  59. data_handler = 'text',
  60. )
  61. #
  62. #This class & fields becomes mandatory when the auth process was integrated
  63. #into lodel2 engine
  64. #
  65. user_group = em.new_group(
  66. 'users',
  67. display_name = 'Lodel users',
  68. help_text = 'Group that handle users en perm'
  69. )
  70. user = em.new_class(
  71. 'User',
  72. group = user_group
  73. )
  74. user.new_field(
  75. 'login',
  76. display_name = 'User login',
  77. help_text = 'login',
  78. group = user_group,
  79. data_handler = 'varchar',
  80. primary_key = True
  81. )
  82. user.new_field(
  83. 'password',
  84. display_name = 'Password',
  85. help_text = 'User password',
  86. group = user_group,
  87. data_handler = 'password',
  88. )
  89. pickle_file_path = 'examples/lodelsites_em.pickle'
  90. xml_file_path = 'examples/lodelsites_em.xml'
  91. em.save('xmlfile', filename=xml_file_path)
  92. em.save('picklefile', filename=pickle_file_path)