947 def relvoc_linkedto(entity, rtype, role): |
947 def relvoc_linkedto(entity, rtype, role): |
948 # first see if its specified by __linkto form parameters |
948 # first see if its specified by __linkto form parameters |
949 linkedto = entity.linked_to(rtype, role) |
949 linkedto = entity.linked_to(rtype, role) |
950 if linkedto: |
950 if linkedto: |
951 buildent = entity._cw.entity_from_eid |
951 buildent = entity._cw.entity_from_eid |
952 return [(buildent(eid).view('combobox'), eid) for eid in linkedto] |
952 return [(buildent(eid).view('combobox'), unicode(eid)) for eid in linkedto] |
953 return [] |
953 return [] |
954 |
954 |
955 def relvoc_init(entity, rtype, role, required=False): |
955 def relvoc_init(entity, rtype, role, required=False): |
956 # it isn't, check if the entity provides a method to get correct values |
956 # it isn't, check if the entity provides a method to get correct values |
957 vocab = [] |
957 vocab = [] |
958 if not required: |
958 if not required: |
959 vocab.append(('', INTERNAL_FIELD_VALUE)) |
959 vocab.append(('', INTERNAL_FIELD_VALUE)) |
960 # vocabulary doesn't include current values, add them |
960 # vocabulary doesn't include current values, add them |
961 if entity.has_eid(): |
961 if entity.has_eid(): |
962 rset = entity.related(rtype, role) |
962 rset = entity.related(rtype, role) |
963 vocab += [(e.view('combobox'), e.eid) for e in rset.entities()] |
963 vocab += [(e.view('combobox'), unicode(e.eid)) for e in rset.entities()] |
964 return vocab |
964 return vocab |
965 |
965 |
966 def relvoc_unrelated(entity, rtype, role, limit=None): |
966 def relvoc_unrelated(entity, rtype, role, limit=None): |
967 if isinstance(rtype, basestring): |
967 if isinstance(rtype, basestring): |
968 rtype = entity._cw.vreg.schema.rschema(rtype) |
968 rtype = entity._cw.vreg.schema.rschema(rtype) |
1048 if field.value in searchedvalues: |
1048 if field.value in searchedvalues: |
1049 form.root_form.remove_field(field) |
1049 form.root_form.remove_field(field) |
1050 form.formvalues[(self, form)] = value |
1050 form.formvalues[(self, form)] = value |
1051 |
1051 |
1052 def format_single_value(self, req, value): |
1052 def format_single_value(self, req, value): |
1053 return value |
1053 return unicode(value) |
1054 |
1054 |
1055 def process_form_value(self, form): |
1055 def process_form_value(self, form): |
1056 """process posted form and return correctly typed value""" |
1056 """process posted form and return correctly typed value""" |
1057 try: |
1057 try: |
1058 return form.formvalues[(self, form)] |
1058 return form.formvalues[(self, form)] |