sample_impl()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 7
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
from atramhasis.protected_resources import ProtectedResourceEvent
3
from atramhasis.protected_resources import ProtectedResourceException
4
from pyramid.events import subscriber
5
6
7
@subscriber(ProtectedResourceEvent)
8
def sample_impl(event):
9
    if event.uri.endswith("2"):
10
        referenced_in = ["urn:someobject", "http://test.test.org/object/2"]
11
        raise ProtectedResourceException(
12
            "resource {0} is still in use, preventing operation".format(event.uri),
13
            referenced_in,
14
        )
15