推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
GreyChen223
V2EX  ›  Python

想请教一个有关于 mongoengine 的问题

  •  
  •   GreyChen223 · May 1, 2017 · 3062 views
    This topic created in 3458 days ago, the information mentioned may be changed or developed.
    mongoengine 有没有一个类似 django 内建 orm 里面 models 的 post_save/pre_save 函数一样的 可以在指定 documen save 之前或之后触发一个函数的?
    7 replies  •  2017-05-02 11:31:45 +08:00
    GreyChen223
        1
    GreyChen223  
    OP
       May 1, 2017
    请教了一下别人找到了解决方案
    1.可以重写 save 方法
    2.可以使用 mongoengine 的 singal 系统
    111111111111
        2
    111111111111  
       May 1, 2017
    唔…… django 的 post_save/pre_save 不是信号么
    Kilerd
        3
    Kilerd  
       May 1, 2017 via iPhone
    他的 signal 十分不好用
    yanzixuan
        4
    yanzixuan  
       May 2, 2017
    @huisezhiyin mongo 没有触发器,所以你要搞这样的指望不了 mongo 本身了,只能靠代码里搞 /
    GreyChen223
        5
    GreyChen223  
    OP
       May 2, 2017
    @111111111111 使用了 mongoengine 操作 mongo 并不是使用 django 的 orm
    GreyChen223
        6
    GreyChen223  
    OP
       May 2, 2017
    @yanzixuan mongoengine 有一个类装饰器拥有和 django 的 post_save/pre_save 一样的功能
    GreyChen223
        7
    GreyChen223  
    OP
       May 2, 2017
    @Kilerd 有比没有好 如果真的不好用的话 考虑重写 save 方法 在 super() save 之前发送一个信号
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   943 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 20:13 · PVG 04:13 · LAX 13:13 · JFK 16:13
    ♥ Do have faith in what you're doing.