![]() |
|
|
|||||||
![]() |
Python - Re: Web development with Python 3.1 |
|
|
Thread Tools | Search this Thread |
|
|
#61 |
|
> I took a look a both yesterday. They are both generic text templating
> systems that seem to pretty much do the same thing. I suspect you will > prefer Mako since it avoids duplicating Python's comtrol structures. But I > think it worthwhile to look at both anyway since doing so will help to > separate the concepts from the particular implementations. > > My take on them is this: when text mixes code that is meant to be > interpreted and text data meant to be taken literally, some means must be > devised to distinguish the two. In programs files, the code is left unquoted > and the text data is quoted. In template files, the marking is reversed: the > literal text is left unquoted and the code *is* quoted. In Mako, expressions > are quoted with braces ({...}), single statements with '%' prefix, and > multiple statements as well as Mako tags with <% ...>. > Thanks, Terry, that should save me some time. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il Dotan Cohen |
|
|
|
|
#62 |
|
Posts: n/a
|
On 2009-10-30 15:55 PM, Dotan Cohen wrote:
>>> It is clear and obvious. But it has the "template engine" duplicating >>> a function that Python has built in. My goal is to learn reusable >>> Python (reusable for non-web projects). My goal is not to find the >>> quickest way to a website. >> >> Please correct me if I'm wrong, but you did learn HTML, CSS and SQL, didn't >> you ? How do any of these languages relates to Python ?-) > > HTML and CSS yes, but just enough SQL to fake it. None of those > languages relate to Python, each language performs a different > function. However, the template language looks completely redundant as > it duplicates functionality of the language that I intend to learn. Templating languages serve a different, highly specialized purpose. They may have similar flow constructs, but the context and specializations matter a lot. Use the right language for the job. Sometimes the job is a weird mix of concerns and requires a weird mix of constructs to be convenient. If you're writing web apps, you should learn a templating language. If you're primarily concerned with learning Python and nothing else, you should find a different kind of project. But if you insist, you may be interested in Breve: http://pypi.python.org/pypi/Breve/ -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco Robert Kern |
|
|
|
#63 |
|
Posts: n/a
|
On Oct 28, 5:16*am, "Diez B. Roggisch" <de...@nospam.web.de> wrote:
> Dotan Cohen schrieb: > > > > >> While I know that to be true in the general sense, from what I've > >> looked at Django and other frameworks it seems that the web frameworks > >> push the coder to use templates, not letting him near the HTML. > > >> For instance, I was looking for a class / framework that provided a > >> proven method of decoding cookies (setting them is no problem), > >> decoding POST and GET variables, escaping variables for safe entry > >> into MySQL, and other things. Django and the other frameworks seem to > >> force the user to use templates. I just want the functions, and to > >> print the HTML as stdout to the *browser making the request. I had to > >> settle on PHP to do this, which admittedly is what PHP was invented to > >> do. However, for obvious reasons, I would have prefered to code in > >> Python. In fact, I still would. > > > I should probably expand on this: > > > How can I get an array with all the GET variables in Python? > > How can I get an array with all the POST variables in Python? > > How can I get an array with all the COOKIE variables in Python? > > How can I get the request URI path (everything after > >http://[www.?]example.com/)? > > > That's all I want: no templates and nothing between me and the HTML. > > The HTTP headers I can output to stdout myself as well. > > Again: if you insist on doing everything yourself - then of course any > library or framework isn't for you. > > But then do you deal with headers correctly? Do you respect character > encodings? Form-encodings? Is your generated HTML valid? Are > timestamp-formats generated according to RFCs for your cookies? Do you > parse content negotiation headers? > > I think you underestimate the task it is to make a webapplication good. > And even if not, what you will do is ... code your own webframework. > Because there is a lot of boilerplate otherwis. If that's a > learning-experience your after, fine. > > Besides, yes, you can get all these things nonetheless. You just don't > need them most of the time. > > And at least pylons/TG2 lets you return whatever you want instead, as a > string. Not via "print" though - which is simply only for CGI, and no > other means (e.g. mod_wsgi) of python-web-programming. > > Diez notmm uses Python 2.6 and will probably work just fine with Python 3000. Cheers, Etienne P.S - We all don't think in the same box. erob |
|
|
|
#64 |
|
Posts: n/a
|
On Oct 30, 7:01*pm, erob <robillard.etie...@gmail.com> wrote:
> On Oct 28, 5:16*am, "Diez B. Roggisch" <de...@nospam.web.de> wrote: > > > > > Dotan Cohen schrieb: > > > >> While I know that to be true in the general sense, from what I've > > >> looked at Django and other frameworks it seems that the web frameworks > > >> push the coder to use templates, not letting him near the HTML. > > > >> For instance, I was looking for a class / framework that provided a > > >> proven method of decoding cookies (setting them is no problem), > > >> decoding POST and GET variables, escaping variables for safe entry > > >> into MySQL, and other things. Django and the other frameworks seem to > > >> force the user to use templates. I just want the functions, and to > > >> print the HTML as stdout to the *browser making the request. I had to > > >> settle on PHP to do this, which admittedly is what PHP was invented to > > >> do. However, for obvious reasons, I would have prefered to code in > > >> Python. In fact, I still would. > > > > I should probably expand on this: > > > > How can I get an array with all the GET variables in Python? > > > How can I get an array with all the POST variables in Python? > > > How can I get an array with all the COOKIE variables in Python? > > > How can I get the request URI path (everything after > > >http://[www.?]example.com/)? > > > > That's all I want: no templates and nothing between me and the HTML. > > > The HTTP headers I can output to stdout myself as well. > > > Again: if you insist on doing everything yourself - then of course any > > library or framework isn't for you. > > > But then do you deal with headers correctly? Do you respect character > > encodings? Form-encodings? Is your generated HTML valid? Are > > timestamp-formats generated according to RFCs for your cookies? Do you > > parse content negotiation headers? > > > I think you underestimate the task it is to make a webapplication good. > > And even if not, what you will do is ... code your own webframework. > > Because there is a lot of boilerplate otherwis. If that's a > > learning-experience your after, fine. > > > Besides, yes, you can get all these things nonetheless. You just don't > > need them most of the time. > > > And at least pylons/TG2 lets you return whatever you want instead, as a > > string. Not via "print" though - which is simply only for CGI, and no > > other means (e.g. mod_wsgi) of python-web-programming. > > > Diez > > notmm uses Python 2.6 and will probably work just fine with Python > 3000. > > Cheers, > > Etienne > > P.S - We all don't think in the same box. "I am free, no matter what rules surround me. If I find them tolerable, I tolerate them; if I find them too obnoxious, I break them. I am free because I know that I alone am morally responsible for everything I do." -- Robert A. Heinlein erob |
|
|
|
#65 |
|
Posts: n/a
|
>> notmm uses Python 2.6 and will probably work just fine with Python
>> 3000. >> The only reference to "notmm" that I could find in Google was this thread! > "I am free, no matter what rules surround me. If I find them > tolerable, I tolerate them; if I find them too obnoxious, I break > them. I am free because I know that I alone am morally responsible for > everything I do." -- Robert A. Heinlein > Heinlein said that? It's been a long time since I've read Heinlein, and his quotes are as vivid as his books. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il Dotan Cohen |
|
|
|
#66 |
|
Posts: n/a
|
With respect to to original question regarding web frameworks +
database and Python 3, all the following have been available for Python 3 since the day Python 3.0 was released: QP, a Web Framework http://pypi.python.org/pypi/qp/ Durus, a Python Object Database (the "default" in qp, for user sessions, etc) http://pypi.python.org/pypi/Durus/ Evoque, state-of-the-art templating engine http://pypi.python.org/pypi/evoque/ (this one is available for py3.0 since a little later, 21-jan-2009) All the above also runs on python 2.4 (thru to python 3) For the record, you may see the list of all pypi packages availabe for Python 3 at: http://pypi.python.org/pypi?:action=...show=all&c=533 m. mario ruggier |
|
|
|
#67 |
|
Posts: n/a
|
On Oct 30, 6:23*pm, Dotan Cohen <dotanco...@gmail.com> wrote:
> The point is that I want to use only _Python_ features, not > Django/Mako/whatever features. Pure python has a builtin templating system -- its called % See http://simonwillison.net/2003/Jul/28/simpleTemplates/ rustom |
|
|
|
#68 |
|
Posts: n/a
|
rustom a écrit :
> On Oct 30, 6:23 pm, Dotan Cohen <dotanco...@gmail.com> wrote: > >> The point is that I want to use only _Python_ features, not >> Django/Mako/whatever features. > > Pure python has a builtin templating system -- its called % Poor man's template... It only do variable substitutions - no branching nor iteration (and let's not talk about macros, inclusions, filters etc). Bruno Desthuilliers |
|
|
|
#69 |
|
Posts: n/a
|
On Nov 5, 2:23*pm, Bruno Desthuilliers <bruno.
42.desthuilli...@websiteburo.invalid> wrote: > rustom a écrit : > > > On Oct 30, 6:23 pm, Dotan Cohen <dotanco...@gmail.com> wrote: > > >> The point is that I want to use only _Python_ features, not > >> Django/Mako/whatever features. > > > Pure python has a builtin templating system -- its called *% > > Poor man's template... It only do variable substitutions - no branching > nor iteration (and let's not talk about macros, inclusions, filters etc). I realised that that link http://simonwillison.net/2003/Jul/28/simpleTemplates/ was written in 2003 Subsequently python has sprouted something explicitly templateish http://docs.python.org/library/strin...mplate-strings rustom |
|
|
|
#70 |
|
Posts: n/a
|
rustom a écrit :
> On Nov 5, 2:23 pm, Bruno Desthuilliers <bruno. > 42.desthuilli...@websiteburo.invalid> wrote: >> rustom a écrit : >> >>> On Oct 30, 6:23 pm, Dotan Cohen <dotanco...@gmail.com> wrote: >>>> The point is that I want to use only _Python_ features, not >>>> Django/Mako/whatever features. >>> Pure python has a builtin templating system -- its called % >> Poor man's template... It only do variable substitutions - no branching >> nor iteration (and let's not talk about macros, inclusions, filters etc). > > I realised that that link > http://simonwillison.net/2003/Jul/28/simpleTemplates/ > was written in 2003 > > Subsequently python has sprouted something explicitly templateish > http://docs.python.org/library/strin...mplate-strings Still poor man's template. Just don't hope to do any realworld web templating with this. Bruno Desthuilliers |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Software Development Company | hanusoft | Software | 0 | 12-23-2007 06:52 AM |
| Regarding MSTS SharePoint 2007 and WSS 3.0 Application Development | Shiva | MCTS | 6 | 12-06-2007 06:32 AM |
| Business Software Development | hanusoft | Software | 0 | 11-16-2007 01:21 PM |
| DVD Verdict reviews: ARRESTED DEVELOPMENT: SEASON TWO and more! | DVD Verdict | DVD Video | 0 | 10-11-2005 09:16 AM |
| The Practice Test Package Development: A New Service on the Certification Market | David Johnson | A+ Certification | 0 | 01-19-2005 10:52 AM |