diff options
author | Paul Johnston <paj@pajhome.org.uk> | 2007-10-17 11:23:39 +0000 |
---|---|---|
committer | Paul Johnston <paj@pajhome.org.uk> | 2007-10-17 11:23:39 +0000 |
commit | a0748b3d66c8afa217b1356ea7a4d0599b7c5c6c (patch) | |
tree | 693d5ed7014c14ccd60f3c7ba6847ecb303004e4 /lib/sqlalchemy/ext/activemapper.py | |
parent | 5154d304181ec7f2203e9c02db3c7d41dafc79b5 (diff) | |
download | sqlalchemy-a0748b3d66c8afa217b1356ea7a4d0599b7c5c6c.tar.gz |
Make ActiveMapper support viewonly property
Diffstat (limited to 'lib/sqlalchemy/ext/activemapper.py')
-rw-r--r-- | lib/sqlalchemy/ext/activemapper.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/sqlalchemy/ext/activemapper.py b/lib/sqlalchemy/ext/activemapper.py index 5f9aba956..2a39fe970 100644 --- a/lib/sqlalchemy/ext/activemapper.py +++ b/lib/sqlalchemy/ext/activemapper.py @@ -36,7 +36,7 @@ class column(object): # class relationship(object): def __init__(self, classname, colname=None, backref=None, private=False, - lazy=True, uselist=True, secondary=None, order_by=False): + lazy=True, uselist=True, secondary=None, order_by=False, viewonly=False): self.classname = classname self.colname = colname self.backref = backref @@ -45,6 +45,7 @@ class relationship(object): self.uselist = uselist self.secondary = secondary self.order_by = order_by + self.viewonly = viewonly def process(self, klass, propname, relations): relclass = ActiveMapperMeta.classes[self.classname] @@ -65,7 +66,8 @@ class relationship(object): private=self.private, lazy=self.lazy, uselist=self.uselist, - order_by=self.order_by) + order_by=self.order_by, + viewonly=self.viewonly) def create_backref(self, klass): if self.backref is None: @@ -83,17 +85,14 @@ class relationship(object): class one_to_many(relationship): - def __init__(self, classname, colname=None, backref=None, private=False, - lazy=True, order_by=False): - relationship.__init__(self, classname, colname, backref, private, - lazy, uselist=True, order_by=order_by) - + def __init__(self, *args, **kwargs): + kwargs['uselist'] = True + relationship.__init__(self, *args, **kwargs) class one_to_one(relationship): - def __init__(self, classname, colname=None, backref=None, private=False, - lazy=True, order_by=False): - relationship.__init__(self, classname, colname, backref, private, - lazy, uselist=False, order_by=order_by) + def __init__(self, *args, **kwargs): + kwargs['uselist'] = False + relationship.__init__(self, *args, **kwargs) def create_backref(self, klass): if self.backref is None: |