[reportlab-users] Getting the name of the current (or next) page template

Robin Becker reportlab-users@reportlab.com
Sat, 10 Jul 2004 17:16:10 +0100


Michael Mauws wrote:
> Can anyone tell me if there is an easy way to determine the name of the
> current or next page template? I'm a reportlab newbie so my apologies in
> advance if the answer is obvious (to some/most)...
> 
> 
> ...michael


If doc is your BaseDocTemplate, then the current page template is

	doc.pageTemplate

so you can get its id as

	doc.pageTemplate.id



Normally the current pageTemplate persists. If you have called
	doc.handle_nextPageTemplate(pt)

with pt as the id of the new page template then doc will have an 
attribute _nextPageTemplateIndex. Thus you should be able to get the 
name of the next page template as

	x = getattr(doc,'_nextPageTemplateIndex',None)
	if x is None:
		nextptid = doc.pageTemplate.id
	else:
		nextptid = doc.pageTemplates[x].id

hope this helps.

-- 
Robin Becker