Hi,Spett/le Sig. $name $last_name,
I found very interesting the way you use oo to create reports.
I can't figure out how to pass values (of type a) to the template.
Should it be passed as list of dictionaries or else.
I tried this:
from sqlkit.misc import oootemplate
from sqlkit.misc.oootemplate import Template , Context
from datetime import date
tmpl = Template('/tmp/my_template.odt')
context = Context({
'name' : 'Jo',
'last_name' : 'Soares',
'Table1' : [{'title':'Pinocchio',
'author':'Collodi',
'qty':3,
'price':1.32},
{'title':'La divina commedia',
'author':'Dante Alighieri',
'qty':3,
'price':32.2}
],
})
tmpl.render(context)
tmpl.save_as('/tmp/new_document.pdf')
the template is:
Titolo |
Autore |
Quantita' |
prezzo |
++$title |
$author |
$qty |
$price |
Titolo |
Autore |
Quantita' |
prezzo |
++$title |
$author |
$qty |
$price |
On Sun, Feb 03, 2013 at 08:59:01AM -0800, j...@sferacarta.com wrote:
> Hi,
> I found very interesting the way you use oo to create reports.
pleased to know ;-)
> I can't figure out how to pass values (of type a) to the template.
what do you mean "of type a"?
> Should it be passed as list of dictionaries or else.
Context requires a dict, but table (the one that expands ++) requires a list
of items not a list of dictionaries, i.e.: list of instances of a class with
attributes named 'title', 'author',... The idea is that you normally will
render objects that live in a database and you retrieved using an ORM, that
maps each tuple to an instance.
I don't mind which class it belongs to as far as it has attributed named
according to the $names in your template ($title, $author, $qty...)
On Wed, Feb 06, 2013 at 12:04:20AM -0800, j...@sferacarta.com wrote:
> I've been watching the project OOoPy and it seems to me that it do the same
> thing as PyUno with the difference that you do not need to install OpenOffice,
> so it should be more light and should also work with Solaris. What do you think
> of OOoPyi?
I didn't know about it before you mentioned it. In my opinion il lacks
docuemntations and examples.
Another project that compares to that one is relatorio
(http://relatorio.openhex.org/) that could be worth a try.
sandro
*:-)
> I did not understand how it is constructed� the menu demo (basic relation,