As a new Pylons user who knows nothing about databases, I agree that
it's slightly confusing. If threadlocal or sessioncontext is the
recommended usage pattern, then it's fine to have it. But it would be
good to have a little note, maybe a footnote, in the tutorial that
explains what it does, and how this situation differs from the
SQLAlchemy tutorial.

Also, I spent a bit of time trying to figure out how to get my project
to echo debugging SQL like in the SQLAlchemy tutorial. Perhaps this
should also be included as a footnote in the Pylons tutorial:

        model.meta.connect(
            request.environ['paste.config']['app_conf']['dsn'],
            echo=True
        )

Finally, it would be nice for people new to databases to have a brief
note about primary keys. Seeing the QuickWiki tutorial use String(40)
as a primary key led me to believe that I could use fixed-length
strings as primary keys, and I also thought that it was somehow good
for the primary key to be a "real" data field in the table. This worked
allright for awhile but later on I faced a host of problems from
cryptic errors (MySQL, unlike SQLite, doesn't like fixed-length unicode
strings as primary keys) to mysteriously disappearing data (if your
primary key in table A is partially composed of a foreign key to a row
in table B which is newly created, you may have to call
objectstore.flush() before creating the entry in table A).

Eventually I figured out that the easiest thing to do is just to make
an Integer "id" column in each table and make that the primary key.

I'm not advocating that a detailed introduction to databases be added
to the tutorial. But it might be nice to mention very briefly that if
you don't know what a primary key is, it's a unique ID for each row in
a database table, and furthermore the easiest way to deal with them is
to add an extra column to each table of type Integer, and make that the
primary key (unless this advice is in error; as I noted, I don't know
anything about databases).


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss
-~----------~----~----~----~------~----~------~--~---

Reply via email to