Well, I don't understand what the original problem is. If he can't do "<% import package %>" within a template, he probably can't import it outside the template either. That suggests it was installed incorrectly or the Python path or virtualenv is screwed up.
I think you can use <%namespace ...> to import pure Python modules, but the functions have to be written to use Mako's special context argument. On Mon, May 24, 2010 at 5:36 PM, Didip Kerabat <[email protected]> wrote: > Usually I do that by importing the module into helpers.py > > Then you can just call h.jsmin > > - Didip - > > On Mon, May 24, 2010 at 2:33 PM, Mario Moura <[email protected]> wrote: >> >> Hi All >> >> I not talking about import >> /templates/modules/something.py >> or >> /templates/modules/something.html >> >> I am talking about pypi packages. >> >> Could you give a easy example like: >> >> easy_install jsmin >> >> ## /templates/myminimizer.mako >> <%namespace name="hw" file="/jsmin/__init__.py" import="*" /> NOT WORKING >> <%namespace name="hw" module="jsmin" /> NOT WORKING >> <% >> import jsmin ## NOT WORKING >> %> >> >> ## toMinimizer is a javascript code >> toMinimizer = ' >> function decodeit_ve() { >> inpdata=window.document.blcoder.blinptext.value; >> passwd=window.document.blcoder.blpassword.value; >> window.document.blcoder.blouttext.value="Working..."; >> if ( window.document.blcoder.bltype.options[0].selected ) >> decodetext(2); >> if ( window.document.blcoder.bltype.options[1].selected ) >> decodetext(0); >> // if ( window.document.blcoder.bltype.options[2].selected ) >> // decodetext(1); >> window.document.blcoder.blouttext.value=outdata; >> inpdata=""; >> outdata=""; >> passwd=""; >> } >> ' >> >> ${hw.jsmin(toMinimizer)} NOT WORKING >> >> I tried a lot! >> >> And I read http://www.makotemplates.org/docs/namespaces.html >> >> from mako.runtime import supports_caller >> @supports_caller >> >> Regards >> >> Mario >> macm >> >> 2010/5/18 Eryx Lee <[email protected]> >>> >>> import html in Mako: >>> >>> <%! >>> from html import HTML >>> h = HTML() >>> %> >>> >>> a test ${str(h.p('hello world!\n'))|n} >>> >>> On Mon, May 17, 2010 at 10:22 PM, Mario Moura <[email protected]> >>> wrote: >>>> >>>> Hi Folks >>>> >>>> I want use html 1.11 from Package Index inside mako. (and anothers >>>> packages) >>>> >>>> Is it possible? how? >>>> >>>> http://pypi.python.org/pypi/html >>>> >>>> Regards >>>> >>>> Mario >>>> macm >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "pylons-discuss" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/pylons-discuss?hl=en. >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "pylons-discuss" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/pylons-discuss?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "pylons-discuss" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/pylons-discuss?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/pylons-discuss?hl=en. > -- Mike Orr <[email protected]> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
