On Wed, Sep 23, 2009 at 10:09 AM, James Henstridge <span dir="ltr"><<a href="mailto:james@jamesh.id.au">james@jamesh.id.au</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">If you're instantiating a new object, then Storm will issue an INSERT to add the new row.</div></div></blockquote><div><br></div><div>This is actually what we're trying to prevent. We want to make an object that has the same interface as the store, but will save objects to a CSV file to be loaded by SQL*Loader later instead of having an INSERT statement generated.</div>
<div><br></div><div>Perhaps some code snippets will help illustrate what we're trying to do (note that this is just the relevant parts of course):</div><div><br></div><div>class BulkStore(object):</div><div><div> def add(self, entity, has_identity_property=True):</div>
<div> """</div><div> Add an object to this store. Will take no action if the object has</div><div> been added since the last flush operation.</div><div> """</div>
<div> entity_store = Store.of(entity)</div><div> if entity_store is not None and entity_store is not self:</div><div> msg = '%s is part of another store.' % repr(entity)</div><div> raise WrongStoreError, msg</div>
<div><br></div><div> elif entity_store is None:</div><div> # <snip> - do whatever this store</div><div> # should do on adding an object</div><div> self.set_as_store(entity)</div>
<div><br></div><div> def set_as_store(self, entity):</div><div> """</div><div> Set this saver as the storm store.</div><div> """</div><div> obj_info = get_obj_info(entity)</div>
<div> obj_info['store'] = self</div><div><br></div><div> def add_flush_order(self, *args, **kwargs):</div><div> """This is a stub method that is for compatibility with the storm</div>
<div> store. Currently, this does nothing."""</div><div><br></div></div></div><div>The add_flush_order method is just there because it will be called automatically sometimes. For the most part, we're ignoring it because we're determining our own flush ordering (although it would be nice if storm had a function that we can call to determine flush ordering the same way the store does).</div>
<div><br></div>In my testing thus far, this approach seems to be working flawlessly. However, I get the feeling that this is something that you guys hadn't planned for and may give problems at some point.<br>