Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ckanext-odsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open-Data
ckanext-odsh
Commits
5407174b
Commit
5407174b
authored
6 years ago
by
chbaeh
Browse files
Options
Downloads
Patches
Plain Diff
add preconditon for slave
parent
4b27c0d2
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ckanext/odsh/plugin.py
+3
-6
3 additions, 6 deletions
ckanext/odsh/plugin.py
ckanext/odsh/precondition.py
+17
-0
17 additions, 0 deletions
ckanext/odsh/precondition.py
with
20 additions
and
6 deletions
ckanext/odsh/plugin.py
+
3
−
6
View file @
5407174b
...
...
@@ -19,8 +19,8 @@ from dateutil.parser import parse
import
ckan.plugins
as
p
import
logging
import
validation
import
precondition
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -96,7 +96,7 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
# IActions
def
get_actions
(
self
):
return
{
'
package_create
'
:
action
.
odsh_package_create
,
return
{
'
package_create
'
:
precondition
.
not_on_slave
(
action
.
odsh_package_create
)
,
'
user_create
'
:
action
.
odsh_user_create
}
# IConfigurer
...
...
@@ -332,11 +332,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
dict_pkg
[
'
openness
'
]
=
OdshPlugin
.
scores
[
score
-
1
]
@precondition.not_on_slave
def
before_index
(
self
,
dict_pkg
):
debug
=
config
.
get
(
'
ckanext.odsh.debug
'
,
False
)
slave
=
config
.
get
(
'
ckanext.odsh.slave
'
,
False
)
assert
not
(
debug
and
slave
)
# make special date fields solr conform
fields
=
[
"
issued
"
,
"
temporal_start
"
,
"
temporal_end
"
]
for
field
in
fields
:
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/precondition.py
0 → 100644
+
17
−
0
View file @
5407174b
from
pylons
import
config
class
PreconditionViolated
(
Exception
):
def
__init__
(
self
,
message
):
super
(
PreconditionViolated
,
self
).
__init__
(
message
)
def
not_on_slave
(
func
):
def
wrapped
(
*
args
,
**
kwargs
):
if
config
.
get
(
'
ckanext.odsh.slave
'
,
False
):
raise
PreconditionViolated
(
'
not allowed on slave
'
)
return
func
(
*
args
,
**
kwargs
)
if
config
.
get
(
'
ckanext.odsh.debug
'
,
False
):
return
wrapped
return
func
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment