Hi Marc,

I think you are not understanding what mod_wsgi is.

*"The aim of mod_wsgi is to implement a simple to use
Apache<http://httpd.apache.org/> module
which can host any Python <http://www.python.org/> application which
supports the Python WSGI <http://www.wsgi.org/>interface. The module would
be suitable for use in hosting high performance production web sites, as
well as your average self managed personal sites running on web hosting
services."*

WSGI is the "Web Server Gateway Interface", as (mostly) defined in
http://www.python.org/dev/peps/pep-0333/

mod_wsgi provides a mechanism to connect apache with python, so that python
can form a response to a web request.  However, the interface is very
basic.  Python is expected to return the (usually html) data directly.

Any templating type systems would happen at a level above mod_wsgi.  Take a
look at some of the python web frameworks out there (bottle, flask, django,
etc...) to see what they have to offer.

Under mod_python, the PSP handler is what was responsible for the syntax
you were referencing.  In the same way, if such a thing exists to be run
under WSGI, it would be a separate project (and be able to run on any
compliant wsgi server).

I am not personally aware of such a thing.  Personally, I accomplish a
similar feat using python code directly:  Given that HS() is a function
which encodes HTML entities, and QA() is an xmlish quote attribute
function, and UE() is a url encode function:

html = '''
<div>
  <h1>Hi, this is an example</h1>
  <h2>Record List</h2>
*  ''' + ''.join('''*
  <div class="record">
     First Name: ''' + HS(row.FirstName) + '''<br />
     Last Name: ''' + HS(row.LastName) + '''<br />
     <a href=''' + QA('/user/details?id=' + UE(row.ID)) + '''>Details</a>
  </div>
*  ''' for row in GetList()) + '''*
</div>
'''

I've used PHP and ASP.Net razr, and this isn't that much different.  It
requires you to think a little harder sometimes, but it is very possible to
get the same effect using python syntax directly embedded in a view
function.

JG





On Fri, Oct 5, 2012 at 4:50 PM, Marc ThinlineData <m...@thinlinedata.com>wrote:

> I was wondering if mod_wsgi eventually allows me to embed Python code
> directly into HTML such as mod_python does?
>
> I have installed mod_wsgi but I came short to finding any topic that
> pointed me into a direction for allowing me to directly embedding Python
> code into an HTML file.
>
> What I cant really figure out would be what the extension of the files
> would then have to be ( .psp? )
>
> And additionally to that, what is the coding syntax going to look like (
> {% %} ) ?
>
> I was looking at Mako for Python to embed Python code directly into HTML,
> but it seems Mako still uses the template approach. And I am not really to
> happy about the entire MVC terminology for the small fixes and patches I
> need to do on certain websites.
>
> Hope someone can direct me to an article or tutorial that covers mod_wsgi
> with Python embedded into HTML.
>
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/modwsgi/-/g6BQdctrAj8J.
> To post to this group, send email to modwsgi@googlegroups.com.
> To unsubscribe from this group, send email to
> modwsgi+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to modwsgi@googlegroups.com.
To unsubscribe from this group, send email to 
modwsgi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to