Todd Greenwood wrote:
> William -
> That's pretty cool. I didn't think of the defaultOrder in the sqlmeta.
> However, the recentupdate=Entry.select()[:10] will only grab the most
> 10 most recent updates, which could all be to the same page. What I'm
> trying to get at is the 10 most recently updated pages...
>

class Page(SQLObject):
        class sqlmeta:
            defaultOrder = "-mod_date_time"
        pagename = StringCol(alternateID=True, length=30)
        entries = MultipleJoin('Entry')
        mod_date_time=DateTimeCol(default=datetime.now())

class Entry(SQLObject):
        class sqlmeta:
            defaultOrder = "-mod_date_time"
        page = ForeignKey('Page')
        data = StringCol()
        mod_date_time = DateTimeCol(default=datetime.now())

recentupdate=Page.select()[:10]
recentpages=[p.pagename for p in recentupdate.page]

When you will add a new entry, you could do something like:
e=Entry(data="blablabla", pageID=pageid, mod_date_time=datetime.now())
where pageid is a integer corresponding to Page.id.

You can get more details here: http://www.sqlobject.org/SQLObject.html

But, be aware of :
"At the moment foreign key column names must end in "ID"
(case-insensitive). This restriction will probably be removed in the
next release."

William

Reply via email to