Re: beaker_cache query_args when duplicate queries are in
Previously Philip Jenvey wrote: I just applied a fix that now correctly handles eleith's issue with duplicate query params, and always includes the function name regardless of the key type specified. A fix was made about a month ago to make it work everywhere (not just controller actions) again. That has not yet made it into a release though. Wichert. -- Wichert Akkerman wich...@wiggy.netIt is simple to make things. http://www.wiggy.net/ It is hard to make things simple. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: beaker_cache query_args when duplicate queries are in
Previously Philip Jenvey wrote: I just applied a fix that now correctly handles eleith's issue with duplicate query params, and always includes the function name regardless of the key type specified. I think you also need to add the class name if you get a bound function: you may very well have the same function name in multiple classes in the same source file. I also found another problem in the determination of the cache key: default function arguments were not handled correctly. I've filed that under http://pylonshq.com/project/pylonshq/ticket/568 along with a fix. Wichert. -- Wichert Akkerman wich...@wiggy.netIt is simple to make things. http://www.wiggy.net/ It is hard to make things simple. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: beaker_cache query_args when duplicate queries are in
On Feb 11, 2009, at 3:38 AM, Wichert Akkerman wrote: Previously Philip Jenvey wrote: I just applied a fix that now correctly handles eleith's issue with duplicate query params, and always includes the function name regardless of the key type specified. I think you also need to add the class name if you get a bound function: you may very well have the same function name in multiple classes in the same source file. The class's name and module name are used for the cache's namespace, which'll prevent clashes. For normal functions just the function's module name is used for the namespace. Looking at this again maybe the class name should be in the key instead of the namespace, but that's not a big deal. By the time you read this an rc5 will likely be out with all these fixes. -- Philip Jenvey --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: beaker_cache query_args when duplicate queries are in
On 2/11/09 11:12 PM, Philip Jenvey wrote: The class's name and module name are used for the cache's namespace, which'll prevent clashes. For normal functions just the function's module name is used for the namespace. Looking at this again maybe the class name should be in the key instead of the namespace, but that's not a big deal. By the time you read this an rc5 will likely be out with all these fixes. Thanks! I'm looking forward to it. Wichert. -- Wichert Akkermanwich...@wiggy.netIt is simple to make things. http://www.wiggy.net/ It is hard to make things simple. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: beaker_cache query_args when duplicate queries are in
On Feb 9, 2009, at 4:33 AM, Wichert Akkerman wrote: Previously eleith wrote: My solution was to write my own decorator. could you share your decorator? For what it's worth below is my variant of beaker_cache. It has the advantage over the stock version that it works everywhere instead of only for controller methods and will never try to cache response headers. I think the latest tip solves all the complaints with beaker_cache in this thread. I just applied a fix that now correctly handles eleith's issue with duplicate query params, and always includes the function name regardless of the key type specified. A fix was made about a month ago to make it work everywhere (not just controller actions) again. There's been a toggle to specify which cache headers it preserves for a while now. -- Philip Jenvey --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: beaker_cache query_args when duplicate queries are in
Previously eleith wrote: My solution was to write my own decorator. could you share your decorator? For what it's worth below is my variant of beaker_cache. It has the advantage over the stock version that it works everywhere instead of only for controller methods and will never try to cache response headers. The only missing feature I can think of is a simple way to add request headers to the cache key. That is trivial to add, but not needed for my current projects so I haven't added that. Wichert. def timed(expire=None, invalidate_on_startup=False, **b_kwargs): Cache decorator utilizing Beaker. Caches action or other function that returns a pickle-able object as a result. Optional arguments: ``expire`` Time in seconds before cache expires, or the string never. Defaults to never ``invalidate_on_startup`` If True, the cache will be invalidated each time the application starts or is restarted. If cache_enabled is set to False in the .ini file, then cache is disabled globally. if invalidate_on_startup: starttime = time.time() else: starttime = None def wrapper(func, *args, **kwargs): Decorator wrapper enabled = pylons.config.get(cache_enabled, True) if not asbool(enabled): log.debug(Caching disabled, skipping cache lookup) return func(*args, **kwargs) key_dict=kwargs.copy() key_dict.update(_make_dict_from_args(func, args)) cache_key = .join([%s=%s % (k, v) for k, v in key_dict.iteritems()]) if hasattr(func, im_class): namespace=%s.%s.%s % (func.__module__, func.im_class.__name__, func.__name__) else: namespace=%s.%s % (func.__module__, func.__name__) my_cache = pylons.cache.get_cache(namespace, **b_kwargs) def create_func(): log.debug(Creating new cache copy with key: %s, cache_key) return func(*args, **kwargs) return my_cache.get_value(cache_key, createfunc=create_func, expiretime=expire, starttime=starttime) return decorator(wrapper) -- Wichert Akkerman wich...@wiggy.netIt is simple to make things. http://www.wiggy.net/ It is hard to make things simple. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: beaker_cache query_args when duplicate queries are in
My solution was to write my own decorator. could you share your decorator? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
beaker_cache query_args when duplicate queries are in
i've got a controller that will accept multiple same name args in the query string ?id=10id=100id=50 it looks like beaker_cache does not interpret these as different query strings, so ?id=10id=100id=50 will return the same as ?id=10id=100id=20id=50 any recommended workarounds for this? on a tangential note, does beaker_cache support keying on a controllers 'action' as well as a 'query_arg' ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: beaker_cache query_args when duplicate queries are in
yes, you're right it's totally weird that the key beaker_cache uses for caching controller actios, doesn't include the action in it by default. My solution was to write my own decorator. On Feb 6, 1:52 pm, eleith ele...@gmail.com wrote: i've got a controller that will accept multiple same name args in the query string ?id=10id=100id=50 it looks like beaker_cache does not interpret these as different query strings, so ?id=10id=100id=50 will return the same as ?id=10id=100id=20id=50 any recommended workarounds for this? on a tangential note, does beaker_cache support keying on a controllers 'action' as well as a 'query_arg' ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---