50 rmode.set_rtag('link', 'wf_info_for', 'subject') |
50 rmode.set_rtag('link', 'wf_info_for', 'subject') |
51 |
51 |
52 @classmethod |
52 @classmethod |
53 def registered(cls, registry): |
53 def registered(cls, registry): |
54 """build class using descriptor at registration time""" |
54 """build class using descriptor at registration time""" |
55 super(AutomaticEntityForm, cls).registered(registry) |
55 super(EditBox, cls).registered(registry) |
56 cls.init_rtags_mode() |
56 cls.init_rtags_mode() |
57 return cls |
57 return cls |
58 |
58 |
59 @classmethod |
59 @classmethod |
60 def init_rtags_mode(cls): |
60 def init_rtags_mode(cls): |
68 X, Y = eschema, tschema |
68 X, Y = eschema, tschema |
69 card = rschema.rproperty(X, Y, 'cardinality')[0] |
69 card = rschema.rproperty(X, Y, 'cardinality')[0] |
70 else: |
70 else: |
71 X, Y = tschema, eschema |
71 X, Y = tschema, eschema |
72 card = rschema.rproperty(X, Y, 'cardinality')[1] |
72 card = rschema.rproperty(X, Y, 'cardinality')[1] |
73 if not cls.rmode.rtag(role, rschema, X, Y): |
73 if not cls.rmode.rtag(rschema, role, X, Y): |
74 if card in '?1': |
74 if card in '?1': |
75 # by default, suppose link mode if cardinality doesn't allow |
75 # by default, suppose link mode if cardinality doesn't allow |
76 # more than one relation |
76 # more than one relation |
77 mode = 'link' |
77 mode = 'link' |
78 elif rschema.rproperty(X, Y, 'composite') == role: |
78 elif rschema.rproperty(X, Y, 'composite') == role: |
79 # if self is composed of the target type, create mode |
79 # if self is composed of the target type, create mode |
80 mode = 'create' |
80 mode = 'create' |
81 else: |
81 else: |
82 # link mode by default |
82 # link mode by default |
83 mode = 'link' |
83 mode = 'link' |
84 cls.rmode.set_rtag(category, role, rschema, X, Y) |
84 cls.rmode.set_rtag(mode, rschema, role, X, Y) |
85 |
85 |
86 @classmethod |
86 @classmethod |
87 def relation_mode(cls, rtype, etype, targettype, role='subject'): |
87 def relation_mode(cls, rtype, etype, targettype, role='subject'): |
88 """return a string telling if the given relation is usually created |
88 """return a string telling if the given relation is usually created |
89 to a new entity ('create' mode) or to an existant entity ('link' mode) |
89 to a new entity ('create' mode) or to an existant entity ('link' mode) |
90 """ |
90 """ |
91 return cls.rmode.rtag(role, rtype, etype, targettype) |
91 return cls.rmode.rtag(rtype, role, etype, targettype) |
92 |
92 |
93 |
93 |
94 def call(self, **kwargs): |
94 def call(self, **kwargs): |
95 _ = self.req._ |
95 _ = self.req._ |
96 title = _(self.title) |
96 title = _(self.title) |