
Untitled
By: a guest on
Jun 12th, 2012 | syntax:
Python | size: 0.65 KB | hits: 15 | expires: Never
def __getattribute__(self, name, checkForVersionKey=True):
""" """
actualAttribute = models.Model.__getattribute__(self, name)
if checkForVersionKey:
try:
version = Printable.__getattribute__(self, name+"Version", checkForVersionKey=False)
if version:
model = Printable.__getattribute__(self, "__class__", checkForVersionKey=False)
foreignKeyModel = getattr(model, name).field.related.parent_model
relatedObject = foreignKeyModel.objects.get(copyOfId=actualAttribute.id, version=version)
return relatedObject
except AttributeError: pass
return actualAttribute