bottlepy/bottle-extras

Unused configuration values

parroit opened this issue · 3 comments

in bottle_memcache, config values for servers,keyword and server_max_value_length are not used after being retrieved.
I guess two referencens to 'self' are missing:

def apply(self, callback, context):
    conf = context['config'].get('memcache') or {}
    #########################################
    #self.servers, self.server_max_value_length,self.password ??
    #########################################
    servers = conf.get('servers', self.servers)
    keyword = conf.get('keyword', self.keyword)
    server_max_value_length = conf.get('server_max_value_length',
        self.server_max_value_length)

    args = inspect.getargspec(context['callback'])[0]
    if keyword not in args:
        return callback

    def wrapper(*args, **kwargs):
        mc = memcache.Client(servers=self.servers,
            server_max_value_length=self.server_max_value_length, debug=0)
        kwargs[self.keyword] = mc
        rv = callback(*args, **kwargs)
        return rv
    return wrapper

Hi @parroit can you try my (still unmerged) branch to see if it fixes your problem?

Hi @thekad, please note that I'm corrently not using the plugin in my code, I revert to creating memcache client directly. Anyway, looking at your changes it appear to be ok now.

Uploaded the fix to https://pypi.python.org/pypi/bottle-memcache after being a complete moron and forgetting about this :(