本文整理汇总了Python中app.models.Event.register_delete_rule方法的典型用法代码示例。如果您正苦于以下问题:Python Event.register_delete_rule方法的具体用法?Python Event.register_delete_rule怎么用?Python Event.register_delete_rule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.models.Event
的用法示例。
在下文中一共展示了Event.register_delete_rule方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_delete_rules
# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import register_delete_rule [as 别名]
def register_delete_rules():
"""Registers rules for how Mongoengine handles the deletion of objects
that are being referenced by other objects.
See the documentation for :func:`mongoengine.model.register_delete_rule`
for more information.
All delete rules for User fields must by DENY, because User objects should
never be deleted. Lists of reference fields should PULL, to remove deleted
objects from the list, and all others should NULLIFY
"""
from app.models import Event, EventSeries, User, Post, BlogPost, Image
from mongoengine import NULLIFY, PULL, DENY
Event.register_delete_rule(EventSeries, 'events', PULL)
Image.register_delete_rule(BlogPost, 'images', PULL)
Image.register_delete_rule(User, 'image', NULLIFY)
Image.register_delete_rule(BlogPost, 'featured_image', NULLIFY)
Image.register_delete_rule(Event, 'image', NULLIFY)
EventSeries.register_delete_rule(Event, 'parent_series', NULLIFY)
User.register_delete_rule(Event, 'creator', DENY)
User.register_delete_rule(Image, 'creator', DENY)
User.register_delete_rule(Post, 'author', DENY)
User.register_delete_rule(Post, 'posted_by', DENY)