Re: newbie (coming from java) question
Didrik Pinte <[email protected]> Wed, 02 Jun 2004 11:40:06 +0200
| Newsgroups | gmane.comp.web.albatross.general |
|---|---|
| Message-ID | <1086169206.4898.39.camel@geru-itea> |
Le mer 02/06/2004 à 09:56, Gregory Bond a écrit :
> Oh OK I think I see the problem.
>
> The _first time_ you get to the ListPage object, the call seq will be
> prevpage.page_exit()
> ListPage.page_enter()
> ListPage.page_display()
>
> ctx.locals.doclist is not set because it is only set once someone hits the
> "recherche" button and ListPager.page_process() is called.
>
> the fix: make ListPage.page_enter() like this:
> def page_enter(self, ctx):
> self.locals.doclist = []
> ctx.add_session_variables('doclist')
Here is the latest version of the class, it works, the page is displayed
but the doclist seems empty.
Do you know how I can debug this ? I've tried to add some
sys.stderr.write('problem') in the code but I have no output ...
class ListPage:
'''This page shows the list of results due to the search
'''
name = 'list'
def page_enter(self, ctx):
ctx.locals.doclist = []
ctx.add_session_vars('doclist')
def page_process(self,ctx):
if ctx.req_equals('detail'):
ctx.set_page('detail')
elif ctx.req_equals('recherche'):
container = getContainer()
for result in
container.searchContains('title',ctx.locals.title):
ctx.locals.doclist.append(result)
if len(ctx.locals.doclist)<1 :
ctx.locals.error = "No document found"
ctx.set_page('error')
else :
ctx.add_session_vars('doclist')
def page_display(self,ctx):
ctx.load_template('headers.html').to_html(ctx)
ctx.load_template('footer.html').to_html(ctx)
ctx.run_template('list.html')
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBAvaB19Rlh4Zs4yBMRAuO0AKCagU5oMVBEAUO4xYG0gwUeqb2udQCfXsAQ 5Pwfk/nk23b/75W6Yz7wQhw= =QW/p -----END PGP SIGNATURE-----