]>
git.ipfire.org Git - people/jschlag/pbs.git/blob - src/buildservice/base.py
3 from .decorators
import *
7 Main object where all other objects inherit from.
9 This is used to access the global instance of Pakfire
10 and hold the database connection.
12 def __init__(self
, backend
, *args
, **kwargs
):
13 self
.backend
= backend
15 # Shortcut to settings.
16 if hasattr(self
.pakfire
, "settings"):
17 self
.settings
= self
.backend
.settings
19 # Call custom constructor
20 self
.init(*args
, **kwargs
)
22 def init(self
, *args
, **kwargs
):
24 Custom constructor to be overwritten by inheriting class
33 return self
.backend
.db
38 DEPRECATED: This attribute is only kept until
39 all other code has been updated to use self.backend.
44 class DataObject(Object
):
48 def init(self
, id, data
=None):
56 assert self
.table
, "Table name is not set"
59 return self
.db
.get("SELECT * FROM %s \
60 WHERE id = %%s" % self
.table
, self
.id)
62 def _set_attribute(self
, key
, val
):
63 # Detect if an update is needed
64 if self
.data
[key
] == val
:
67 self
.db
.execute("UPDATE %s SET %s = %%s \
68 WHERE id = %%s" % (self
.table
, key
), val
, self
.id)
70 # Update the cached attribute