Changeset 355 for elixir/trunk/elixir/relationships.py
- Timestamp:
- 07/07/08 14:55:41 (5 years ago)
- Files:
-
- 1 modified
-
elixir/trunk/elixir/relationships.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
elixir/trunk/elixir/relationships.py
r350 r355 413 413 414 414 kwargs.update(self.get_prop_kwargs()) 415 415 416 self.property = relation(self.target, **kwargs) 416 417 self.add_mapper_property(self.name, self.property) … … 451 452 452 453 def is_inverse(self, other): 453 return other is not self and \ 454 # viewonly relationships shouldn't match as inverse of anything (so 455 # that no backref is created -- which doesn't make sense in that case) 456 viewonly = self.kwargs.get('viewonly', False) or \ 457 other.kwargs.get('viewonly', False) 458 return not viewonly and \ 459 other is not self and \ 454 460 self.match_type_of(other) and \ 455 461 self.entity == other.target and \ … … 612 618 613 619 def create_keys(self, pk): 620 # When using a viewonly relationship, you are on your own: Elixir 621 # doesn't check that a corresponding ManyToOne relationship exists. 622 if self.kwargs.get('viewonly', False): 623 return 624 614 625 # make sure an inverse relationship exists 615 626 if self.inverse is None: … … 637 648 kwargs['remote_side'] = self.inverse.foreign_key 638 649 639 if self.inverse.primaryjoin_clauses: 640 kwargs['primaryjoin'] = and_(*self.inverse.primaryjoin_clauses) 650 # viewonly relationships do not have any inverse (and they provide 651 # their primaryjoin argument manually anyway). 652 if not self.kwargs.get('viewonly', False): 653 if self.inverse.primaryjoin_clauses: 654 kwargs['primaryjoin'] = and_(*self.inverse.primaryjoin_clauses) 641 655 642 656 kwargs.update(self.kwargs)
