Hey Jason, Thank you for the quick reply.
For some reason I was assuming mod_wsgi was embedding Python in the "PSP" way as well. But you lost me on your html code there. What did you just do? Did you just after all implement Python syntax in HTML without any template/framework? My other approach was to make use of Mako, but since that too is a template I am yet to adhere to the template terminology :( I have a Mako thread running here, but they are quite inactive in that group. https://groups.google.com/forum/#!topic/mako-discuss/kiC6zAN0VmY To say the least, I am struggling to find a simple, light and "up-to-date" method in allowing Python to work directly inside HTML, thus why you surprised me there, please do share :) On Friday, October 5, 2012 10:01:33 PM UTC+1, Jason Garber wrote: > > 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 > <[email protected]<javascript:> > > 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 [email protected]<javascript:> >> . >> To unsubscribe from this group, send email to >> [email protected] <javascript:>. >> 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 view this discussion on the web visit https://groups.google.com/d/msg/modwsgi/-/xZHEzegEbl8J. 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/modwsgi?hl=en.
