On Thu, 3 May 2007 at 08:54, Thierry wrote:
> I'm currently using an existing database(MySQL) with table Greet, so
> my model.py looks like the following:
>
> class Greet(SQLObject):
>    class sqlmeta:
>        fromDatabase = true
>
> My controller.py:
>
> class Root(controllers.RootController):
>    @expose(...)
>    def index(self):
>        g = Greet()
>        return dict(hellos=[])
>
>
> Each time I reload my main web page, I an empty new entry is populated
> in the table Greet. It seems to be coming from the call Greet() in
> index(). Does anyone know why this is happening?

Kevin has already answered the immediate question.

Given what you've told us so far, maybe you really want to do
something like this (untested):

     class Greet(SQLOjbect):
         class slqmeta:
             fromDatabase = True

         @classmethod
         def greetings(klass):
             return klass._connection.queryAll('SELECT distinct greeting FROM 
Greets')


Then your index method would do:

     return dict(greets=Greet.greetings())


There may be better ways to accomplish your long term goals, but I
don't know what those are :)

--David

--~--~---------~--~----~------------~-------~--~----~
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