[albatross-users] newbie (coming from java) question

Didrik Pinte pinted at tiscali.be
Wed Jun 2 19:40:06 EST 2004


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')
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Ceci est une partie de message num?riquement sign?e.
URL: <http://www.object-craft.com.au/pipermail/albatross-users/attachments/20040602/fc2cc605/attachment.pgp>


More information about the Albatross-users mailing list