Permalink
Browse files

Updating the egg file for 2.6, as well as the source tarball.

  • Loading branch information...
1 parent 864d8a9 commit 94a9adee17f825771f73377437e23aaf7fc374dd Aurynn Shaw committed Jul 20, 2010
View
BIN .DS_Store
Binary file not shown.
@@ -0,0 +1,23 @@
+Metadata-Version: 1.0
+Name: Exceptable
+Version: 0.1.0
+Summary: DB Exception Management
+Home-page: https://public.commandprompt.com/projects/exceptable/wiki
+Author: Aurynn Shaw, Commandprompt, Inc.
+Author-email: ashaw@commandprompt.com
+License: LGPL
+Download-URL: https://projects.commandprompt.com/public/exceptable/repo/dist/Exceptable-0.1.0.tar.gz
+Description:
+ What is Exceptable?
+ ===================
+ Exceptable is a library that handles matching formatted exceptions raised
+ in PostgreSQL to Python exception types, allowing for a simple and easy
+ process for the database to throw a named exception in Python.
+
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Operating System :: Unix
+Classifier: Topic :: Software Development
@@ -0,0 +1,16 @@
+LICENSE
+MANIFEST.in
+README
+setup.py
+Exceptable.egg-info/PKG-INFO
+Exceptable.egg-info/SOURCES.txt
+Exceptable.egg-info/dependency_links.txt
+Exceptable.egg-info/top_level.txt
+Exceptable.egg-info/zip-safe
+exceptable/__init__.py
+exceptable/base.py
+sql/base.sql
+sql/exceptable-8.4.sql
+sql/exceptable.sql
+test/__init__.py
+test/test_base.py
@@ -0,0 +1 @@
+
@@ -0,0 +1,2 @@
+test
+exceptable
@@ -0,0 +1 @@
+
@@ -0,0 +1,91 @@
+import re
+
+def __factory__(regex):
+
+ class Exceptable(object):
+
+ def __init__(self, wraps, mappings):
+ """
+ * wraps - is the base exception type to wrap.
+ * mappings - the dict of strings to mappings that represent the Exceptable chain.
+ Strings will be searched for in the base exception string using the regex
+ ^[a-zA-Z0-9]{1,}::[\w]{0,}$
+ """
+
+ self.wraps = wraps
+ self.mappings = mappings
+ self.regex = re.compile(regex)
+ self.regex_base = regex
+
+ # We also need to extract the exceptions from the database, for
+ # this particular set of exceptions.
+ # Exceptions are mapped via the exceptable.register function in the
+ # database, and should be queriable and used easily
+
+ def __call__(self, func):
+ def decorates(*args,**kwargs):
+ try:
+ return func(*args,**kwargs)
+ except self.wraps, e:
+ msg = str(e)
+ if self.regex is not None:
+ g = self.regex.match(msg)
+
+ if g:
+ # We have a group match. Woot.
+ if g.group('type') in self.mappings.keys():
+ curr = g.group('type')
+ msg = g.group('msg')
+ raise self.mappings[curr](msg)
+ else:
+ # We don't have a match. Re-raise
+ raise e
+ else:
+ raise e # Why is this even happening?
+ return decorates
+ def add(self, mappings):
+
+ for key, val in mappings.items():
+ # Allows for easy overrides
+ self.mappings[key] = val
+
+ def remove(self, key):
+ if key in self.mappings:
+ del self.mappings[key]
+
+
+ def exception(self, key):
+ if key in self.mappings:
+ return self.mappings.get(key)
+
+ def mapped(self):
+ pass
+
+ def register(self, key, exception):
+ self.mappings[key] = exception
+
+
+ return Exceptable
+
+r = __factory__('^(?P<type>[a-zA-Z]{1,})::(?P<msg>[a-zA-Z\. ]{0,})$')
+class Except(r):
+ """Except
+ User-defined exception trapping. Traps all DB-level exceptions in the
+ format of Except::Message
+ This type can be extended using the .add mechanism.
+ """
+ pass
+
+
+
+"""
+ Use via:
+
+excepts = Except(ProgrammingError, {"PermissionError":PermissionError})
+
+@excepts
+def someFunc():
+
+ db_operation()
+"""
+
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
@@ -18,7 +18,7 @@
""",
author='Aurynn Shaw, Commandprompt, Inc.',
author_email='ashaw@commandprompt.com',
- url='https://projects.commandprompt.com/public/exceptable/wiki',
+ url='https://public.commandprompt.com/projects/exceptable/wiki',
download_url='https://projects.commandprompt.com/public/exceptable/repo/dist/Exceptable-0.1.0.tar.gz',
# install_requires=[
# ],

0 comments on commit 94a9ade

Please sign in to comment.