I have the following in model.py:
class Greet(SQLObject):
class sqlmeta:
fromDatabase = True
def _get_greetings(self):
c = Greet._connection
return c.queryAll('SELECT distinct greeting FROM Greets')
The only way I can retrieve the value of greetings in controllers.py
is the following:
g = Greet()
return dict(greets=g.greetings)
All I want to do is get some values from the database, is there an
alternative way of doing the above?
On May 3, 12:07 pm, "Kevin Horn" <[EMAIL PROTECTED]> wrote:
> Your call to Greet() is creating a new SQLObject (g), which is then (by
> default) committed to the database when your controller method finishes.
> Since you haven't set any of the values in "g", it shows up as an empty
> record in the database.
>
> What are you trying to do in your index method?
>
> Kevin Horn
>
> On 5/3/07, Thierry <[EMAIL PROTECTED]> 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?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---