コード例 #1
0
ファイル: slug_fields.py プロジェクト: rfResearch/udata
 def __get__(self, instance, owner):
     # mongoengine calls this after document initialization
     # We register signals handlers here to have a owner reference
     if not hasattr(self, 'owner'):
         self.owner = owner
         pre_save.connect(self.populate_on_pre_save, sender=owner)
         if self.follow:
             post_delete.connect(self.cleanup_on_delete, sender=owner)
     return super(SlugField, self).__get__(instance, owner)
コード例 #2
0
ファイル: __init__.py プロジェクト: rfResearch/udata
def register(adapter):
    '''Register a search adapter'''
    # register the class in the catalog
    if adapter.model and adapter.model not in adapter_catalog:
        adapter_catalog[adapter.model] = adapter
        # Automatically (re|un)index objects on save/delete
        post_save.connect(reindex_model_on_save, sender=adapter.model)
        post_delete.connect(unindex_model_on_delete, sender=adapter.model)
    return adapter
コード例 #3
0
ファイル: slug_fields.py プロジェクト: opendatateam/udata
 def __get__(self, instance, owner):
     # mongoengine calls this after document initialization
     # We register signals handlers here to have a owner reference
     if not hasattr(self, 'owner'):
         self.owner = owner
         pre_save.connect(self.populate_on_pre_save, sender=owner)
         if self.follow:
             post_delete.connect(self.cleanup_on_delete, sender=owner)
     return super(SlugField, self).__get__(instance, owner)
コード例 #4
0
ファイル: slug_fields.py プロジェクト: odtvince/udata
 def __init__(self, populate_from=None, update=False, lower_case=True,
              separator='-', follow=False, **kwargs):
     kwargs.setdefault('unique', True)
     self.populate_from = populate_from
     self.update = update
     self.lower_case = lower_case
     self.separator = separator
     self.follow = follow
     super(SlugField, self).__init__(**kwargs)
     if follow:
         # Can't use sender=self.owner_document which is not yet defined
         post_delete.connect(self.cleanup_on_delete)
コード例 #5
0
 def __init__(self,
              populate_from=None,
              update=False,
              lower_case=True,
              separator='-',
              follow=False,
              **kwargs):
     kwargs.setdefault('unique', True)
     self.populate_from = populate_from
     self.update = update
     self.lower_case = lower_case
     self.separator = separator
     self.follow = follow
     super(SlugField, self).__init__(**kwargs)
     if follow:
         # Can't use sender=self.owner_document which is not yet defined
         post_delete.connect(self.cleanup_on_delete)