"OriginalBrownster" <[EMAIL PROTECTED]> writes:
> A)
>
> what is the purpose of this line in controllers.py after completing the
> tutorial
>
> page = Page.byPagename(pagename)
It is the equivalent of:
SELECT * FROM page WHERE page_name = pagename;
It is also the equivalent of:
page = Page.select(Page.q.pagename == pagename)
It is a shortcut to do what is said: get the page with pagename by search all
pages and looking for the one with that specific name.
> B) when using page to display the list of pages in the database
> this line is used to define pages
>
> pages = [page.pagename for page in
> Page.select(orderBy=Page.q.pagename)]
>
> I want to understand how to use this
It is a list comprehension. A shortcut for:
pages = list()
for page in Page.select(orderBy=Page.q.pagename):
pages.append(page.pagename)
i.e., it will create a new list with all pagenames ordered alphabetically
according to the page name.
> C)
>
> class UploadedFile(SQLObject):
> filename = StringCol(alternateID=True)
> abspath = StringCol()
> size = IntCol()
>
> I want to display the abspath variable in this class from the database
> on a page...ne ideas?
my_file = UploadedFile.byFilename(file_name)
file_path = my_file.abspath
--
Jorge Godoy <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---