Default value for MAX_CHAR_LIMIT and convert to int to catch early errors
This commit is contained in:
parent
760c5b41fc
commit
b41053dd38
2 changed files with 5 additions and 6 deletions
|
|
@ -18,7 +18,7 @@ _MOD_IMPORT = None
|
||||||
# throttles
|
# throttles
|
||||||
_MAX_CONNECTION_RATE = float(settings.MAX_CONNECTION_RATE)
|
_MAX_CONNECTION_RATE = float(settings.MAX_CONNECTION_RATE)
|
||||||
_MAX_COMMAND_RATE = float(settings.MAX_COMMAND_RATE)
|
_MAX_COMMAND_RATE = float(settings.MAX_COMMAND_RATE)
|
||||||
_MAX_CHAR_LIMIT = settings.MAX_CHAR_LIMIT
|
_MAX_CHAR_LIMIT = int(settings.MAX_CHAR_LIMIT)
|
||||||
|
|
||||||
_MIN_TIME_BETWEEN_CONNECTS = 1.0 / float(settings.MAX_CONNECTION_RATE)
|
_MIN_TIME_BETWEEN_CONNECTS = 1.0 / float(settings.MAX_CONNECTION_RATE)
|
||||||
_ERROR_COMMAND_OVERFLOW = settings.COMMAND_RATE_WARNING
|
_ERROR_COMMAND_OVERFLOW = settings.COMMAND_RATE_WARNING
|
||||||
|
|
@ -358,7 +358,7 @@ class PortalSessionHandler(SessionHandler):
|
||||||
#text = timetrace(text, "portalsessionhandler.data_in")
|
#text = timetrace(text, "portalsessionhandler.data_in")
|
||||||
try:
|
try:
|
||||||
text = kwargs['text']
|
text = kwargs['text']
|
||||||
if _MAX_CHAR_LIMIT and len(text) > _MAX_CHAR_LIMIT:
|
if (_MAX_CHAR_LIMIT > 0) and len(text) > _MAX_CHAR_LIMIT:
|
||||||
if session:
|
if session:
|
||||||
self.data_out(session, text=[[_ERROR_MAX_CHAR], {}])
|
self.data_out(session, text=[[_ERROR_MAX_CHAR], {}])
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -203,10 +203,9 @@ MAX_COMMAND_RATE = 80
|
||||||
COMMAND_RATE_WARNING ="You entered commands too fast. Wait a moment and try again."
|
COMMAND_RATE_WARNING ="You entered commands too fast. Wait a moment and try again."
|
||||||
# Determine how large of a string can be sent to the server in number
|
# Determine how large of a string can be sent to the server in number
|
||||||
# of characters. If they attempt to enter a string over this character
|
# of characters. If they attempt to enter a string over this character
|
||||||
# limit, we stop them and send a message. Set to None by default. To
|
# limit, we stop them and send a message. To make unlimited, set to
|
||||||
# change it, just set it to a number of characters - ie, 6000 to be
|
# 0 or less.
|
||||||
# roughly two pages of text.
|
MAX_CHAR_LIMIT = 6000
|
||||||
MAX_CHAR_LIMIT = None
|
|
||||||
# The warning to echo back to users if they enter a very large string
|
# The warning to echo back to users if they enter a very large string
|
||||||
MAX_CHAR_LIMIT_WARNING="You entered a string that was too large. Please break it up into separate commands."
|
MAX_CHAR_LIMIT_WARNING="You entered a string that was too large. Please break it up into separate commands."
|
||||||
# If this is true, errors and tracebacks from the engine will be
|
# If this is true, errors and tracebacks from the engine will be
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue