8000 address PR feedback, add license header to about.py · Pucadopr/botbuilder-python@82c0cab · GitHub
[go: up one dir, main page]

Skip to content

Commit 82c0cab

Browse files
committed
address PR feedback, add license header to about.py
1 parent d0da6fe commit 82c0cab

File tree

7 files changed

+22
-23
lines changed

7 files changed

+22
-23
lines changed

libraries/botbuilder-core/botbuilder/core/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .bot_adapter import BotAdapter
1111
from .bot_framework_adapter import BotFrameworkAdapter, BotFrameworkAdapterSettings
1212
from .bot_context import BotContext
13-
from .bot_state import BotState, CachedBotState
13+
from .bot_state import BotState
1414
from .conversation_state import ConversationState
1515
from .memory_storage import MemoryStorage
1616
from .middleware_set import AnonymousReceiveMiddleware, Middleware, MiddlewareSet
@@ -24,7 +24,6 @@
2424
'BotFrameworkAdapter',
2525
'BotFrameworkAdapterSettings',
2626
'BotState',
27-
'CachedBotState',
2827
'calculate_change_hash',
2928
'ConversationState',
3029
'MemoryStorage',

libraries/botbuilder-core/botbuilder/core/about.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
14
__title__ = 'botbuilder-core'
25
__version__ = '4.0.0.a4'
36
__uri__ = 'https://www.github.com/Microsoft/botbuilder-python'

libraries/botbuilder-core/botbuilder/core/bot_state.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,11 @@
66
from .storage import calculate_change_hash, StoreItem, StorageKeyFactory, Storage
77

88

9-
class CachedBotState(StoreItem):
10-
def __init__(self):
11-
super(CachedBotState, self).__init__()
12-
self.state = None
13-
self.hash: str = None
14-
15-
169
class BotState(Middleware):
1710
def __init__(self, storage: Storage, storage_key: StorageKeyFactory):
1811
self.state_key = 'state'
1912
self.storage = storage
2013
self.storage_key = storage_key
21-
pass
2214

2315
async def on_process_request(self, context, next_middleware):
2416
"""

libraries/botbuilder-core/botbuilder/core/conversation_state.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ def call_get_storage_key(context):
3232

3333
def get_storage_key(self, context: BotContext):
3434
activity = context.activity
35-
channel_id = activity.channel_id
36-
conversation_id = (activity.conversation.id if
37-
(activity and hasattr(activity, 'conversation') and hasattr(activity.conversation, 'id')) else
38-
None)
39-
return f"conversation/{channel_id}/{conversation_id}" if channel_id and conversation_id else None
35+
channel_id = getattr(activity, 'channel_id', None)
36+
conversation_id = getattr(activity.conversation, 'id', None) if hasattr(activity, 'conversation') else None
37+
38+
storage_key = None
39+
if channel_id and conversation_id:
40+
storage_key = f"conversation/{channel_id}/{conversation_id}/{self.namespace}"
41+
return storage_key

libraries/botbuilder-core/botbuilder/core/memory_storage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def delete(self, keys: List[str]):
1717
for key in keys:
1818
if key in self.memory:
1919
del self.memory[key]
20-
except Exception as e:
20+
except TypeError as e:
2121
raise e
2222

2323
async def read(self, keys: List[str]):
@@ -26,7 +26,7 @@ async def read(self, keys: List[str]):
2626
for key in keys:
2727
if key in self.memory:
2828
data[key] = self.memory[key]
29-
except Exception as e:
29+
except TypeError as e:
3030
raise e
3131

3232
return data

libraries/botbuilder-core/botbuilder/core/middleware_set.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ async def receive_activity_internal(self, context, callback, next_middleware_ind
6565

6666
async def call_next_middleware():
6767
return await self.receive_activity_internal(context, callback, next_middleware_index+1)
68-
return await next_middleware.on_process_request(
69-
context,
70-
call_next_middleware
71-
)
68+
69+
try:
70+
return await next_middleware.on_process_request(context,
71+
call_next_middleware)
72+
except Exception as e:
73+
raise e

libraries/botbuilder-core/botbuilder/core/user_state.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ def get_storage_key(self, context: BotContext) -> str:
3737
:return:
3838
"""
3939
activity = context.activity
40-
channel_id = activity.channel_id or None
41-
user_id = activity.from_property.id or None
40+
channel_id = getattr(activity, 'channel_id', None)
41+
user_id = getattr(activity.from_property, 'id', None) if hasattr(activity, 'from_property') else None
42+
4243
storage_key = None
4344
if channel_id and user_id:
4445
storage_key = f"user/{channel_id}/{user_id}/{self.namespace}"

0 commit comments

Comments
 (0)
0