REQ: Ensure only initial parameter is positional & adjust views/messages.py.

This commit is contained in:
neiljp (Neil Pilgrim)
2017-12-24 01:49:21 +00:00
committed by Greg Price
parent b0126ca8dc
commit 16b939a964
3 changed files with 4 additions and 2 deletions

View File

@@ -48,7 +48,7 @@ class REQ:
pass
NotSpecified = _NotSpecified()
def __init__(self, whence: str=None, converter: Callable[[Any], Any]=None,
def __init__(self, whence: str=None, *, converter: Callable[[Any], Any]=None,
default: Any=NotSpecified, validator: Callable[[Any], Any]=None,
argument_type: str=None) -> None:
"""whence: the name of the request variable that should be used

View File

@@ -23,6 +23,7 @@ class _NotSpecified: ...
NotSpecified = _NotSpecified()
def REQ(whence: Optional[str] = None,
*,
converter: Optional[Callable[[str], ResultT]] = None,
default: Union[_NotSpecified, ResultT] = NotSpecified,
validator: Optional[Validator] = None,

View File

@@ -948,7 +948,8 @@ def send_message_backend(request: HttpRequest, user_profile: UserProfile,
message_type_name: Text=REQ('type'),
message_to: List[Text]=REQ('to', converter=extract_recipients, default=[]),
forged: bool=REQ(default=False),
topic_name: Optional[Text]=REQ('subject', lambda x: x.strip(), None),
topic_name: Optional[Text]= REQ('subject',
converter=lambda x: x.strip(), default=None),
message_content: Text=REQ('content'),
realm_str: Optional[Text]=REQ('realm_str', default=None),
local_id: Optional[Text]=REQ(default=None),