Uploading to trunk now. Please give it a try:

$ python web2py.py -S welcome
>>> import StringIO
>>> a=StringIO.StringIO('{{for i in range(10):}}{{=i}}{{pass}}')
>>> response.render(a)
'0123456789'

This means in view you can do

{{=response.render(s)}} and {{=cache.ram('key',lambda: response.render
(s),5000)}}
where s is any stream-like object with a read method.

Massimo

On Jun 23, 11:29 am, mdipierro <[email protected]> wrote:
> This could be a possibility. I will experiment.
>
> On Jun 23, 6:45 am, AchipA <[email protected]> wrote:
>
> > Could response.view also be a handle (or maybe response.viewhandle ?).
> > That way we could throw a (c)StringIO at response view, and StringIO
> > can wrap db fields, python strings or whatever we want.
>
> > Note that response.stream already works this way so it would be
> > perhaps more consequential, too.
>
> > On Jun 22, 9:03 pm, mdipierro <[email protected]> wrote:
>
> > > I should be able to di it tomorrow if no major obstacles.
>
> > > Massimo
>
> > > On Jun 22, 12:01 pm, Ted G <[email protected]> wrote:
>
> > > > Hi Massimo,
>
> > > > I've been watching trunk. Have you had any luck with this?
>
> > > > Ted
>
> > > > On Jun 18, 8:31 pm, mdipierro <[email protected]> wrote:
>
> > > > > not easy to do now, but easy to add. I will add this to trunk
> > > > > tomorrow.
>
> > > > > Massimo
>
> > > > > On Jun 18, 4:30 pm, Ted G <[email protected]> wrote:
>
> > > > > > I have an application in which I need to have the view rendered by a
> > > > > > controller be specified using a parameter to that controller.
>
> > > > > > I believe I could do the following based on what I've dug up in this
> > > > > > forum:
>
> > > > > > def index():
>
> > > > > >   try:
> > > > > >     response.view='default/' + request.args[0]  # eg.
> > > > > > 'indexview2.html'
> > > > > >    except:
> > > > > >     response.view='default/index.html'
>
> > > > > >   return dict(message=T('Hello World'))
>
> > > > > > Ideally, as I come up with new view templates, I would like to 
> > > > > > upload
> > > > > > them to the appropriate directory, allowing me to request an 
> > > > > > alternate
> > > > > > view by simply passing the filename of the new view to this
> > > > > > controller.
>
> > > > > > The problem is that I am running my application on Google App 
> > > > > > Engine,
> > > > > > therefore to upload new views I would have to update my application,
> > > > > > which is not practical if I am frequently adding new views.
>
> > > > > > The ideal solution would be to store the new view in a text or blob
> > > > > > field within a table of the database and then be able to use that 
> > > > > > text/
> > > > > > blob/string as the input to response.view instead of a file.
>
> > > > > > Is this at all possible under web2py's current template processing
> > > > > > (processing a view from a blobl/text/string instead of file).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to