From 8889d2c1bc7c527271909c0896e5d053c6aa369e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 14 Jul 2007 21:57:51 +0000 Subject: - improved ability to get the "correct" and most minimal set of primary key columns from a join, equating foreign keys and otherwise equated columns. this is also mostly to help inheritance scenarios formulate the best choice of primary key columns. [ticket:185] - added 'bind' argument to Sequence.create()/drop(), ColumnDefault.execute() --- lib/sqlalchemy/util.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/util.py') diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index c827f1e7d..b47822d61 100644 --- a/lib/sqlalchemy/util.py +++ b/lib/sqlalchemy/util.py @@ -10,6 +10,7 @@ except ImportError: import dummy_thread as thread import dummy_threading as threading +from sqlalchemy import exceptions import md5 import sys import warnings @@ -128,7 +129,16 @@ def duck_type_collection(col, default=None): return dict else: return default - + +def assert_arg_type(arg, argtype, name): + if isinstance(arg, argtype): + return arg + else: + if isinstance(argtype, tuple): + raise exceptions.ArgumentError("Argument '%s' is expected to be one of type %s, got '%s'" % (name, ' or '.join(["'%s'" % str(a) for a in argtype]), str(type(arg)))) + else: + raise exceptions.ArgumentError("Argument '%s' is expected to be of type '%s', got '%s'" % (name, str(argtype), str(type(arg)))) + def warn_exception(func): """executes the given function, catches all exceptions and converts to a warning.""" try: -- cgit v1.2.1