Propertie settings in database
This commit is contained in:
1 parent
f1cbb265bd
commit
e3a9bb1301
1 file changed
+28
@@ -4,9 +4,11 @@ from couchpotato.core.event import addEvent, fireEvent
|
|||||||
from couchpotato.core.helpers.encoding import isInt, toUnicode
|
from couchpotato.core.helpers.encoding import isInt, toUnicode
|
||||||
from couchpotato.core.helpers.request import getParams, jsonified
|
from couchpotato.core.helpers.request import getParams, jsonified
|
||||||
from couchpotato.core.helpers.variable import mergeDicts, tryInt
|
from couchpotato.core.helpers.variable import mergeDicts, tryInt
|
||||||
|
from couchpotato.core.settings.model import Properties
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import os.path
|
import os.path
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
|
||||||
class Settings(object):
|
class Settings(object):
|
||||||
@@ -190,3 +192,29 @@ class Settings(object):
|
|||||||
return jsonified({
|
return jsonified({
|
||||||
'success': True,
|
'success': True,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def getProperty(self, identifier):
|
||||||
|
from couchpotato import get_session
|
||||||
|
|
||||||
|
db = get_session()
|
||||||
|
try:
|
||||||
|
prop = db.query(Properties).filter_by(identifier = identifier).first()
|
||||||
|
return prop.value
|
||||||
|
except:
|
||||||
|
print traceback.format_exc()
|
||||||
|
return None
|
||||||
|
|
||||||
|
def setProperty(self, identifier, value = ''):
|
||||||
|
from couchpotato import get_session
|
||||||
|
|
||||||
|
db = get_session()
|
||||||
|
|
||||||
|
p = db.query(Properties).filter_by(identifier = identifier).first()
|
||||||
|
if not p:
|
||||||
|
p = Properties()
|
||||||
|
db.add(p)
|
||||||
|
|
||||||
|
p.identifier = identifier
|
||||||
|
p.value = toUnicode(value)
|
||||||
|
|
||||||
|
db.commit()
|
||||||
Reference in new issue
Block a user