The first argument in your cache decorator ( request.env.path_info ) is the key that the cache system uses to determine uniqueness.  If you have a form in your view, then you need to insert all levels of uniqueness into this key.  Perhaps something like this...
cachekey = str(request.env.path_info)+str(dict(request.vars))+str(request.args)
@cache(cachekey,time_expire=20,cache_model=cache.disk)
would do the trick.  If the page is restricted based on authentication, you'll also need to include some sort of unique user identification in the cachekey variable.

-tim

voltron wrote:
Thanks Massimo,

The web2PY generic template is not displayed anymore. BUT I have a
more serious problem, forms rendered in the cached view function are
not validated and do not work anymore.

Any ideas?


Thanks


On Jan 6, 5:55 pm, mdipierro <[email protected]> wrote:
  
@voltron,

ignore my original response. Tim pointed out the right issue. Correct
your code as

@cache(request.env.path_info,time_expire=20,cache_model=cache.disk)
def index():
    """ This action renders the feedback form """
    response.view = "parents_normal_form.html"
    ....
    return response.render(dict(....))  ### this renders the template
before caching.

Massimo

On Jan 6, 10:53 am, mdipierro <[email protected]> wrote:

    
instead of
      
    return dict()
      
use
      
    return response.render(dict())
      
This is explained inhttp://mdp.cti.depaul.edu/examples/default/examples
      
Massimo
      
On Jan 6, 10:45 am, Timothy Farrell <[email protected]> wrote:
      
So when you use the cache decorator on a controller, it only caches the controller output...not the rendered view?
If someone wanted to cache the rendered view, how would they do that?
-tim
mdipierro wrote:Because you override the view in the action which is not executed when cached. To fix it, outside the index function add if request.function=='index': response.view = "parents_normal_form.html" Massimo On Jan 6, 10:07 am, voltron<[email protected]>wrote:I used disk and RAM, like I mentioned above, no errors except that it shows web2pys generic template instead of the one I declared On Jan 6, 3:49 pm, mdipierro<[email protected]>wrote:Do you get the error using cache.ram instead of cache.disk? How does the problem manifest? Do you get an empty page? An error? Can you add a print statement to check whether the controller is executed when you see the error?Why are you using cache.disk over cache.ram? The former involved picklying so the latter is much faster.massimoOn Jan 6, 8:09 am, voltron<[email protected]>wrote:Here is an example:@cache(request.env.path_info,time_expire=20,cache_model=cache.disk) def index(): """ This action renders the feedback form """ response.view = "parents_normal_form.html"page_title = T("Feedback") page_content = """On Jan 6, 3:07 pm, mdipierro<[email protected]>wrote:Can you provide an example of how you caching a page so that I can try reproduce this?MassimoOn Jan 6, 6:19 am, voltron<[email protected]>wrote:I have a bad problem at the moment, all the views that use cacheing sometimes default to web2py generic template sporadically then are then correct after a refresh. I set the template in the views as such# Exampleresponse.view = "accounts/register.html"Is there some workaround for this
?Thanks-- Timothy Farrell<[email protected]>Computer Guy Statewide General Insurance Agency (www.swgen.com)
        

  

-- 
Timothy Farrell <[email protected]>
Computer Guy
Statewide General Insurance Agency (www.swgen.com)

--~--~---------~--~----~------------~-------~--~----~
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