Using just the Mako part of Pylons?

J

John Salerno

I just installed Pylons onto my hosting server so I could try out
templating with Mako, but it seems a little more complicated than that.
From the look of it all, the site seems to want a full Pylons
application. Is it possible to just use regular HTML files with a bit of
the Mako language embedded, or will I actually have to use all aspects
of Pylons?

In other words, can I use *just* Mako (sort of like as a replacement for
PHP) without having to use a framework?

For example, I'd like to just test out the <%include /> tag and see it
in action, but the site doesn't seem to be looking for a regular HTML
file (like index.html), it seems to want a "controller". So is Pylons
overkill for just this? How would I try out *just* Mako?

Thanks!
 
J

John Salerno

John said:
I just installed Pylons onto my hosting server so I could try out
templating with Mako, but it seems a little more complicated than that.
From the look of it all, the site seems to want a full Pylons
application. Is it possible to just use regular HTML files with a bit of
the Mako language embedded, or will I actually have to use all aspects
of Pylons?

In other words, can I use *just* Mako (sort of like as a replacement for
PHP) without having to use a framework?

For example, I'd like to just test out the <%include /> tag and see it
in action, but the site doesn't seem to be looking for a regular HTML
file (like index.html), it seems to want a "controller". So is Pylons
overkill for just this? How would I try out *just* Mako?

Thanks!

Ok, I figured out how to get it to just use regular HTML files as if it
were a regular, static site. However, the include directive I used
didn't seem to work. I used:

<%include file="separate.html"/>

And it just shows that text in the browser. Am I missing something?
 
M

mario

You would need a controller of some sort to connect the web request/
response with your template handling. This is the key task of the web
application layer. This is also the area that WSGI atttemps to
standardize in so far as making the basic objects framework
independent. You can thus supply a generic wsgi app to act as your
controller... see wsgiref package docs. Or, you can of course use any
app framework of your choice.

But, as a small, ultra-lightweight templating system that can be used
in a web context or as standalone, you should really take a look at
Evoque Templating: http://evoque.gizmojo.org/

All the power of any fully featured text-based templating system and
then some (no constraints on template file names or formats,
restricted execution, automatic XSS protection, ...) while being also
incredibly fast. And the simplicity of the system means you can learn
it really quickly, and remember it...

Btw, you may be interested in a small example of wsgi based app that
uses evoque -- one of the examples of how to use evoque under various
contexts:
http://evoque.gizmojo.org/ext/

mario
 
B

Bruno Desthuilliers

John Salerno a écrit :
I just installed Pylons onto my hosting server so I could try out
templating with Mako, but it seems a little more complicated than that.

Err... Actually, it's certainly a little less complicated than that.
First point: Mako is totally independant from Pylons. Second point: you
don't need any web server to use Mako - it's just another Python package.
 
J

John Salerno

Bruno said:
John Salerno a écrit :

Err... Actually, it's certainly a little less complicated than that.
First point: Mako is totally independant from Pylons. Second point: you
don't need any web server to use Mako - it's just another Python package.

Well, so far I have installed Pylons onto my web server, but a test Mako
template isn't rendering, it just prints the text to the browser.
There's got to be something more to do to get it all hooked up so that
it works.
 
M

Matt Nordhoff

John said:
Well, so far I have installed Pylons onto my web server, but a test Mako
template isn't rendering, it just prints the text to the browser.
There's got to be something more to do to get it all hooked up so that
it works.

What do you mean by "the text"? The source code of the template? A
random insult? The generated page? If it's the last, you forgot to set a
Content-Type header.
--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top