Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
喜羊羊3508
Dak
提交
e2763988
D
Dak
项目概览
喜羊羊3508
/
Dak
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Dak
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e2763988
编写于
9月 19, 2010
作者:
M
Mark Hymers
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stub code to start moving config into the database. I feel slightly nauseous
Signed-off-by:
N
Mark Hymers
<
mhy@debian.org
>
上级
ef5bc2b8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
0 deletion
+37
-0
daklib/config.py
daklib/config.py
+37
-0
未找到文件。
daklib/config.py
浏览文件 @
e2763988
...
@@ -53,6 +53,7 @@ class Config(object):
...
@@ -53,6 +53,7 @@ class Config(object):
if
not
getattr
(
self
,
'initialised'
,
False
):
if
not
getattr
(
self
,
'initialised'
,
False
):
self
.
initialised
=
True
self
.
initialised
=
True
self
.
_readconf
()
self
.
_readconf
()
self
.
_setup_routines
()
def
_readconf
(
self
):
def
_readconf
(
self
):
apt_pkg
.
init
()
apt_pkg
.
init
()
...
@@ -84,3 +85,39 @@ class Config(object):
...
@@ -84,3 +85,39 @@ class Config(object):
def
__setitem__
(
self
,
name
,
value
):
def
__setitem__
(
self
,
name
,
value
):
self
.
Cnf
[
name
]
=
value
self
.
Cnf
[
name
]
=
value
@
staticmethod
def
get_db_value
(
name
,
default
=
None
,
rettype
=
None
):
from
daklib.dbconn
import
DBConfig
,
DBConn
,
NoResultFound
try
:
res
=
DBConn
().
session
().
query
(
DBConfig
).
filter
(
DBConfig
.
name
==
name
).
one
()
except
NoResultFound
:
return
default
if
rettype
:
return
rettype
(
res
.
value
)
else
:
return
res
.
value
def
_setup_routines
(
self
):
"""
This routine is the canonical list of which fields need to exist in
the config table. If your dak instance is to work, we suggest reading it
Of course, what the values do is another matter
"""
for
field
in
[(
'db_revision'
,
None
,
int
),
(
'defaultsuitename'
,
'unstable'
,
str
)]:
setattr
(
self
,
'get_%s'
%
field
[
0
],
lambda
x
=
None
:
self
.
get_db_value
(
field
[
0
],
field
[
1
],
field
[
2
]))
setattr
(
Config
,
'%s'
%
field
[
0
],
property
(
fget
=
getattr
(
self
,
'get_%s'
%
field
[
0
])))
def
get_defaultsuite
(
self
):
from
daklib.dbconn
import
get_suite
suitename
=
self
.
defaultsuitename
if
not
suitename
:
return
None
else
:
return
get_suite
(
suitename
)
defaultsuite
=
property
(
get_defaultsuite
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录