206 elif isinstance(value, unicode): |
206 elif isinstance(value, unicode): |
207 # file modified using a text widget |
207 # file modified using a text widget |
208 encoding = entity.attr_metadata(attr, 'encoding') |
208 encoding = entity.attr_metadata(attr, 'encoding') |
209 value = Binary(value.encode(encoding)) |
209 value = Binary(value.encode(encoding)) |
210 else: |
210 else: |
211 # (filename, mimetype, stream) |
211 # value is a 3-uple (filename, mimetype, stream) |
212 val = Binary(value[2].read()) |
212 val = Binary(value[2].read()) |
213 if not val.getvalue(): # usually an unexistant file |
213 if not val.getvalue(): # usually an unexistant file |
214 value = None |
214 value = None |
215 else: |
215 else: |
216 val.filename = value[0] |
216 val.filename = value[0] |
217 if entity.e_schema.has_metadata(attr, 'format'): |
217 # ignore browser submitted MIME type since it may be buggy |
218 key = '%s_format' % attr |
218 # XXX add a config option to tell if we should consider it |
219 formparams[key] = value[1] |
219 # or not? |
220 self.relations.append('X %s_format %%(%s)s' |
220 #if entity.e_schema.has_metadata(attr, 'format'): |
221 % (attr, key)) |
221 # key = '%s_format' % attr |
|
222 # formparams[key] = value[1] |
|
223 # self.relations.append('X %s_format %%(%s)s' |
|
224 # % (attr, key)) |
222 # XXX suppose a File compatible schema |
225 # XXX suppose a File compatible schema |
223 if entity.e_schema.has_subject_relation('name') \ |
226 if entity.e_schema.has_subject_relation('name') \ |
224 and not formparams.get('name'): |
227 and not formparams.get('name'): |
225 formparams['name'] = value[0] |
228 formparams['name'] = value[0] |
226 self.relations.append('X name %(name)s') |
229 self.relations.append('X name %(name)s') |