Commit 1a9de5a9 authored by Christophe Dumez's avatar Christophe Dumez

- Worked on commit (login/cookie is working + SSL Trust)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6431 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4853cc2c
...@@ -59,9 +59,13 @@ try: ...@@ -59,9 +59,13 @@ try:
class SubversionLoginError(SubversionError): class SubversionLoginError(SubversionError):
"""Raised when an authentication is required. """Raised when an authentication is required.
""" """
# Declarative Security
security = ClassSecurityInfo()
def __init__(self, realm = None): def __init__(self, realm = None):
self._realm = realm self._realm = realm
security.declarePublic('getRealm')
def getRealm(self): def getRealm(self):
return self._realm return self._realm
...@@ -105,7 +109,7 @@ try: ...@@ -105,7 +109,7 @@ try:
class GetLoginCallback(Callback): class GetLoginCallback(Callback):
def __call__(self, realm, username, may_save): def __call__(self, realm, username, may_save):
user, password = self.client.getLogin(realm) user, password = self.client.getLogin(realm)
if user is None: if not username or not password:
self.client.setException(SubversionLoginError(realm)) self.client.setException(SubversionLoginError(realm))
#raise SubversionLoginError(realm) #raise SubversionLoginError(realm)
return False, '', '', False return False, '', '', False
...@@ -197,10 +201,14 @@ try: ...@@ -197,10 +201,14 @@ try:
#self.client.callback_ssl_server_trust_prompt = self.callback_ssl_server_trust_prompt #self.client.callback_ssl_server_trust_prompt = self.callback_ssl_server_trust_prompt
self.creation_time = time.time() self.creation_time = time.time()
self.__dict__.update(kw) self.__dict__.update(kw)
self.exception = None
def getLogMessage(self): def getLogMessage(self):
return self.log_message return self.log_message
def getLogin(self, realm):
return self.aq_parent._getLogin(realm)
def _getPreferences(self): def _getPreferences(self):
self.working_path = self.getPortalObject().portal_preferences.getPreference('subversion_working_copy') self.working_path = self.getPortalObject().portal_preferences.getPreference('subversion_working_copy')
if not self.working_path : if not self.working_path :
...@@ -237,8 +245,12 @@ try: ...@@ -237,8 +245,12 @@ try:
self._getPreferences() self._getPreferences()
try: try:
return self.client.checkin(path, log_message=log_message, recurse=recurse) return self.client.checkin(path, log_message=log_message, recurse=recurse)
except pysvn.ClientError: except pysvn.ClientError, error:
raise self.getException() excep = self.getException()
if excep:
raise excep
else:
raise error
def status(self, path, **kw): def status(self, path, **kw):
# Since plain Python classes are not convenient in Zope, convert the objects. # Since plain Python classes are not convenient in Zope, convert the objects.
...@@ -258,6 +270,8 @@ try: ...@@ -258,6 +270,8 @@ try:
InitializeClass(SubversionSSLTrustError) InitializeClass(SubversionSSLTrustError)
allow_class(SubversionSSLTrustError) allow_class(SubversionSSLTrustError)
InitializeClass(SubversionLoginError)
allow_class(SubversionLoginError)
except ImportError: except ImportError:
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
......
...@@ -386,9 +386,6 @@ class SubversionTool(UniqueObject, Folder): ...@@ -386,9 +386,6 @@ class SubversionTool(UniqueObject, Folder):
expires = (DateTime() + 1).toZone('GMT').rfc822() expires = (DateTime() + 1).toZone('GMT').rfc822()
response.setCookie(self.login_cookie_name, value, path = '/', expires = expires) response.setCookie(self.login_cookie_name, value, path = '/', expires = expires)
# def setLogin(self, username, passwd):
# self.login = (username, passwd)
def _getLogin(self, target_realm): def _getLogin(self, target_realm):
request = self.REQUEST request = self.REQUEST
cookie = request.get(self.login_cookie_name) cookie = request.get(self.login_cookie_name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment