Skip to content

Commit

Permalink
[#2959] Comments and docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
icmurray committed Oct 4, 2012
1 parent 7afc1fc commit 0ae97a6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 7 additions & 1 deletion ckan/lib/search/__init__.py
Expand Up @@ -116,14 +116,20 @@ class SynchronousSearchPlugin(SingletonPlugin):

def notify(self, entity, operation):

## If a Group's name hsa been changed, then its datasets need to be
## re-indexed.
if (isinstance(entity, model.Group) and
operation == domain_object.DomainObjectOperation.changed):

## Check if the name has changed.
if 'name' in entity.diff():
for dataset in entity.active_packages().all():
dispatch_by_operation(
dataset.__class__.__name__,
get_action('package_show')(
{'model': model, 'ignore_auth': True, 'validate': False},
{'model': model,
'ignore_auth': True,
'validate': False},
{'id': dataset.id}),
operation
)
Expand Down
12 changes: 11 additions & 1 deletion ckan/plugins/interfaces.py
Expand Up @@ -175,10 +175,20 @@ def after_rollback(self, session):

class IDomainObjectModification(Interface):
"""
Receives notification of new, changed and deleted datesets.
Receives notification of new, changed and deleted Package, Resource and
Group objects.
"""

def notify(self, entity, operation):
'''Called when a domain model is created/updated/deleted.
entity - the instance of the Package, Resource or Group that has been
created/updated/deleted.
operation - instance of `domain_object.DomainObjectOperation`
identifying whether the `entity` was created, updated or
deleted.
'''
pass


Expand Down

0 comments on commit 0ae97a6

Please sign in to comment.