1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2026-06-14 06:20:48 +02:00

EmComponent and EmClass, first draft

This commit is contained in:
ArnAud 2015-05-22 14:33:33 +02:00
commit cc50da7658
2 changed files with 77 additions and 14 deletions

41
em/class.py Normal file
View file

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
## Manipulate Classes of the Editorial Model
#
# Create classes of object
# @see EmClass, EmType, EmFieldGroup, EmField
import EmComponent
class EmClass(EmComponent)
def __init(id_or_name):
self.table = 'em_class'
pass
## create a new class
# @param str name name of the new class
# @param EmClasstype class_type type of the class
def create(self, name, class_type):
pass
## retrieve list field_groups of this class
# @return [EmFieldGroup]
def field_groups():
pass
def fields():
pass
def types():
pass
## add a new EmType that can ben linked to this class
# @param EmType t type to link
# @return bool success
def link_type(t <EmType>):
pass
## retrieve list of EmType that are linked to this class
# @return [EmType]
def linked_types():
pass

View file

@ -8,7 +8,7 @@
class EmComponent(object):
## instaciate an EmComponent
# @param id_or_name <int> || <str>
# @param int|str id_or_name
# @raise TypeError
def __init(id_or_name):
if id_or_name is int:
@ -25,28 +25,50 @@ class EmComponent(object):
where = "name = " + db.quote(self.name)
else:
where = "id = " + self.id
row = db.query(where)
if not row:
# could have two possible Error message for id and for name
raise EmComponentNotExistError("Bad id_or_name: could not find the component")
self.name = row.name
self.rank = row.rank
self.date_update = row.date_update
self.date_create <datetime object>
self.date_create = row.date_create
self.string <MlString object> : string representation of the component
self.help <MlString object> : help string
self.icon <string> : path to the icon (should be id_global of EmFile object)
@static_method
def id_from_name(name):
## write the representation of the component in the database
# @return bool
def save(self):
pass
@staticmethod
def create(name <string>, parent_component <EmComponent object>)
def save(self)
def delete(self)
def modify_rank(self)
def set_string(self, lang, texte)
def set_strings(self)
def get_string(self, lang)
## delete this component in the database
# @return bool
def delete(self):
pass
## change the rank of the component
# @param int new_rank new position
def modify_rank(self, new_rank):
pass
## set a string representation of the component for a given language
# @param str lang iso 639-2 representation of the language http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
# @param str text
# @return bool
def set_string(self, lang, text):
pass
## set the string representation of the component
# @param MlString ml_string strings for all language
# @return bool
def set_strings(self, ml_string):
pass
## get the string representation of the component for the given language
# @param str lang iso 639-2 representation of the language
# @return str
def get_string(self, lang):
pass