Açıklama Yok
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.

component.py 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 int|str id_or_name
  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 = row.date_create
  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. ## write the representation of the component in the database
  36. # @return bool
  37. def save(self):
  38. pass
  39. ## delete this component in the database
  40. # @return bool
  41. def delete(self):
  42. pass
  43. ## change the rank of the component
  44. # @param int new_rank new position
  45. def modify_rank(self, new_rank):
  46. pass
  47. ## set a string representation of the component for a given language
  48. # @param str lang iso 639-2 representation of the language http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
  49. # @param str text
  50. # @return bool
  51. def set_string(self, lang, text):
  52. pass
  53. ## set the string representation of the component
  54. # @param MlString ml_string strings for all language
  55. # @return bool
  56. def set_strings(self, ml_string):
  57. pass
  58. ## get the string representation of the component for the given language
  59. # @param str lang iso 639-2 representation of the language
  60. # @return str
  61. def get_string(self, lang):
  62. pass