2008/4/25, Christopher Arndt <[EMAIL PROTECTED]>:
>
> > In model I have:
> >     class BlogComment(SQLObject):
> >         date        = DateTimeCol(default = datetime.now)
> >         commentText = StringCol()
> >         commenter   = ForeignKey('User', cascade = True)
> >         entry       = ForeignKey('BlogEntry', cascade = True)
> >
> > To receive the comments on a certain blog entry, I have defined in my
> > controller:
> >     @expose()
> >     def getComments(self, entryId):
> >         comments = list()
> >         for comment in BlogComment.select(BlogComment.q.entryID ==
> entryId,
> >                                           orderBy =
> > BlogComment.q.date).reversed():
> >             comments.append(dict(date = comment.date,
> >                                  commenter =
> comment.commenter.display_name,
> >                                  commentText = comment.commentText))
> >         return dict(comments = comments)
> >
> > Is this the good way to receive this information, or can it be done more
> > efficient?
>
>
>
> It depends on when you want the actual SQL query execution to happen: in
> your controller code, or when the template is rendered.


There is no template, because it is delivering JSON data on an AJAX request.
So I do not have a choice.
But the used code is not bad? I am just starting with TG, so I am open for
suggestions to do things better. ;-}

-- 
Cecil Westerhof

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