To solve my problem<http://www.web2pyslices.com/main/slices/take_slice/92>,
I did:

#Category CleanUp
def categoryClean():
    """
    Check if a category exists for a deleted page, then delete the dead category
    """
    #populate a set with pages in db
    dbpages = set()
    [dbpages.add(item.slug) for item in
db(db.plugin_wiki_page.id>0).select(db.plugin_wiki_page.slug) ]
    #populate a set with pages referenced by categories
    dbcats = set()
    [dbcats.add(item.slug) for item in
db(db.category.id>0).select(db.category.slug)]
    #cleanup dead entries
    if dbcats-dbpages:
        [db(db.category.slug==page).delete() for page in dbcats-dbpages ]


It will be better if a page was disabled.

tks


2010/7/27 mdipierro <mdipie...@cs.depaul.edu>

> This needs some thought. Pages should disabled not deleted. Good
> catch.
>
> On Jul 26, 5:33 pm, Bruno Rocha <rochacbr...@gmail.com> wrote:
> > I found an error in the model plugin_wiki.
> > 1. Create a new page
> > 2. make some changes to include entries in the table
> > plugin_wiki_page_archive
> > 3. Appadmin go through the table .. _archive and view the historic
> > 4. Delete the page you created
> > 5. Visit again .. _archive through appadmin
> >
> > I guess that is related to cascate deletions, but in this case the
> archive
> > entry dont have to be deleted.
> >
> > I'm trying to create a logic to excluding categories of pages that have
> > already been excluded from _page table. [1]
> >
> > [1]http://www.web2pyslices.com/main/slices/take_slice/92
> >
> > Error traceback
> >
> > 1.
> > 2.
> > 3.
> > 4.
> > 5.
> > 6.
> > 7.
> > 8.
> > 9.
> > 10.
> > 11.
> > 12.
> > 13.
> > 14.
> > 15.
> > 16.
> > 17.
> > 18.
> > 19.
> > 20.
> > 21.
> > 22.
> > 23.
> > 24.
> > 25.
> > 26.
> > 27.
> > 28.
> > 29.
> > 30.
> > 31.
> > 32.
> > 33.
> > 34.
> > 35.
> > 36.
> > 37.
> > 38.
> > 39.
> >
> > Traceback (most recent call last):
> >   File "/Users/brunomac/web2pydev/web2py/gluon/restricted.py", line
> > 178, in restricted
> >     exec ccode in environment
> >   File
> "/Users/brunomac/web2pydev/web2py/applications/rochacbruno/views/appadmin.html"
> > </admin/default/edit/rochacbruno/views/appadmin.html>, line 156, in
> > <module>
> >     {{pass}}
> >   File "/Users/brunomac/web2pydev/web2py/gluon/globals.py", line 105, in
> write
> >     self.body.write(xmlescape(data))
> >   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 106, in
> xmlescape
> >     return data.xml()
> >   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 557, in xml
> >     """
> >   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 548, in
> _xml
> >     # get the xml for the inner components
> >   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 106, in
> xmlescape
> >     return data.xml()
> >   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 557, in xml
> >     """
> >   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 548, in
> _xml
> >     # get the xml for the inner components
> >   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 106, in
> xmlescape
> >     return data.xml()
> >   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 557, in xml
> >     """
> >   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 548, in
> _xml
> >     # get the xml for the inner components
> >   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 106, in
> xmlescape
> >     return data.xml()
> >   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 557, in xml
> >     """
> >   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 548, in
> _xml
> >     # get the xml for the inner components
> >   File "/Users/brunomac/web2pydev/web2py/gluon/html.py", line 106, in
> xmlescape
> >     return data.xml()
> >   File "/Users/brunomac/web2pydev/web2py/gluon/sql.py", line 1467, in
> > __getattr__
> >     self.__allocate()
> >   File "/Users/brunomac/web2pydev/web2py/gluon/sql.py", line 1462, in
> __allocate
> >     raise Exception, "undefined record"
> > Exception: undefined record
> >
> > --
> >
> > http://rochacbruno.com.br
>



-- 

http://rochacbruno.com.br

Reply via email to