Use this method when - * upsert=False is desired * special operators like push, push_all are to be used.
(cls, model_object, publish=True, dispatch_trigger=True, **kwargs)
| 223 | |
| 224 | @classmethod |
| 225 | def update(cls, model_object, publish=True, dispatch_trigger=True, **kwargs): |
| 226 | """ |
| 227 | Use this method when - |
| 228 | * upsert=False is desired |
| 229 | * special operators like push, push_all are to be used. |
| 230 | """ |
| 231 | cls._get_impl().update(model_object, **kwargs) |
| 232 | # update does not return the object but a flag; likely success/fail but docs |
| 233 | # are not very good on this one so ignoring. Explicitly get the object from |
| 234 | # DB abd return. |
| 235 | model_object = cls.get_by_id(model_object.id) |
| 236 | |
| 237 | # Publish internal event on the message bus |
| 238 | if publish: |
| 239 | try: |
| 240 | cls.publish_update(model_object) |
| 241 | except: |
| 242 | LOG.exception("Publish failed.") |
| 243 | |
| 244 | # Dispatch trigger |
| 245 | if dispatch_trigger: |
| 246 | try: |
| 247 | cls.dispatch_update_trigger(model_object) |
| 248 | except: |
| 249 | LOG.exception("Trigger dispatch failed.") |
| 250 | |
| 251 | return model_object |
| 252 | |
| 253 | @classmethod |
| 254 | def delete(cls, model_object, publish=True, dispatch_trigger=True): |