Massimo, This works like a charm! Thank you so much.
FYI, I'm using it in the following manner (code simplified for example): import StringIO def show_profile(): # get the user profile data user_profile=db(db.user_profile.id==request.args[0]).select[0] # get the view used to show the profile display_template=db (db.profile_view.id==user_profile.display_template).select()[0] view_text=StringIO.StringIO(display_template.template_text) # get the style used to format the view display_style=db (db.profile_style.id==user_profile.display_style).select()[0] return response.render(view_text,dict (style=display_style.style_text,user_profile=user_profile)) In my application, I'm providing users the ability to select from a list of different views and styles they can use to display their user profile. Since I'm running on GAE, it is painful for me to create and upload new views as part of the app, so with this change, I can now upload new views into the DB as I create them and they then become an available option for the user to select (I administer and control this process to prevent uploading of views that could compromise the system via the template system). The stylesheets are stored in the DB as well, separate from the view, so the user can mix and match the style along with the view to create a custom look to their profile. Thanks again for the change that makes this possible! Ted On Jun 23, 12:29 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > 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 <mdipie...@cs.depaul.edu> wrote: > > > > > This could be a possibility. I will experiment. > > > On Jun 23, 6:45 am, AchipA <attila.cs...@gmail.com> 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 <mdipie...@cs.depaul.edu> wrote: > > > > > I should be able to di it tomorrow if no major obstacles. > > > > > Massimo > > > > > On Jun 22, 12:01 pm, Ted G <tedg...@gmail.com> wrote: > > > > > > Hi Massimo, > > > > > > I've been watching trunk. Have you had any luck with this? > > > > > > Ted > > > > > > On Jun 18, 8:31 pm, mdipierro <mdipie...@cs.depaul.edu> 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 <tedg...@gmail.com> 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 web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---