当前位置: 首页>>代码示例>>Python>>正文


Python Event.register_delete_rule方法代码示例

本文整理汇总了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)
开发者ID:parthibanloganathan,项目名称:adi-website,代码行数:26,代码来源:__init__.py


注:本文中的app.models.Event.register_delete_rule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。