0
回到整數名單上有這些變量:通過查詢在龍捲風
PERM_READ = 0x01
PERM_WRITE = 0x02
PERM_CMDS = 0x04
和功能檢查權限的網絡或傳感器。決定用戶權限的函數。
這是函數:
def check_network_access(self, network, access=None, raise_err=True):
if access is None:
access = PERM_READ
else:
assert(access > 0)
assert(access <= (PERM_READ + PERM_WRITE + PERM_CMDS))
usr = self.get_current_user()
usr_id = usr['id']
# Does the network exist?
net = self.get_network(network)
if not net:
raise tornado.web.HTTPError(404, "not found")
self.lock_tables('read', ['nets_permissions'])
perms = self.db.get("SELECT * FROM nets_permissions WHERE network_id=%s AND \
user_id=%s", network, usr_id)
self.unlock_tables()
if (not perms) or ((perms['perm'] & access) != access):
if (raise_err):
raise tornado.web.HTTPError(403, "access forbidden %s %s", perms['perm'], access)
else:
return False
return True
現在比如我有一個錯誤,當我調用一個頁面,這個處理程序:
class NetworkStatusHandler(BaseHandler):
# Requires authentication
@tornado.web.authenticated
def get(self, nid):
# Retrieve the current user
usr = self.get_current_user()
usr_id = usr['id']
perm = self.db.query("SELECT n.perm FROM nets_permissions as n \
WHERE n.network_id=%s AND n.user_id=%s", nid, int(usr_id))
# Check whether the user has access to the network
perms = self.check_network_access(nid, perm)
net = self.get_network(nid)
# Render the networks page
self.render("networkstatus.html", net=net)
我的錯誤是:
File "./wsn.py", line 264, in check_network_access
raise tornado.web.HTTPError(403, "access forbidden %s %s", perms['perm'], access)
HTTPError: HTTP 403: Forbidden (access forbidden 4 1)
我認爲這是一個問題,在通過可滲透的perm /訪問函數...我如何通過這個變量爲了做到這一點是一個整數,而不是一個列表?
謝謝你的幫助!
你爲什麼想?已經檢查了你傳遞給'check_network_access'的東西嗎? –
我不知道如何在旋風中看到變量。我不知道我該如何做調試!請幫助我 – sharkbait
只需使用打印語句。 –