-
Notifications
You must be signed in to change notification settings - Fork 2k
/
core.py
44 lines (28 loc) · 921 Bytes
/
core.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# encoding: utf-8
from ckan.model import domain_object
__all__ = ['System', 'State', 'StatefulObjectMixin']
log = __import__('logging').getLogger(__name__)
class System(domain_object.DomainObject):
name = 'system'
def __unicode__(self):
return u'<%s>' % self.__class__.__name__
def purge(self):
pass
@classmethod
def by_name(cls, name):
return System()
# VDM-specific domain objects
class State(object):
ACTIVE = u'active'
DELETED = u'deleted'
PENDING = u'pending'
class StatefulObjectMixin(object):
__stateful__ = True
def delete(self):
log.debug('Running delete on %s', self)
self.state = State.DELETED
def undelete(self):
self.state = State.ACTIVE
def is_active(self):
# also support None in case this object is not yet refreshed ...
return self.state is None or self.state == State.ACTIVE