David Pratt <fairwinds@...> writes:
> Hi there. I am new to SQLObject. I am concerned that I don't repeat my
> work so it is best to ask a few questions first.
I'm also a beginner, but I'm trying to make it a substitute for a project that
is "a little" big and I'm trying to work with it a little everyday.
> 1. What is the best way to organize a project with SQLObject. I was
> thinking of a base.py that would contain connection and base classes
> and then a separate file for each class representing a table with its
> methods. Any guidance here would be appreciated.
I am doing something a little different. I dunno how you're validating users,
but I'm connecting with data supplied by the user himself, so I'm leaving it
for PostgreSQL to do this validation. Since I have more than one interface I
am creating the connection string in one place and instantiating the class in
I've putten all classes related to database in the same file. For now there
are... 30 classes (with corresponding documentation and sqlmeta classes) in my
I have all of these on the same file to make it easier to stablish relations
between classes and Python namespace, importing other files would add an extra
layer that I would have to deal with and as a beginner I thought it would be
worse than keeping my "maps" in one place only. Besides that, I'm also
migrating an existing application, so all of my columns come automatically
from the database.
> 2. I also do work in Zope although presently in zope2, I am beginning
> to work in Five. SQLOS uses this type of strategy for the schema. In
I am going this way too... Maybe we can exchange some experience on that as
> all the examples shown on the SQLObject site, you are using something
> like this:
>>>> class Person(SQLObject):
> ... firstName = StringCol()
> ... middleInitial = StringCol(length=1, default=None)
> ... lastName = StringCol()
> in SQLOS, this is desired:
> _columns = [StringCol('username', length=20, notNull=True),
> StringCol('fname', length=20, notNull=True),
> StringCol('lname', length=20, notNull=True),]
> I would like to do things just once so schemas will not have to be
> changed whether or not I use Zope. Can the _columns type arrangement
> be used directly by SQLObject? If so, can you explain.
Hmmm... I'd try using an external script and passing data from Zope to it.
This same script would also be used outside Zope.
At least, this is the route I'm planning to follow, but I'm not using Five.
Jorge Godoy <godoy@...>