Added initial implementation of cascading document deletion.

The current implementation is still very basic and needs some polish.
The essence of it is that each Document gets a new meta attribute called
"delete_rules" that is a dictionary containing (documentclass,
fieldname) as key and the actual delete rule as a value.  (Possible
values are DO_NOTHING, NULLIFY, CASCADE and DENY.  Of those, only
CASCADE is currently implented.)
This commit is contained in:
Vincent Driessen
2010-12-05 08:08:55 -08:00
parent 4f3eacd72c
commit 86233bcdf5
4 changed files with 56 additions and 2 deletions

View File

@@ -417,12 +417,13 @@ class ReferenceField(BaseField):
access (lazily).
"""
def __init__(self, document_type, **kwargs):
def __init__(self, document_type, delete_rule=None, **kwargs):
if not isinstance(document_type, basestring):
if not issubclass(document_type, (Document, basestring)):
raise ValidationError('Argument to ReferenceField constructor '
'must be a document class or a string')
self.document_type_obj = document_type
self.delete_rule = delete_rule
super(ReferenceField, self).__init__(**kwargs)
@property