decorator for opening a connection and passing a cursor to the function

def call_cur(f):
  "decorator for opening a connection and passing a cursor to the function"
  @functools.wraps(f)
  def f2(self, *args, **kwargs):
    with self.withcur() as cur:
      return f(self, cur, *args, **kwargs)
  return f2