[albatross-users] Flushing content during page processing

Michael C. Neel neel at mediapulse.com
Tue Mar 16 04:01:56 EST 2004


Shelia,

	I've done this before, and I did it by breaking up the template
into a header and a footer and calling ctx.write_content() directly, so
that I could:

	ctx.run_template('header.html')
	for row in c.fetchall():
		ctx.write_content(row)
		ctx.flush_content()
	ctx.run_template('footer.html')

	Downside is you cannot have an al-tag span the header and
footer, which wasn't a problem for me.  If you need an al-form in the
page, you might be able to work something out with buttons and
javascript, so that each row has a button which onClick submits a form
after setting a hidden field to the row clicked, then the form can live
100% in the header.html or the footer.html.  Since the hidden field is
still an al-input, it will get hooked into the recorder, and into the
session.

	If you need you could also replace the write_content() with a
call to a 'middle.html' if the formating of the row was pretty html
heavy and you still want to keep the log and html cleanly seperated.

hth,
mike


> -----Original Message-----
> From: Andrew McNamara [mailto:andrewm at object-craft.com.au] 
> Sent: Sunday, March 14, 2004 10:34 PM
> To: Sheila King
> Cc: albatross-users at object-craft.com.au
> Subject: Re: [albatross-users] Flushing content during page 
> processing 
> 
> 
> >I have some very large pages that I will be working with in certain
> >circumstances. It involves having a large query set returned 
> from a MySQL
> >query and needing to process and display many rows of output.
> >
> >I'm going to be trying to see if I can use the 
> flush_content() method for
> >flushing the output to the browser every few rows or so.
> >
> >In reference to this statement from the documentation:
> >"Does nothing if a content trap stack is in effect,..."
> >
> >I would guess, that if I have a template for the page (I'm 
> using the random
> >page access model), that since the page is basically 
> something along these
> >lines:
> >
> ><al-macro name="pagetemplatename">
> >
> >...other stuff in here...
> >
> ></al-macro>
> >
> >That the content trap stack will be in effect, in that case? 
> So, I guess I
> >either can't use a template that encloses the entire page, 
> or else I can't
> >flush bit by bit?
> 
> As of about r1_10pre2, this was no longer true, I think, so you should
> be okay if you use r1_11pre2 or r1_2_dev_20040203 (but the 
> stable release
> 1.01 and before use a content trap for macro expansion).
> 
> Note, however, that the content trap *is* used for <al-form> 
> content - 
> this seems a little excessive to me and maybe there's potential to
> remove it.
> 
> -- 
> Andrew McNamara, Senior Developer, Object Craft
> http://www.object-craft.com.au/
> _______________________________________________
> Albatross-users mailing list
> Albatross-users at object-craft.com.au
> https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albat
ross-users



More information about the Albatross-users mailing list