Changeset 4871 for waeup/trunk
- Timestamp:
- 21 Jan 2010, 14:57:03 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/trunk/src/waeup/utils/batching.txt
r4858 r4871 93 93 ... required = True, 94 94 ... missing_value = 'Fred Estates Inc.') 95 ... taxpayer = schema.Bool( 96 ... title = u'Payes taxes', 97 ... required = True, 98 ... default = False) 95 99 96 100 Now a class that implements this interface: … … 100 104 ... grok.implements(ICave) 101 105 ... def __init__(self, name=u'Unnamed', dinoports=2, 102 ... owner='Fred Estates Inc.' ):106 ... owner='Fred Estates Inc.', taxpayer=False): 103 107 ... self.name = name 104 108 ... self.dinoports = 2 105 109 ... self.owner = owner 110 ... self.taxpayer = taxpayer 106 111 107 112 We also provide a factory for caves. Strictly speaking, this not … … 164 169 165 170 >>> open('newcomers.csv', 'wb').write( 166 ... """name,dinoports,owner 167 ... Barneys Home,2,Barney 168 ... Wilmas Asylum,1,Wilma 169 ... Freds Dinoburgers,10,Fred 170 ... Joeys Drive-in,110,Joey 171 ... """name,dinoports,owner,taxpayer 172 ... Barneys Home,2,Barney,1 173 ... Wilmas Asylum,1,Wilma,1 174 ... Freds Dinoburgers,10,Fred,0 175 ... Joeys Drive-in,110,Joey,0 171 176 ... """) 172 177 … … 209 214 210 215 >>> processor = CaveProcessor() 211 >>> processor.doImport('newcomers.csv', ['name', 'dinoports', 'owner'], 216 >>> processor.doImport('newcomers.csv', 217 ... ['name', 'dinoports', 'owner', 'taxpayer'], 212 218 ... mode='create', user='Bob') 213 219 (4, {}) … … 257 263 could be read here as we can see, if we do the same operation again: 258 264 259 >>> processor.doImport('newcomers.csv', ['name', 'dinoports', 'owner'], 265 >>> processor.doImport('newcomers.csv', 266 ... ['name', 'dinoports', 'owner', 'taxpayer'], 260 267 ... mode='create', user='Bob') 261 268 (4, {1: 'This object already exists...}) … … 281 288 282 289 >>> print open('newcomers.csv.create.pending').read() 283 owner,name, dinoports284 Barney,Barneys Home, 2285 Wilma,Wilmas Asylum,1 286 Fred,Freds Dinoburgers, 10287 Joey,Joeys Drive-in, 110290 owner,name,taxpayer,dinoports 291 Barney,Barneys Home,1,2 292 Wilma,Wilmas Asylum,1,1 293 Fred,Freds Dinoburgers,0,10 294 Joey,Joeys Drive-in,0,110 288 295 289 296 This way we can correct the faulty entries and afterwards retry without 290 297 having the already processed rows in the way. 298 299 We also notice, that the values of the taxpayer column are returned as 300 in the input file. There we wrote '1' for ``True`` and '0' for 301 ``False`` (which is accepted by the converters). 291 302 292 303
Note: See TracChangeset for help on using the changeset viewer.