説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

component.py 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # -*- coding: utf-8 -*-
  2. ## Main object to manipulate Editorial Model
  3. #
  4. # parent of all other EM editing classes
  5. # @see EmClass, EmType, EmFieldGroup, EmField
  6. class EmComponent(object):
  7. ## instaciate an EmComponent
  8. # @param id_or_name <int> || <str>
  9. # @raise TypeError
  10. def __init(id_or_name):
  11. if id_or_name is int:
  12. self.id = id_or_name
  13. else if id_or_name is str:
  14. self.name = id_or_name
  15. self.populate()
  16. else:
  17. raise TypeError('Bad argument: expecting <int> or <str>')
  18. ## Lookup in the database properties of the object
  19. def populate(self):
  20. if self.id is None:
  21. where = "name = " + db.quote(self.name)
  22. else:
  23. where = "id = " + self.id
  24. row = db.query(where)
  25. if not row:
  26. # could have two possible Error message for id and for name
  27. raise EmComponentNotExistError("Bad id_or_name: could not find the component")
  28. self.name = row.name
  29. self.rank = row.rank
  30. self.date_update = row.date_update
  31. self.date_create <datetime object>
  32. self.string <MlString object> : string representation of the component
  33. self.help <MlString object> : help string
  34. self.icon <string> : path to the icon (should be id_global of EmFile object)
  35. @static_method
  36. def id_from_name(name):
  37. @staticmethod
  38. def create(name <string>, parent_component <EmComponent object>)
  39. def save(self)
  40. def delete(self)
  41. def modify_rank(self)
  42. def set_string(self, lang, texte)
  43. def set_strings(self)
  44. def get_string(self, lang)