On Wed, Sep 23, 2009 at 10:09 AM, James Henstridge <span dir="ltr">&lt;<a href="mailto:james@jamesh.id.au">james@jamesh.id.au</a>&gt;</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&#39;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&#39;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&#39;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>        &quot;&quot;&quot;</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>        &quot;&quot;&quot;</div>
<div>        entity_store = Store.of(entity)</div><div>        if entity_store is not None and entity_store is not self:</div><div>            msg = &#39;%s is part of another store.&#39; % repr(entity)</div><div>            raise WrongStoreError, msg</div>
<div><br></div><div>        elif entity_store is None:</div><div>            # &lt;snip&gt; - 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>        &quot;&quot;&quot;</div><div>        Set this saver as the storm store.</div><div>        &quot;&quot;&quot;</div><div>        obj_info = get_obj_info(entity)</div>
<div>        obj_info[&#39;store&#39;] = self</div><div><br></div><div>    def add_flush_order(self, *args, **kwargs):</div><div>        &quot;&quot;&quot;This is a stub method that is for compatibility with the storm</div>
<div>           store.  Currently, this does nothing.&quot;&quot;&quot;</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&#39;re ignoring it because we&#39;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&#39;t planned for and may give problems at some point.<br>