Changeset 4051 for waeup/branches/ulif-rewrite
- Timestamp:
- 2 Apr 2009, 11:39:53 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/utils/importexport.txt
r4048 r4051 76 76 >>> import os 77 77 >>> os.unlink('myexport.xml') 78 79 Importing XML 80 ============= 81 82 We can generate objects from XML. 83 84 Let's create a faculty instance, that we want to be restored 85 afterwards:: 86 87 >>> from waeup.university.faculty import Faculty 88 >>> myfaculty = Faculty() 89 >>> myfaculty.name = 'My very faculty.' 90 91 We create an XML dump of this object:: 92 93 >>> from waeup.interfaces import IWAeUPXMLExporter 94 >>> exporter = IWAeUPXMLExporter(myfaculty) 95 >>> result = exporter.export('myexport.xml') 96 97 We change the name of the faculty:: 98 99 >>> myfaculty.name = 'Another name' 100 101 Now we create an importer for that file:: 102 103 >>> from waeup.interfaces import IWAeUPXMLImporter 104 >>> importer = IWAeUPXMLImporter(myfaculty) 105 >>> new_obj = importer.doImport('myexport.xml') 106 107 The object created is indeed a faculty:: 108 109 >>> new_obj 110 <waeup.university.faculty.Faculty object at 0x...> 111 112 >>> new_obj.name 113 'My very faculty'
Note: See TracChangeset for help on using the changeset viewer.