I have what I think is pretty simple code, and it works up until TG
tries to handle the transaction...

I have a Servers lookup table mapped to a simple Server class.  Should
only be update-able by administrative functions, but apparently TG
will write to the table every end of transaction.

Without further ado, my test code:

server = "a1"
servers = model.Server()
serverObject =
session.query(model.Server.name).filter(model.Server.name==server).first()
if serverObject != None:
    return serverObject.name
else:
    raise ServerNotFoundError("Unknown server: "+server)

It works fine until TG tries to close the session... u'INSERT INTO
`Servers` (translate, redirect) VALUES (%s, %s)' [None, None]

Why is TG trying to write a new object into the database?  I did not
create any instances, and it's trying to write a non-existant object
and fails... gee.

Is there a "proper" way to check if an object exists without TG trying
to automatically create it for me?  The SQLAlchemy documents don't
seem to give any hints in this direction.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to