Changeset 4779 for waeup/branches/ulif-layout/src
- Timestamp:
- 10 Jan 2010, 01:47:13 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-layout/src/waeup/browser/pages.py
r4758 r4779 17 17 IUserAccount, IFacultyContainer, IDataCenter, 18 18 IFaculty, IDepartment, ICourse, ICertificate, 19 ICertificateCourse) 19 ICertificateCourse, IWAeUPXMLImporter, 20 IWAeUPXMLExporter) 20 21 from waeup.widgets.interfaces import ITableProvider 21 22 from waeup.utils.helpers import getName … … 28 29 from zope.exceptions import DuplicationError 29 30 31 grok.context(IWAeUPObject) 30 32 grok.templatedir('templates') 31 33 … … 340 342 self.redirect(self.url(self.context)) 341 343 return 344 345 class ExportXMLPage(grok.View): 346 """Deliver an XML representation of the context. 347 """ 348 grok.name('export.xml') 349 grok.require('waeup.manageUniversity') 350 351 def render(self): 352 exporter = IWAeUPXMLExporter(self.context) 353 xml = exporter.export().read() 354 self.response.setHeader( 355 'Content-Type', 'text/xml; charset=UTF-8') 356 return xml 357 358 class ImportXMLPage(WAeUPPage): 359 """Replace the context object by an object created from an XML 360 representation. 361 362 XXX: This does not work for ISite objects, i.e. for instance 363 for complete University objects. 364 """ 365 grok.name('importxml') 366 grok.require('waeup.manageUniversity') 367 368 def update(self, xmlfile=None, CANCEL=None, SUBMIT=None): 369 if CANCEL is not None: 370 self.redirect(self.url(self.context)) 371 return 372 if not xmlfile: 373 return 374 importer = IWAeUPXMLImporter(self.context) 375 obj = importer.doImport(xmlfile) 376 if type(obj) != type(self.context): 377 return 378 parent = self.context.__parent__ 379 name = self.context.__name__ 380 self.context = obj 381 if hasattr(parent, name): 382 setattr(parent, name, obj) 383 else: 384 del parent[name] 385 parent[name] = obj 386 pass 387 return 388 342 389 343 390
Note: See TracChangeset for help on using the changeset viewer.