Changeset 2292
- Timestamp:
- 28 Sep 2007, 14:47:14 (17 years ago)
- Location:
- WAeUP_SRP/base
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/WAeUPTool.py
r2289 r2292 1454 1454 ###) 1455 1455 1456 security.declareProtected(ModifyPortalContent,"moveImagesToFS")###( 1457 def moveImagesToFS(self,student_id="O738726"): 1458 "move the images to the filesystem" 1459 images_dir = os.path.join("%s/images" % i_home,student_id) 1460 student_folder = getattr(self.portal_url.getPortalObject().campus.students,student_id) 1461 stool = getToolByName(self, 'portal_schemas') 1462 schemas = ['student_application', 1463 'student_clearance', 1464 ] 1465 created = False 1466 for schema_id in schemas: 1467 schema = stool._getOb(schema_id) 1468 object = getattr(student_folder,schema_id[len('student_'):],None) 1469 if object is None: 1470 continue 1471 doc = object.getContent() 1472 for key in schema.keys(): 1473 if schema[key].meta_type != "CPS Image Field": 1474 continue 1475 #import pdb;pdb.set_trace() 1476 image = getattr(doc,key) 1477 if not hasattr(image,"data"): 1478 continue 1479 if not created: 1480 if not os.path.exists(images_dir): 1481 os.mkdir(images_dir) 1482 created = True 1483 filename = os.path.join(images_dir,"%(key)s_%(student_id)s.jpg" % vars()) 1484 open(filename,"wb").write(str(image.data)) 1485 1456 1486 InitializeClass(WAeUPTool)
Note: See TracChangeset for help on using the changeset viewer.