Problem with Axiom?

"Chaz." <[email protected]> Sun, 27 Aug 2006 16:51:28 -0400
Newsgroups gmane.comp.python.quotient.dev
Message-ID <[email protected]>
I am having a strange problem and I am not sure of exactly where the 
problem lies. It could be my python code, it could be axiom, I just 
don't know.

I have three files:

db.py -------------------------------

from axiom.store import Store
from axiom import errors

globaldb = None
globalName = None

localdb = None
localName = None


def dbSetup(globName,locName) :
     global globaldb,globalName
     if globaldb is None:
         globaldb = Store(globName)
         globalName = globName
     global localdb,localName
     if localdb is None:
         localdb = Store(locName)
         localName = locName


bar.py --------------------------------

from axiom.item import Item
from axiom.attributes import AND, OR
from db import globaldb

class Category(Item) :
     schemaVersion = 1
     typeName = 'category'
     tenant = bytes( allowNone=False )
     cat = bytes( allowNone = False )
     defs = bytes( )

def addCategory(tenant,category,defs) :
     try :
         rval = 
globaldb.findUnique(Category,AND(Category.tenant==tenant,Category.cat==category))
     except errors.ItemNotFound :
         Category(store=globaldb,tenant=tenant,cat=category,defs=defs)
     else :
         rval.defs = defs

foo.py -------------------------------------
import db
db.dbSetup('wwGlobalDB','wwLocalDB')
from bar import addCategory
a = 'snarf'
addCategory('xxx','online',a)
addCategory('xxx','offline',a)


If I do a

rm -rf wwGlobalDB wwLocalDB

before doing

python
import foo

It works fine.

If I don't remove the files (leaving them from the previous run) the 
outcome is something different. If I run

python
import foo

I get this returned:
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "foo.py", line 5, in ?
     addCategory('xxx','online',a)
   File "bar.py", line 17, in addCategory
     rval = 
globaldb.findUnique(Category,AND(Category.tenant==tenant,Category.cat==category))
AttributeError: 'NoneType' object has no attribute 'findUnique'


Am I doing something incredibly stupid and just don't see it?

Peace,
Chaz