# Check for variables used in document in Python prior to rendering

**URL:** <https://discuss.tryton.org/t/check-for-variables-used-in-document-in-python-prior-to-rendering/6852>\
**Category:** Developer\
**Tags:** relatorio\
**Created:** [January 8, 2024, 1:28pm UTC](https://discuss.tryton.org/t/check-for-variables-used-in-document-in-python-prior-to-rendering/6852 "2024-01-08T13:28:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DomCa](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/da6949/32.png) [@DomCa](https://discuss.tryton.org/u/DomCa)\
**Post date:** [January 8, 2024, 1:28pm UTC](https://discuss.tryton.org/t/check-for-variables-used-in-document-in-python-prior-to-rendering/6852/1 "2024-01-08T13:28:51Z")

</div>

Hi all,

I hope you had a good start into the new year!

I have a question regarding relatorio and python:  
I often find it difficult to identify the real reason for the rendering of a template failing.

Is it possible to check for all used variables that a template references in python prior to rendering the template as odt?

I would then perform a check to see if all referenced variables are available in the data object that I pass to relatorio.

Also, is it possible to set relatorio to skip any section that references variables that are not present?

Thanks  
DomCa

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [January 8, 2024, 3:31pm UTC](https://discuss.tryton.org/t/check-for-variables-used-in-document-in-python-prior-to-rendering/6852/2 "2024-01-08T15:31:06Z")

</div>

> [@DomCa](#):
>
> I often find it difficult to identify the real reason for the rendering of a template failing.

Normally you get the expression (with some caching extra function) that is failing and usually it is easy to find it in your template.

> [@DomCa](#):
>
> Is it possible to check for all used variables that a template references in python prior to rendering the template as odt?

I do not think so because it support the full Python language.

> [@DomCa](#):
>
> Also, is it possible to set relatorio to skip any section that references variables that are not present?

What do you mean by “skip section”?

---

<div class="post-metadata">

**Author:** ![DomCa](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/da6949/32.png) [@DomCa](https://discuss.tryton.org/u/DomCa)\
**Post date:** [January 9, 2024, 7:21am UTC](https://discuss.tryton.org/t/check-for-variables-used-in-document-in-python-prior-to-rendering/6852/3 "2024-01-09T07:21:57Z")

</div>

Hi Ced,

> [@ced](#):
>
> > [@DomCa](#):
> >
> > I often find it difficult to identify the real reason for the rendering of a template failing.
> 
> Normally you get the expression (with some caching extra function) that is failing and usually it is easy to find it in your template.

That’s probably right. I am not sure, what I would be looking for here. Maybe something like a hint to a page/line in the template document.

> [@ced](#):
>
> > [@DomCa](#):
> >
> > Also, is it possible to set relatorio to skip any section that references variables that are not present?
> 
> What do you mean by “skip section”?

With “skip” I mean that the template could finish rendering instead of failing with an error. Maybe that section could then print “Error” or something, but still finish rendering.

This should of course only be an option/flag, since people may not want to render long templates without failing, if there are errors.

Regards,  
DomCa
