Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2273 (closed enhancement: fixed)

Opened 10 years ago

Last modified 10 years ago

[PATCH] Pass toscawidgets parameters from TG config so can cache header created

Reported by: LawrenceK Owned by: jorge.vargas
Priority: normal Milestone: 2.1a2
Component: TurboGears Version: 2.0b7
Severity: normal Keywords:
Cc:

Description

Turbogears passes a predefined set of parameters to toscawidgets when it creates the middleware, this means that you cannot override the configuration from externally, i.e. TG configuration files. At the time I was trying to pass a resource_expires value into tw so that it set the cache header to something other than no-cache - the internal default is 0.

This is a patch to tg.core.configuration to pass parameters into the tg middleware and a patch to tw.middleware to pick up a resource_expires header.

See  http://groups.google.com/group/turbogears/browse_thread/thread/cad07193436ad7df thread for more details etc.

Attachments

configuration.patch Download (878 bytes) - added by LawrenceK 10 years ago.
tg configuration patch to pas toscawidgets in.
middleware.diff Download (1.1 KB) - added by LawrenceK 10 years ago.
toscawidgets middleware patch to pick up a resource_expires value

Change History

Changed 10 years ago by LawrenceK

tg configuration patch to pas toscawidgets in.

Changed 10 years ago by LawrenceK

toscawidgets middleware patch to pick up a resource_expires value

comment:1 Changed 10 years ago by LawrenceK

I do appreciate the comment that in a live environment you could/would serve resources through a different server, but the impact of no caching makes page delivery slow.

comment:2 Changed 10 years ago by jorge.vargas

overall the patch seems good. I'll implemented the tg config as a dict.update but that's easily fixable.

I'll suggest you drop a line to the TW ML, so someone with commit access over there could apply the small patch.

I'll assign the ticket to myself and will probably have time earlier next week to commit it, if someone can work on this earlier please do so :)

comment:3 Changed 10 years ago by jorge.vargas

  • Owner set to jorge.vargas

comment:4 Changed 10 years ago by mramm

  • Milestone changed from 2.0rc1 to 2.0rc2

comment:5 Changed 10 years ago by brickenstein

Many thanks for your work. I think, parameters not starting with the correct prefix are ignored, when passing the to toscawidgets make_middleware. What actually seems to be missing, is making available the option in make_middleware in tw/core/middleware.py Michael

comment:6 Changed 10 years ago by LawrenceK

I have created a ticket on the toscawidgets TRAC  http://toscawidgets.org/trac/tw/ticket/39

Thanks for taking the request seriously.

comment:7 Changed 10 years ago by percious

  • Status changed from new to closed
  • Resolution set to fixed

I added this here, but I modified it slightly:

        twconfig = {'toscawidgets.framework.default_view': self.default_renderer,
                    'toscawidgets.framework.translator': ugettext,
                    'toscawidgets.middleware.inject_resources': True,
                    }
        for k,v in config.iteritems(): 
            if k.startswith('toscawidgets.framework.') or k.startswith('toscawidgets.middleware.'): 
                twconfig[k] = v 
                twconfig.update()
        app = tw_middleware(app, twconfig)

}}

By changing the ordering, it is much easier to override the default configuration.

I'm closing this ticket, since there is a TW ticket that covers the other issue.  Since I maintain TW, and I know of the other issue, I should be able to straighten it out.

cheers.
-chris
Note: See TracTickets for help on using tickets.