Merge pull request #18 from gdott9/master
Handle exceptions with ConfigParser in from_file.py
This commit is contained in:
commit
47b0f801fd
@ -50,9 +50,9 @@ from radicale.rights import owner_only
|
|||||||
# Manage Python2/3 different modules
|
# Manage Python2/3 different modules
|
||||||
# pylint: disable=F0401
|
# pylint: disable=F0401
|
||||||
try:
|
try:
|
||||||
from configparser import RawConfigParser as ConfigParser
|
from configparser import RawConfigParser as ConfigParser, NoSectionError, NoOptionError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from ConfigParser import RawConfigParser as ConfigParser
|
from ConfigParser import RawConfigParser as ConfigParser, NoSectionError, NoOptionError
|
||||||
# pylint: enable=F0401
|
# pylint: enable=F0401
|
||||||
|
|
||||||
|
|
||||||
@ -68,13 +68,20 @@ else:
|
|||||||
|
|
||||||
def read_authorized(user, collection):
|
def read_authorized(user, collection):
|
||||||
"""Check if the user is allowed to read the collection."""
|
"""Check if the user is allowed to read the collection."""
|
||||||
return (
|
if owner_only.read_authorized(user, collection):
|
||||||
owner_only.read_authorized(user, collection) or
|
return True
|
||||||
"r" in RIGHTS.get(collection.url.rstrip("/") or "/", user))
|
else:
|
||||||
|
try:
|
||||||
|
return "r" in RIGHTS.get(collection.url.rstrip("/") or "/", user)
|
||||||
|
except (NoSectionError, NoOptionError):
|
||||||
|
return False
|
||||||
|
|
||||||
def write_authorized(user, collection):
|
def write_authorized(user, collection):
|
||||||
"""Check if the user is allowed to write the collection."""
|
"""Check if the user is allowed to write the collection."""
|
||||||
return (
|
if owner_only.read_authorized(user, collection):
|
||||||
owner_only.write_authorized(user, collection) or
|
return True
|
||||||
"w" in RIGHTS.get(collection.url.rstrip("/") or "/", user))
|
else:
|
||||||
|
try:
|
||||||
|
return "w" in RIGHTS.get(collection.url.rstrip("/") or "/", user)
|
||||||
|
except (NoSectionError, NoOptionError):
|
||||||
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user