[Tutor] Building application namespaces.

David Driver count0.djd at gmail.com
Fri Apr 22 16:30:03 CEST 2005

I have generally used python for tasks that are scripty and not
appish. I have found that I don't know the language very well even
though I have been scripting with it for about two years. To remedy
this I am in the process of laying out a mock up for an accounting
system (GL, AR, AP). This is the first time I have done modules inside
packages and I am confused about namespaces.

What I have is a folder structure that looks like this:
++ Common
++ AP
++ AR
++ GL

Each subfolder looks like:
++ Common
++++ __init__.py
++++ sobjs.py (this contains sqlobjects for the domain)
++++ validators.py (contains formencode validators for the sqlobjects
for the domain)
++++ exceptions.py
++++ folder: view (this will be templates)
++++ folder: search (this will contain controllers for lookups)
++++ folder: transact (this will contain controllers for creating transactions)
++++ folder: maintain (contains folders for maintaining domain objects
(ie customer maintenance or anything that isn't a busness transaction)

In the __init__ file I import sobjs, exceptions, validators and I will
eventually check to see that the user is supposed to be in that

You may laready see what the problem is. When I import Common from the
script running in the root folder and it runs init all of themodules
in the  domain (common, GL) package that get imported by __init__have
no ancesters in their name spaces (is that the correct term?). What I
wanted was root/common/sobjs.py as common.sobjs not just sobjs.

Am I totally confused here?

Is there some place that I could go that has better doccumentation on
settig up namespaces for large python projects?

Thanks tutors!


See there, that wasn't so bad.

More information about the Tutor mailing list