Changing the mode to 'nr' was the trick. I didn't see that mode in the
docs! Thanks for the input there.

On Jun 13, 8:03 pm, Christopher Lee <l...@chem.ucla.edu> wrote:
> On Jun 13, 2009, at 5:52 PM, Kenny Daily wrote:
>
>
>
> > First, that would be great to use the Graph instead, so I can query
> > it. It works the same when adding/binding attributes? I know the
> > difference in constructing it.
>
> Yes, you save the schema of the Graph to worldbase in the same basic  
> way as for a Mapping, just using a metabase.OneToManyRelation schema  
> object instead of OneToOneRelation...
>
>
>
> > BUT I tried to add the close() and still get the same problem. So
> > where do I add the close call? Immediately after my for... loop, after
> > adding the mapping resource to the worldbase, or before/after the
> > worldbase.commit()? I actually am getting an EOFerror, which to me
> > does indicate that a buffer was not flushed to a file.
>
> I just noticed that you are using mode 'ww' which means that the  
> Mapping will not only be opened initially in write mode, it will also  
> be opened in write mode whenever it is unpickled in the future.  Is  
> that really what you want?  Given that you're having trouble reopening  
> this Mapping successfully, I think you ought to switch to 'nr', which  
> means
> - initially, open in mode 'n', creating a completely new shelve file;  
> if an existing shelve file is present, its contents will be deleted,  
> so you know you are starting from scratch.
>
> - when the Mapping is unpickled in the future it will open in mode  
> 'r', i.e. read-only.  That way the contents should remain exactly what  
> they were when you first created them.
>
> I am wondering whether some side-effects of your first attempt to  
> create this shelve file without closing it may be persisting and  
> screwing up subsequent attempts to write it correctly.  (I know that  
> on Windows this could cause long-lasting mayhem).  If I were you, I'd  
> delete the existing file and start over from scratch, maybe with a  
> different filename just to be on the paranoid side.
>
> A second, more fundamental piece of advice for getting things working  
> with worldbase: do this in two steps.  It seems like you're trying to  
> accomplish two steps in one script:
>
> 1. create the Mapping and save it successfully to disk;
>
> 2. add this resource to worldbase.
>
> Since your script proceeds directly to step 2 without first checking  
> that step 1 actually worked, this makes it much harder to debug.  I  
> suggest that you just try to do step 1, then check that it succeeded  
> by reopening it in read-only mode, and verifying that its contents are  
> what you'd expect.  Once you are able to re-open that Mapping read-
> only whenever you want, adding it to worldbase should be trivial.
>
> -- Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pygr-dev" group.
To post to this group, send email to pygr-dev@googlegroups.com
To unsubscribe from this group, send email to 
pygr-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pygr-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to