小编Szi*_*ter的帖子

PostgreSQL角色继承不起作用?

我遇到了一个非常烦人的PostgreSQL角色继承问题.根据文档,它根本不表现.

我想拥有一个主角色,并将其权限授予新创建的用户.这些用户应该继承权限,而无需SET ROLE手动发布.

CREATE ROLE testrole NOSUPERUSER INHERIT CREATEDB NOCREATEROLE;
CREATE ROLE testuser LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE;
GRANT testrole TO testuser;
Run Code Online (Sandbox Code Playgroud)

现在我连接后testuser,我得到以下内容:

postgres=> CREATE DATABASE foobar;
ERROR:  permission denied to create database
postgres=> SET ROLE testrole;
SET
postgres=> CREATE DATABASE foobar;
CREATE DATABASE
Run Code Online (Sandbox Code Playgroud)

根据上面链接的文档(由于INHERIT选项),SET ROLE不应该要求.

我在这里错过了什么?

postgresql

13
推荐指数
1
解决办法
4007
查看次数

Python日志记录在2.5和2.6之间不兼容

你能帮我解决Python 2.5和2.6之间的以下不兼容问题吗?

logger.conf:

[loggers]
keys=root,aLogger,bLogger

[handlers]
keys=consoleHandler

[formatters]
keys=

[logger_root]
level=NOTSET
handlers=consoleHandler

[logger_aLogger]
level=DEBUG
handlers=consoleHandler
propagate=0
qualname=a

[logger_bLogger]
level=INFO
handlers=consoleHandler
propagate=0
qualname=b

[handler_consoleHandler]
class=StreamHandler
args=(sys.stderr,)
Run Code Online (Sandbox Code Playgroud)

module_one.py:

import logging
import logging.config

logging.config.fileConfig('logger.conf')
a_log = logging.getLogger('a.submod')
b_log = logging.getLogger('b.submod')

def function_one():
    b_log.info("function_one() called.")
Run Code Online (Sandbox Code Playgroud)

module_two.py:

import logging
import logging.config

logging.config.fileConfig('logger.conf')
a_log = logging.getLogger('a.submod')
b_log = logging.getLogger('b.submod')

def function_two():
    a_log.info("function_two() called.")
Run Code Online (Sandbox Code Playgroud)

logger.py:

from module_one import function_one
from module_two import function_two

function_one()
function_two()
Run Code Online (Sandbox Code Playgroud)

在Ubuntu 9.04下调用logger.py的输出:

$ python2.5 logger.py
$

$ python2.6 logger.py
function_one() called.
function_two() …
Run Code Online (Sandbox Code Playgroud)

python logging incompatibility

6
推荐指数
1
解决办法
1254
查看次数

标签 统计

incompatibility ×1

logging ×1

postgresql ×1

python ×1