ó :*§Rc@s²ddlmZddlmZddlmZddlmZddlm Z ddl Z ddl Z de fd„ƒYZ d „Zd „Zddd „Zddd „ZdS( iÿÿÿÿ(tsettings(t HttpResponse(tContext(t get_template(tpisaNtUnsupportedMediaPathExceptioncBseZRS((t__name__t __module__(((s&/home/denis/henry2web/ponto/reports.pyRscCsû|jtjƒr<tjjtj|jtjdƒƒ}n»|jtjƒrÛtjjtj |jtjdƒƒ}tjj |ƒs÷xNtj D]@}tjj||jtjdƒƒ}tjj |ƒr‘Pq‘q‘Wq÷nt dtjtj fƒ‚|S(sÊ Callback to allow xhtml2pdf/reportlab to retrieve Images,Stylesheets, etc. `uri` is the href attribute from the html link element. `rel` gives a relative path, but it's not used here. ts#media urls must start with %s or %s( t startswithRt MEDIA_URLtostpathtjoint MEDIA_ROOTtreplacet STATIC_URLt STATIC_ROOTtexiststSTATICFILES_DIRSR(turitrelR td((s&/home/denis/henry2web/ponto/reports.pytfetch_resourcess$cCs>|jt|ƒƒ}tj|jdƒ|dddtƒ|S(sX Inner function to pass template objects directly instead of passing a filename sUTF-8tencodingt link_callback(trenderRRt CreatePDFtencodeR(ttemplate_objectt file_objecttcontextthtml((s&/home/denis/henry2web/ponto/reports.pytgenerate_pdf_template_object,scCsD|stjƒ}n|s$i}nt|ƒ}t|||ƒ|S(s Uses the xhtml2pdf library to render a PDF to the passed file_object, from the given template name. This returns the passed-in file object, filled with the actual PDF data. In case the passed in file object is none, it will return a StringIO instance. (tStringIORR!(t template_nameRRttmpl((s&/home/denis/henry2web/ponto/reports.pyt generate_pdf9s   cCs\tddƒ}|s>dtjjtjj|ƒƒd}nd||ds