4

I'm registering pysvn.Client.callback_get_login callback, but I want my callback to be defined under my class, as method, rather then global function.

So, in my class I want to have something like:

self.client = pysvn.Client()
self.client.callback_get_login = self.get_login

instead:

self.client = pysvn.Client()
self.client.callback_get_login = get_login

But in 1st snippet I'm getting error:

pysvn._pysvn_2_7.ClientError: unhandled exception in callback_get_login

Is there a way to assign callback that is inside a class?

1 Answer 1

6

I encountered the same problem and solve it by creating a closure for my login func :

class DummyClient:
   def __init__(self):
      def callback_get_login(realm, username, may_save):
         name = raw_input("Enter your svn login : ")
         password = getpass.getpass("Enter your svn password :")
         return True, name, password, False
      self.client.callback_get_login = callback_get_login
Sign up to request clarification or add additional context in comments.

1 Comment

That works. Thanks! Since I store username and password as DummyClient class attributes, I thought I can't access them from closure with self.username and self.password, but I can. Which is good in my case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.