fix the "__lastmatch__" returns undefined#56
fix the "__lastmatch__" returns undefined#56htdinh wants to merge 1 commit intoaichaos:masterfrom htdinh:Dinh-Hung-Tu-patch-1
Conversation
in earlier version, if the value of key "lastmatch" is None, the key-value pair is removed from the users dictionary. the fix remains the key-value pair even when value is None.
|
Deleting user vars by setting their value to |
|
I tried to solve the bug #35 here. When the user variable value is None, should it stays there for the call i.e. last_match return None rather than undefined? Maybe I am not clear about your use case deleting user var. Could you explain further? |
|
It's a little complicated because I want a user var to return the string The problem started when I moved the session management code into its own module, where the same logic was being called both for Probably the best place to fix it would be in the session manager around here. The function could accept a new def get(self, username, key, default="undefined"):
if not username in self._users:
return None
return self._users[username].get(key, default)This will preserve the existing behavior when a Changing the - return self._session.get(user, name)
+ return self._session.get(user, name, None)The On an unrelated side note on deleting user vars: some people have a need to delete temporary user variables once they're done with them. Calling It's supposed to also be the case that you can do |
|
Thanks for your detailed explanation of the design. Your idea to create a In my understanding, except
If so, according to your explanation, there are two additional meaning of these terms.
Your proposal of changing the
|
|
After writing a very long discussion, I realise that unit test suite will be much clearer to specify your design requirement of the final session manager. If I interpret the design, write the tests and fix the code at the same time, the tests may be self-biased. Could you please help to write a test suite for session manager? |
|
Good points. The root problem is the I still like having the So calling In case the developer wants to know whether a variable actually is set, a new function could be added like You don't have to worry about that for this PR, though. tl;dr. suggested changes:
|
|
#63 fixed this instead. |
in earlier version, if the value of key "lastmatch" is None, the key-value pair is removed from the users dictionary.
the fix remains the key-value pair even when value is None.