Author: hwright
Date: Fri Aug 5 17:14:24 2011
New Revision: 1154320
URL: http://svn.apache.org/viewvc?rev=1154320&view=rev
Log:
On the fs-py branch:
Introduce an exception type which can be used to throw errors back to
Subversion from Python.
We put the execption type into a static variable in the python util layer,
where it will be useful for future checks.
* subversion/python/svn/__init__.py
(SubversionException): New.
* subversion/libsvn_fs_py/py_util.c
(p_exception_type): New.
(finalize_python): Release the exception type object.
(svn_fs_py__init_py): Attempt to grab the exception type.
Modified:
subversion/branches/fs-py/subversion/libsvn_fs_py/py_util.c
subversion/branches/fs-py/subversion/python/svn/__init__.py
Modified: subversion/branches/fs-py/subversion/libsvn_fs_py/py_util.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_fs_py/py_util.c?rev=1154320&r1=1154319&r2=1154320&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/libsvn_fs_py/py_util.c (original)
+++ subversion/branches/fs-py/subversion/libsvn_fs_py/py_util.c Fri Aug 5
17:14:24 2011
@@ -30,6 +30,7 @@
#define ROOT_MODULE_NAME "svn"
+static PyObject *p_exception_type;
static PyObject *p_root_module;
static svn_error_t *
@@ -89,6 +90,8 @@ load_error:
static apr_status_t
finalize_python(void *data)
{
+ Py_DECREF(p_exception_type);
+ p_exception_type = NULL;
Py_DECREF(p_root_module);
p_root_module = NULL;
@@ -110,6 +113,16 @@ svn_fs_py__init_python(apr_pool_t *pool)
apr_pool_cleanup_null);
SVN_ERR(load_module(&p_root_module, ROOT_MODULE_NAME));
+
+ p_exception_type = PyObject_GetAttrString(p_root_module,
+ "SubversionException");
+ if (PyErr_Occurred())
+ {
+ PyErr_Clear();
+ return svn_error_create(SVN_ERR_FS_GENERAL, NULL,
+ _("Cannot load Python module"));
+ }
+
return SVN_NO_ERROR;
}
Modified: subversion/branches/fs-py/subversion/python/svn/__init__.py
URL:
http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/python/svn/__init__.py?rev=1154320&r1=1154319&r2=1154320&view=diff
==============================================================================
--- subversion/branches/fs-py/subversion/python/svn/__init__.py (original)
+++ subversion/branches/fs-py/subversion/python/svn/__init__.py Fri Aug 5
17:14:24 2011
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+class SubversionException(Exception):
+ def __init__(self, msg, code = 0):
+ self.message = msg
+ self.code = code
+
+ def __str__(self):
+ return self.message