imio.smartweb.core 1.2.9__py3-none-any.whl → 1.2.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,6 +33,7 @@
33
33
  <include package=".behaviors" />
34
34
  <include package=".browser" />
35
35
  <include package=".faceted" />
36
+ <include package=".rest" />
36
37
  <include package=".upgrades" />
37
38
  <include package=".viewlets" />
38
39
  <include package=".webcomponents" />
File without changes
@@ -0,0 +1,62 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from imio.smartweb.core.config import DIRECTORY_URL
4
+ from imio.smartweb.core.config import EVENTS_URL
5
+ from imio.smartweb.core.config import NEWS_URL
6
+ from Products.Five.browser import BrowserView
7
+ from zope.interface import implementer
8
+ from zope.publisher.interfaces import IPublishTraverse
9
+
10
+ import requests
11
+
12
+
13
+ class BaseRequestForwarder(BrowserView):
14
+ def __call__(self):
15
+ traversal_stack = getattr(self, "traversal_stack", [])
16
+ url = "/".join(traversal_stack)
17
+ auth_source_url = f"{self.base_url}/{url}"
18
+ return self.forward_request(auth_source_url)
19
+
20
+ @implementer(IPublishTraverse)
21
+ def publishTraverse(self, request, name):
22
+ if not hasattr(self, "traversal_stack"):
23
+ self.traversal_stack = []
24
+ self.traversal_stack.append(name)
25
+ return self
26
+
27
+ def browserDefault(self, request):
28
+ return self, ()
29
+
30
+ def forward_request(self, url):
31
+ method = self.request.method
32
+ headers = {"Accept": self.request.environ["HTTP_ACCEPT"]}
33
+ params = self.request.form
34
+
35
+ data = {}
36
+ if self.request.get("BODY") is not None:
37
+ data = self.request.get("BODY")
38
+
39
+ # Forward the request to the authentic source
40
+ auth_source_response = requests.request(
41
+ method, url, params=params, headers=headers, data=data
42
+ )
43
+
44
+ response = self.request.response
45
+ # Set the status code and headers from the authentic source server response
46
+ response.setStatus(auth_source_response.status_code)
47
+ for header, value in auth_source_response.headers.items():
48
+ response.setHeader(header, value)
49
+
50
+ return auth_source_response.text
51
+
52
+
53
+ class DirectoryRequestForwarder(BaseRequestForwarder):
54
+ base_url = DIRECTORY_URL
55
+
56
+
57
+ class EventsRequestForwarder(BaseRequestForwarder):
58
+ base_url = EVENTS_URL
59
+
60
+
61
+ class NewsRequestForwarder(BaseRequestForwarder):
62
+ base_url = NEWS_URL
@@ -0,0 +1,30 @@
1
+ <configure
2
+ xmlns="http://namespaces.zope.org/zope"
3
+ xmlns:browser="http://namespaces.zope.org/browser"
4
+ xmlns:plone="http://namespaces.plone.org/plone">
5
+
6
+ <browser:page
7
+ for="Products.CMFPlone.interfaces.IPloneSiteRoot"
8
+ name="directory_request_forwarder"
9
+ class=".authentic_sources.DirectoryRequestForwarder"
10
+ permission="zope.Public"
11
+ layer="imio.smartweb.core.interfaces.IImioSmartwebCoreLayer"
12
+ />
13
+
14
+ <browser:page
15
+ for="Products.CMFPlone.interfaces.IPloneSiteRoot"
16
+ name="events_request_forwarder"
17
+ class=".authentic_sources.EventsRequestForwarder"
18
+ permission="zope.Public"
19
+ layer="imio.smartweb.core.interfaces.IImioSmartwebCoreLayer"
20
+ />
21
+
22
+ <browser:page
23
+ for="Products.CMFPlone.interfaces.IPloneSiteRoot"
24
+ name="news_request_forwarder"
25
+ class=".authentic_sources.NewsRequestForwarder"
26
+ permission="zope.Public"
27
+ layer="imio.smartweb.core.interfaces.IImioSmartwebCoreLayer"
28
+ />
29
+
30
+ </configure>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: imio.smartweb.core
3
- Version: 1.2.9
3
+ Version: 1.2.10
4
4
  Summary: Core product for iMio websites
5
5
  Home-page: https://github.com/imio/imio.smartweb.core
6
6
  Author: Christophe Boulanger
@@ -189,6 +189,13 @@ Changelog
189
189
  =========
190
190
 
191
191
 
192
+ 1.2.10 (2023-11-28)
193
+ -------------------
194
+
195
+ - Add RequestForwarder views
196
+ [laulaz, boulch]
197
+
198
+
192
199
  1.2.9 (2023-11-24)
193
200
  ------------------
194
201
 
@@ -1,7 +1,7 @@
1
- imio.smartweb.core-1.2.9-py3.10-nspkg.pth,sha256=wnCUSUElqssZ5FI3x-9HqwD229HQ-bAuPoDUNJHmMtU,1684
1
+ imio.smartweb.core-1.2.10-py3.10-nspkg.pth,sha256=wnCUSUElqssZ5FI3x-9HqwD229HQ-bAuPoDUNJHmMtU,1684
2
2
  imio/smartweb/core/__init__.py,sha256=iwhKnzeBJLKxpRVjvzwiRE63_zNpIBfaKLITauVph-0,24
3
3
  imio/smartweb/core/config.py,sha256=BUgfvh4hCaw0onCYAG4gQI1O4hZ-GzXWEltdHi4YLIs,337
4
- imio/smartweb/core/configure.zcml,sha256=G_Txh8wh0Mt5g2nDrJUjec_qFd5l9A8ZEUFzv4cjUcA,1429
4
+ imio/smartweb/core/configure.zcml,sha256=PeC4rF--rF6MfVQ0NzggQrZWIl35oPtJdEhvQwGxhhI,1459
5
5
  imio/smartweb/core/indexers.py,sha256=Lv1lHWFzM71ju822N8y7w61GDOyi6qmUbveZNI1tCz4,3887
6
6
  imio/smartweb/core/indexers.zcml,sha256=XHvKTkNcF5mkX-dVwRbjNsrBwIwwqa2Cm81PoXBqtow,968
7
7
  imio/smartweb/core/interfaces.py,sha256=8FxcXLjS915SZSL41JGsAWFDQNBAtSTsLnGiPmboU3g,971
@@ -357,6 +357,9 @@ imio/smartweb/core/profiles/testing/types/Collection.xml,sha256=C-sMSIWDq53bNJEF
357
357
  imio/smartweb/core/profiles/testing/types/Document.xml,sha256=rsGEqMCL6GdRoNaUaUvUowjR4k-Awwsd1Kpe3ztPV0w,215
358
358
  imio/smartweb/core/profiles/testing/types/Folder.xml,sha256=VegC_axHcmGWUvCSTxID12lErLwKSURpL2h3CTbEae4,213
359
359
  imio/smartweb/core/profiles/uninstall/browserlayer.xml,sha256=K8KnZFW9E6Hwi61Z6XZlXOjUpAKzJR6HjmjoOjFEWrk,128
360
+ imio/smartweb/core/rest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
361
+ imio/smartweb/core/rest/authentic_sources.py,sha256=SXn6Wl0qhI8IMDVoZAu9ietbl1D8UU5d4wPqh0Bjg-0,1951
362
+ imio/smartweb/core/rest/configure.zcml,sha256=GwILcIEU-qjO-8bq7hSorcYLmTKwB_bb7czOjNgfxFA,1001
360
363
  imio/smartweb/core/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
361
364
  imio/smartweb/core/tests/test_banner.py,sha256=83Q86ezLMJVwCLxoJddmlE9GKR3h6Qyb-rbqVSFc8a0,7838
362
365
  imio/smartweb/core/tests/test_behaviors.py,sha256=-CGdTPsWC6p7_SEwmQF_6IugNb5g_-7cQ-3rmN4WKl0,5950
@@ -676,10 +679,10 @@ imio/smartweb/core/webcomponents/src/hooks/useAxios.js,sha256=MsRpT8p9bZTp2Hk2sc
676
679
  imio/smartweb/core/webcomponents/src/hooks/useFilterQuery.js,sha256=fGxgxCI22ERSlVLCYmD0-nztnGUIz-VkUNyLtj5HSuo,223
677
680
  imio/smartweb/core/webcomponents/src/utils/translation.js,sha256=bsTZTvRlBaCImAchnuhZLtLQYC06bM539cPLoAgBMP0,2694
678
681
  imio/smartweb/core/webcomponents/src/utils/url.js,sha256=iyl_1QXfPBgUn0LEbZYT_zMEEjmj5DMiEz44Z6AKLcg,244
679
- imio.smartweb.core-1.2.9.dist-info/LICENSE.GPL,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
680
- imio.smartweb.core-1.2.9.dist-info/LICENSE.rst,sha256=RzkMFz6AX3-cHd531zd2YQcXai8RIbjFWTs6m66Y5u4,653
681
- imio.smartweb.core-1.2.9.dist-info/METADATA,sha256=tjtvD_LAiNb_QVyCvUh4QCSkVGzCVWeoR90d-AFfPE4,45027
682
- imio.smartweb.core-1.2.9.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
683
- imio.smartweb.core-1.2.9.dist-info/namespace_packages.txt,sha256=Pg8AH8t9viMMW1hJbNZvTy_n2jXG2igIYUpon5RA4Js,19
684
- imio.smartweb.core-1.2.9.dist-info/top_level.txt,sha256=ZktC0EGzThvMTAin9_q_41rzvvfMT2FYbP8pbhSLMSA,5
685
- imio.smartweb.core-1.2.9.dist-info/RECORD,,
682
+ imio.smartweb.core-1.2.10.dist-info/LICENSE.GPL,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
683
+ imio.smartweb.core-1.2.10.dist-info/LICENSE.rst,sha256=RzkMFz6AX3-cHd531zd2YQcXai8RIbjFWTs6m66Y5u4,653
684
+ imio.smartweb.core-1.2.10.dist-info/METADATA,sha256=slkOOL5l5q90MbHYRr4zLKgNCqsgbzG8zRAh5ib--VM,45119
685
+ imio.smartweb.core-1.2.10.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
686
+ imio.smartweb.core-1.2.10.dist-info/namespace_packages.txt,sha256=Pg8AH8t9viMMW1hJbNZvTy_n2jXG2igIYUpon5RA4Js,19
687
+ imio.smartweb.core-1.2.10.dist-info/top_level.txt,sha256=ZktC0EGzThvMTAin9_q_41rzvvfMT2FYbP8pbhSLMSA,5
688
+ imio.smartweb.core-1.2.10.dist-info/RECORD,,