summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-03-29 14:41:41 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-03-29 14:41:41 +0000
commit99ed3922678ac050888dad7ca1c2a2195d65e2c0 (patch)
treef2ce3103168be46e1563dd1a865c229e09ff8d3a /lib/sqlalchemy/util.py
parentc4955c05a3ab40d53c83982da612e746c662640d (diff)
downloadsqlalchemy-99ed3922678ac050888dad7ca1c2a2195d65e2c0.tar.gz
- declarative_base() takes optional kwarg "mapper", which
is any callable/class/method that produces a mapper, such as declarative_base(mapper=scopedsession.mapper). This property can also be set on individual declarative classes using the "__mapper_cls__" property.
Diffstat (limited to 'lib/sqlalchemy/util.py')
-rw-r--r--lib/sqlalchemy/util.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py
index 90332fdc0..8451d28b5 100644
--- a/lib/sqlalchemy/util.py
+++ b/lib/sqlalchemy/util.py
@@ -279,6 +279,14 @@ def get_func_kwargs(func):
"""Return the full set of legal kwargs for the given `func`."""
return inspect.getargspec(func)[0]
+def unbound_method_to_callable(func_or_cls):
+ """Adjust the incoming callable such that a 'self' argument is not required."""
+
+ if isinstance(func_or_cls, types.MethodType) and not func_or_cls.im_self:
+ return func_or_cls.im_func
+ else:
+ return func_or_cls
+
# from paste.deploy.converters
def asbool(obj):
if isinstance(obj, (str, unicode)):