Test Failed
Push — master ( e380d0...f5671d )
by W
02:58
created

st2common/st2common/persistence/rule.py (1 issue)

1
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
2
# contributor license agreements.  See the NOTICE file distributed with
3
# this work for additional information regarding copyright ownership.
4
# The ASF licenses this file to You under the Apache License, Version 2.0
5
# (the "License"); you may not use this file except in compliance with
6
# the License.  You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
16
from __future__ import absolute_import
17
from st2common.models.db.rule import rule_access, rule_type_access
18
from st2common.persistence.base import Access, ContentPackResource
19
20
21
class Rule(ContentPackResource):
22
    impl = rule_access
23
24
    @classmethod
25
    def _get_impl(cls):
26
        return cls.impl
27
28
29
class RuleType(Access):
30
    impl = rule_type_access
31
32
    @classmethod
33
    def _get_impl(cls):
34
        return cls.impl
35
36
    @classmethod
37
    def _get_by_object(cls, object):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in object.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
38
        # For RuleType name is unique.
39
        name = getattr(object, 'name', '')
40
        return cls.get_by_name(name)
41