From: Robert Kern on
On 2009-12-29 15:26 PM, Aahz wrote:
> In article<4b2602a0$0$30660$426a34cc(a)>,
> Bruno Desthuilliers<bruno.42.desthuilliers(a)websiteburo.invalid> wrote:
>> zeph a �crit :
>>> 4) It's better to collect all your eventual output into a string that
>>> you print
>> Yuck ! Definitly one of the worst advises you could give.
>> <OP>
>> By all mean, *DONT* do that. Use a templating system instead.
>> </OP>
> Because I know Zeph, I know that you two aren't actually disagreeing. ;-)
> Templates are one good way to follow Zeph's advice, but particularly for
> small projects they may be overkill.

I find that Ian Bicking's Tempita is small enough (in terms of code and language
design) to not be overkill for even small tasks.

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

From: Aaron Watters on
Sancar wants to move from PHP to Python.

The following a shameless plug for WHIFF:
-- I wrote it partially because I wanted PHP-like features using
Python, but better ;).

On Dec 11, 5:26 am, Sancar Saran <> wrote:
> Greetings.

> ....After 3 days of crawling google, diving in python and cursing, now  I can show
> something on my linux/apache/mod_wsgi setup.

It's too bad you didn't find the WHIFF quickstart first :).

> And i'm struck on something....
> My design depends on a Global Array. A huge array which store everything about
> requested Web page for a final rendering.
> In PHP accessing globals is easy. You may do direct access or use class
> something like ZEND Registry....
> 1-) Can I create Global (read/write access anywhere from my code) Multi
> dimensional, associative array (or hash) and store any kind of variable type.

There are a number of ways to do things like this in WHIFF
-- one way is to use the WSGI environment to store your
"globals" as illustrated in the Mako tutorial:

> 2-) Is there any error trigger for mod_wsgi. When something go bad I god
> Internal Server error. Looking for error log was't nice. Is there any way to
> shows errors in the web page ?

Configure your application to display tracebacks on errors.
I need to explicitly add this to the documentation, but here
is an example used by the WHIFF documentation app config:

59 whiffDocumentation = resolver.moduleRootApplication("/", docroot,
60 #exception_middleware=None,
61 environment=environment,
62 exception_middleware=displayTraceback.__middleware__,
63 on_not_found=None, # show traceback (could comment)
64 auto_reload=False,
65 )

lines 62 and 63 from

> 3-) Any documents books sites about helping moving from php to python (doesn't explicitly mention PHP).

> 4-) In php we had something like
> ob_start(); // start Output buffering
> require('hede.php'); // include phtml similar to psp. mixed language and html
> (to avoiding string replacement (or marker based) html templates)
> $var = ob_get_clean(); // get rendered output and use anywhere
> can find a similar abilities in Python ?

Of course:

See the quoteHtml implementation, for example

> 5-) is there any Python documentation based on examples. When I give up about
> to finding  php's $_REQUEST or $_SERVER equivalents in python some demo code in
> Twisted docs are much helpful than any other words. Me and my kind already
> have  problem with English language. Example code much more helpful than full
> academic description. (again) there are lots and lots of

I hope you like it and have a happy new year! -- Aaron Watters

my resolution last year
was not to make any resolutions this year.