Skip to content

Commit 72ad4f3

Browse files
authored
Merge pull request #111 from Aisbergg/feature-create-new-context-for-webs
Create new context for webs
2 parents f251100 + 8a8f452 commit 72ad4f3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

office365/runtime/client_object.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ def create_typed_object(self, properties):
5757
else:
5858
module_name = self.context.__module__.replace("outlook_client", "") + entity_name.lower()
5959
client_object_type = getattr(importlib.import_module(module_name), entity_name)
60-
client_object = client_object_type(self.context)
60+
context = self.context
61+
if entity_name == "Web":
62+
# create a new context to represent the new web object
63+
web_url = properties["__metadata"]["uri"]
64+
web_url = web_url[:web_url.rfind("/_api")]
65+
context = ClientContext(web_url, self.context.auth_context)
66+
client_object = client_object_type(context)
6167
client_object.map_json(properties)
6268
return client_object
6369

office365/runtime/client_runtime_context.py

+3
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ def add_query(self, query, result_object=None):
4444
def service_root_url(self):
4545
return self.__service_root_url
4646

47+
@property
48+
def auth_context(self):
49+
return self.__auth_context

0 commit comments

Comments
 (0)