7
7
8
8
from ckan .model .domain_object import DomainObjectOperation
9
9
from ckan .model .resource import Resource
10
+ from ckan .model .package import Package
10
11
11
12
from . import action , auth , helpers as xloader_helpers , utils
12
13
@@ -99,15 +100,15 @@ def configure(self, config_):
99
100
# IDomainObjectModification
100
101
101
102
def notify (self , entity , operation ):
102
- # type: (ckan.model. Package|ckan.model. Resource, DomainObjectOperation) -> None
103
+ # type: (Package|Resource, DomainObjectOperation) -> None
103
104
"""
104
105
Runs before_commit to database for Packages and Resources.
105
106
We only want to check for changed Resources for this.
106
107
We want to check if values have changed, namely the url.
107
108
See: ckan/model/modification.py.DomainObjectModificationExtension
108
109
"""
109
110
if operation != DomainObjectOperation .changed \
110
- or not isinstance (entity , Resource ):
111
+ or not isinstance (entity , Resource ):
111
112
return
112
113
113
114
# If the resource requires validation, stop here if validation
@@ -116,11 +117,13 @@ def notify(self, entity, operation):
116
117
# be called again. However, url_changed will not be in the entity
117
118
# once Validation does the patch.
118
119
if utils .is_validation_plugin_loaded () and \
119
- toolkit .asbool (toolkit .config .get ('ckanext.xloader.requires_validation' )):
120
+ toolkit .asbool (toolkit .config .get ('ckanext.xloader.requires_validation' )):
121
+
120
122
if entity .__dict__ .get ('extras' , {}).get ('validation_status' , None ) != 'success' :
121
123
log .debug ("Skipping xloading resource %s because the "
122
124
"resource did not pass validation yet." , entity .id )
123
125
return
126
+
124
127
elif not getattr (entity , 'url_changed' , False ):
125
128
return
126
129
@@ -139,11 +142,13 @@ def notify(self, entity, operation):
139
142
140
143
def after_resource_create (self , context , resource_dict ):
141
144
if utils .is_validation_plugin_loaded () and \
142
- toolkit .asbool (toolkit .config .get ('ckanext.xloader.requires_validation' )) and \
143
- resource_dict .get ('validation_status' , None ) != 'success' :
145
+ toolkit .asbool (toolkit .config .get ('ckanext.xloader.requires_validation' )) and \
146
+ resource_dict .get ('validation_status' , None ) != 'success' :
147
+
144
148
log .debug ("Skipping xloading resource %s because the "
145
- "resource did not pass validation yet." , resource_dict .get ('id' ))
149
+ "resource did not pass validation yet." , resource_dict .get ('id' ))
146
150
return
151
+
147
152
self ._submit_to_xloader (resource_dict )
148
153
149
154
def before_resource_show (self , resource_dict ):
0 commit comments