Repository: evennia/evennia

Issue:
Webclient Options popup use causes traceback pre-login
### Brief summary of issue / Description of requested feature:
Attempting to use the webclient options pre-login causes a traceback.
Settings made pre-login are not preserved after login.
 
 
### Steps to reproduce the issue / Reasons for adding feature:
 
1.  Open browser to web client
2.  Attemp to use the webclient options before you log in
3.  Observe traceback in console
 
### Error output / Expected result of feature
```
 Traceback (most recent call last):
   File "/home/evennia/evennia/server/sessionhandler.py", line 762, in call_inputfuncs
     _INPUT_FUNCS[cname](session, *cmdargs, **cmdkwargs)
   File "/home/evennia/evennia/server/inputfuncs.py", line 440, in webclient_options
     storedoptions = account.db._saved_webclient_options or {}
 AttributeError: 'NoneType' object has no attribute 'db'
```
 
### Extra information, such as Evennia revision/repo/branch, operating system and ideas for how to solve / implement:
 
0.7.0 (rev b3c6e9d) master
 
Pop up the "You need to be connected" modal with message changed to "You need to be logged in", or hide settings cog until after login, or do not try to save settings to account until after login.
Webclient Options popup use causes traceback pre-login
### Brief summary of issue / Description of requested feature:
Attempting to use the webclient options pre-login causes a traceback.
Settings made pre-login are not preserved after login.
 
 
### Steps to reproduce the issue / Reasons for adding feature:
 
1.  Open browser to web client
2.  Attemp to use the webclient options before you log in
3.  Observe traceback in console
 
### Error output / Expected result of feature
```
 Traceback (most recent call last):
   File "/home/evennia/evennia/server/sessionhandler.py", line 762, in call_inputfuncs
     _INPUT_FUNCS[cname](session, *cmdargs, **cmdkwargs)
   File "/home/evennia/evennia/server/inputfuncs.py", line 440, in webclient_options
     storedoptions = account.db._saved_webclient_options or {}
 AttributeError: 'NoneType' object has no attribute 'db'
```
 
### Extra information, such as Evennia revision/repo/branch, operating system and ideas for how to solve / implement:
 
0.7.0 (rev b3c6e9d) master
 
Pop up the "You need to be connected" modal with message changed to "You need to be logged in", or hide settings cog until after login, or do not try to save settings to account until after login.


Discussion:

Resolving patch:
diff --git a/evennia/commands/default/help.py b/evennia/commands/default/help.py
--- a/evennia/commands/default/help.py
+++ b/evennia/commands/default/help.py
@@ -267,7 +267,7 @@ def func(self):
             return
 
         # no exact matches found. Just give suggestions.
-        self.msg(self.format_help_entry("", "No help entry found for '%s'" % query, None, suggested=suggestions))
+        self.msg((self.format_help_entry("", "No help entry found for '%s'" % query, None, suggested=suggestions), {"type": "help"}))
 
 
 def _loadhelp(caller):
diff --git a/evennia/server/inputfuncs.py b/evennia/server/inputfuncs.py
--- a/evennia/server/inputfuncs.py
+++ b/evennia/server/inputfuncs.py
@@ -436,9 +436,12 @@ def webclient_options(session, *args, **kwargs):
     """
     account = session.account
 
-    clientoptions = settings.WEBCLIENT_OPTIONS.copy()
-    storedoptions = account.db._saved_webclient_options or {}
-    clientoptions.update(storedoptions)
+    clientoptions = account.db._saved_webclient_options
+    if not clientoptions:
+        # No saved options for this account, copy and save the default.
+        account.db._saved_webclient_options = settings.WEBCLIENT_OPTIONS.copy()
+        # Get the _SaverDict created by the database.
+        clientoptions = account.db._saved_webclient_options
 
     # The webclient adds a cmdid to every kwargs, but we don't need it.
     try:
@@ -448,7 +451,8 @@ def webclient_options(session, *args, **kwargs):
 
     if not kwargs:
         # No kwargs: we are getting the stored options
-        session.msg(webclient_options=clientoptions)
+        # Convert clientoptions to regular dict for sending.
+        session.msg(webclient_options=dict(clientoptions))
 
         # Create a monitor. If a monitor already exists then it will replace
         # the previous one since it would use the same idstring
@@ -461,5 +465,3 @@ def webclient_options(session, *args, **kwargs):
         # kwargs provided: persist them to the account object
         for key, value in kwargs.iteritems():
             clientoptions[key] = value
-
-        account.db._saved_webclient_options = clientoptions


Test patch: