Changeset 2120
- Timestamp:
- 18 Aug 2007, 18:16:24 (17 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Widgets.py
r2119 r2120 1498 1498 #import pdb; pdb.set_trace() 1499 1499 widget_id = self.getWidgetId() 1500 fileupload = datastructure[widget_id] 1501 dm = datastructure.getDataModel() 1502 field_id = self.fields[0] 1503 # if isinstance(fileupload, PersistableFileUpload): 1504 # empty_file = False 1505 # session_file = isinstance(fileupload, PersistableFileUpload) 1506 # current_filename = generateFileName(fileupload.filename) 1507 # fileupload.seek(0, 2) # end of file 1508 # size = fileupload.tell() 1509 # fileupload.seek(0) 1510 # last_modified = '' 1511 # else: 1512 # empty_file = True 1513 # session_file = False 1514 # current_filename = '' 1515 # size = 0 1516 # last_modified = '' 1517 # get the adapter 1518 # for adapter in dm._adapters: 1519 # if adapter.getSchema().has_key(field_id): 1520 # break # Note: 'adapter' is still the right one 1521 # else: 1522 # raise ValueError('No schema for field %r' % field_id) 1523 1524 content_url = "/uniben/viewimage?path=%s/%s_%s.jpg" %\ 1525 (self.path, 1526 datastructure[self.id_field], 1527 self.getWidgetId(), 1528 ) 1529 # registry = getToolByName(self, 'mimetypes_registry') 1530 # mimetype = (registry.lookupExtension(current_filename.lower()) or 1531 # registry.lookupExtension('file.bin')) 1532 1533 # image_info = { 1534 # 'empty_file': empty_file, 1535 # 'session_file': session_file, 1536 # 'current_filename': current_filename, 1537 # 'size': size, 1538 # 'last_modified': last_modified, 1539 # 'content_url': content_url, 1540 # 'mimetype': mimetype, 1541 # } 1542 # if image_info['empty_file']: 1543 # tag = '' 1544 # height = 0 1545 # width = 0 1546 # else: 1547 current_filename = "%s_%s.jpg" % (datastructure[self.id_field], 1548 field_id,) 1549 file_path = "/%s/%s" % (self.storage_path, 1550 current_filename) 1551 1500 if datastructure.has_key(widget_id): 1501 fileupload = datastructure[widget_id] 1502 dm = datastructure.getDataModel() 1503 field_id = self.fields[0] 1504 content_url = "/uniben/viewimage?path=%s/%s_%s.jpg" %\ 1505 (self.path, 1506 datastructure[self.id_field], 1507 self.getWidgetId(), 1508 ) 1509 current_filename = "%s_%s.jpg" % (datastructure[self.id_field], 1510 field_id,) 1511 file_path = "/%s/%s" % (self.storage_path, 1512 current_filename) 1513 else: 1514 file_path = "XXX" 1552 1515 # read the file from the filesystem 1553 1516 if not os.path.exists(file_path): 1517 height = -1 1518 width = -1 1554 1519 empty_file = True 1555 1520 session_file = False 1556 1521 current_filename = '' 1522 content_url = '' 1557 1523 size = 0 1558 1524 mimetype = '' … … 1621 1587 ###) 1622 1588 1623 # def getFileName(self, fileupload, datastructure, choice, old_filename=''):1624 # #filename = datastructure[self.getWidgetId()+'_filename'].strip()1625 # ext ='jpg'1626 # filename = "%s_%s.%s" % (datastructure[self.id_field],1627 # self.getWidgetId(),1628 # ext)1629 # if choice == 'change' and filename == old_filename:1630 # # if upload with input field unchanged, use fileupload filename1631 # filename = cookId('', '', fileupload)[0].strip()1632 # #filename = cleanFileName(filename or 'file.bin')1633 # return filename1634 1589 1635 1590 def checkFileName(self, filename, mimetype): … … 1700 1655 if self.size_max and size > self.size_max: 1701 1656 max_size_str = self.getHumanReadableSize(self.size_max) 1702 err = ' cpsschemas_err_file_too_big${max_size}'1657 err = 'This file is too big, the allowed max size is ${max_size}' 1703 1658 err_mapping = {'max_size': max_size_str} 1704 1659 return self.validateError(err, err_mapping, datastructure) -
WAeUP_SRP/trunk/skins/waeup_default/widget_passport_render.pt
r2119 r2120 34 34 <metal:block use-macro="here/widget_file_render/macros/file_edit"> 35 35 <metal:block fill-slot="keep_file" /> 36 <metal:block fill-slot="delete_file" /> 36 37 <metal:block fill-slot="change_file"> 37 38 <input type="file" name="." size="24"
Note: See TracChangeset for help on using the changeset viewer.