iris-pex-embedded-python 3.5.5b4__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.
Files changed (91) hide show
  1. grongier/__init__.py +0 -0
  2. grongier/cls/Grongier/PEX/BusinessOperation.cls +8 -0
  3. grongier/cls/Grongier/PEX/BusinessProcess.cls +13 -0
  4. grongier/cls/Grongier/PEX/BusinessService.cls +8 -0
  5. grongier/cls/Grongier/PEX/Common.cls +10 -0
  6. grongier/cls/Grongier/PEX/Director.cls +10 -0
  7. grongier/cls/Grongier/PEX/Duplex/Operation.cls +4 -0
  8. grongier/cls/Grongier/PEX/Duplex/Process.cls +13 -0
  9. grongier/cls/Grongier/PEX/Duplex/Service.cls +4 -0
  10. grongier/cls/Grongier/PEX/InboundAdapter.cls +8 -0
  11. grongier/cls/Grongier/PEX/Message.cls +13 -0
  12. grongier/cls/Grongier/PEX/OutboundAdapter.cls +8 -0
  13. grongier/cls/Grongier/PEX/PickleMessage.cls +13 -0
  14. grongier/cls/Grongier/PEX/PrivateSession/Duplex.cls +8 -0
  15. grongier/cls/Grongier/PEX/PrivateSession/Message/Ack.cls +14 -0
  16. grongier/cls/Grongier/PEX/PrivateSession/Message/Poll.cls +14 -0
  17. grongier/cls/Grongier/PEX/PrivateSession/Message/Start.cls +14 -0
  18. grongier/cls/Grongier/PEX/PrivateSession/Message/Stop.cls +14 -0
  19. grongier/cls/Grongier/PEX/Test.cls +10 -0
  20. grongier/cls/Grongier/PEX/Utils.cls +10 -0
  21. grongier/cls/Grongier/Service/WSGI.cls +4 -0
  22. grongier/pex/__init__.py +24 -0
  23. grongier/pex/__main__.py +4 -0
  24. grongier/pex/_business_host.py +1 -0
  25. grongier/pex/_cli.py +4 -0
  26. grongier/pex/_common.py +1 -0
  27. grongier/pex/_director.py +1 -0
  28. grongier/pex/_utils.py +1 -0
  29. grongier/pex/wsgi/handlers.py +104 -0
  30. iop/__init__.py +25 -0
  31. iop/__main__.py +4 -0
  32. iop/_async_request.py +67 -0
  33. iop/_business_host.py +256 -0
  34. iop/_business_operation.py +75 -0
  35. iop/_business_process.py +224 -0
  36. iop/_business_service.py +63 -0
  37. iop/_cli.py +247 -0
  38. iop/_common.py +334 -0
  39. iop/_debugpy.py +187 -0
  40. iop/_decorators.py +49 -0
  41. iop/_director.py +301 -0
  42. iop/_dispatch.py +136 -0
  43. iop/_generator_request.py +30 -0
  44. iop/_inbound_adapter.py +34 -0
  45. iop/_iris.py +8 -0
  46. iop/_log_manager.py +100 -0
  47. iop/_message.py +40 -0
  48. iop/_message_validator.py +49 -0
  49. iop/_outbound_adapter.py +23 -0
  50. iop/_private_session_duplex.py +103 -0
  51. iop/_private_session_process.py +41 -0
  52. iop/_remote.py +91 -0
  53. iop/_serialization.py +199 -0
  54. iop/_utils.py +671 -0
  55. iop/cls/IOP/BusinessOperation.cls +35 -0
  56. iop/cls/IOP/BusinessProcess.cls +156 -0
  57. iop/cls/IOP/BusinessService.cls +40 -0
  58. iop/cls/IOP/Common.cls +569 -0
  59. iop/cls/IOP/Director.cls +70 -0
  60. iop/cls/IOP/Duplex/Operation.cls +29 -0
  61. iop/cls/IOP/Duplex/Process.cls +229 -0
  62. iop/cls/IOP/Duplex/Service.cls +9 -0
  63. iop/cls/IOP/Generator/Message/Ack.cls +31 -0
  64. iop/cls/IOP/Generator/Message/Poll.cls +31 -0
  65. iop/cls/IOP/Generator/Message/Start.cls +15 -0
  66. iop/cls/IOP/Generator/Message/StartPickle.cls +15 -0
  67. iop/cls/IOP/Generator/Message/Stop.cls +32 -0
  68. iop/cls/IOP/InboundAdapter.cls +22 -0
  69. iop/cls/IOP/Message/JSONSchema.cls +125 -0
  70. iop/cls/IOP/Message.cls +754 -0
  71. iop/cls/IOP/OutboundAdapter.cls +36 -0
  72. iop/cls/IOP/PickleMessage.cls +58 -0
  73. iop/cls/IOP/PrivateSession/Duplex.cls +260 -0
  74. iop/cls/IOP/PrivateSession/Message/Ack.cls +32 -0
  75. iop/cls/IOP/PrivateSession/Message/Poll.cls +32 -0
  76. iop/cls/IOP/PrivateSession/Message/Start.cls +31 -0
  77. iop/cls/IOP/PrivateSession/Message/Stop.cls +48 -0
  78. iop/cls/IOP/Projection.cls +49 -0
  79. iop/cls/IOP/Service/Remote/Handler.cls +30 -0
  80. iop/cls/IOP/Service/Remote/Rest/v1.cls +97 -0
  81. iop/cls/IOP/Service/WSGI.cls +310 -0
  82. iop/cls/IOP/Test.cls +85 -0
  83. iop/cls/IOP/Utils.cls +503 -0
  84. iop/cls/IOP/Wrapper.cls +58 -0
  85. iop/wsgi/handlers.py +104 -0
  86. iris_pex_embedded_python-3.5.5b4.dist-info/METADATA +91 -0
  87. iris_pex_embedded_python-3.5.5b4.dist-info/RECORD +91 -0
  88. iris_pex_embedded_python-3.5.5b4.dist-info/WHEEL +5 -0
  89. iris_pex_embedded_python-3.5.5b4.dist-info/entry_points.txt +2 -0
  90. iris_pex_embedded_python-3.5.5b4.dist-info/licenses/LICENSE +21 -0
  91. iris_pex_embedded_python-3.5.5b4.dist-info/top_level.txt +2 -0
@@ -0,0 +1,310 @@
1
+ Class IOP.Service.WSGI Extends %CSP.REST [ ServerOnly = 1 ]
2
+ {
3
+
4
+ Parameter CLASSPATHS;
5
+
6
+ Parameter MODULENAME;
7
+
8
+ Parameter APPNAME;
9
+
10
+ Parameter DEVMODE = 1;
11
+
12
+ /// This method matches the request and method and calls the dispatcher
13
+ ClassMethod Page(skipheader As %Boolean = 0) As %Status [ ProcedureBlock = 1 ]
14
+ {
15
+ #dim tSC As %Status = $$$OK
16
+ #dim e As %Exception.AbstractException
17
+
18
+ #dim tAuthorized,tRedirected As %Boolean
19
+ #dim tRedirectRoutine,tURL As %String = ""
20
+ #dim %response As %CSP.Response
21
+
22
+ Try {
23
+
24
+ #; Ensure that we honor the requested charset
25
+ Set %response.CharSet=..#CHARSET
26
+
27
+ #; Ensure that we honor the requested CONTENTTYPE
28
+ If ..#CONTENTTYPE'="" Set %response.ContentType=..#CONTENTTYPE
29
+
30
+ #; Ensure that we honor the requested HTTP_ACCEPT_LANGUAGE
31
+ Set %response.Domain = ..#DOMAIN
32
+ Do %response.MatchLanguage()
33
+
34
+
35
+
36
+ #; Record if device re-direction is already active
37
+ Set tRedirected=##class(%Library.Device).ReDirectIO()
38
+
39
+ #; Record the redirect routine
40
+ Set tRedirectRoutine=$System.Device.GetMnemonicRoutine()
41
+
42
+ #; Now switch to using THIS routine for device redirection
43
+ Use $io::("^%SYS.cspServer2")
44
+
45
+ #; Switch device redirection on (may already be on but thats ok)
46
+ Do ##class(%Library.Device).ReDirectIO(1)
47
+
48
+ #; Ensure that the application is defined (security check)
49
+ If $$$GetSecurityApplicationsDispatchClass(%request.AppData)="" {
50
+
51
+ #; Report not authorized
52
+ Set tSC=..Http403()
53
+
54
+ #; Done
55
+ Quit
56
+ }
57
+
58
+ #; GgiEnvs are not defined in the CSP shell
59
+ Set tURL=$Get(%request.CgiEnvs("CSPLIB"))
60
+ If tURL="" Set tURL=%request.URL
61
+
62
+ #; Do an access check
63
+ Set tSC=..AccessCheck(.tAuthorized)
64
+ If $$$ISERR(tSC) Quit
65
+
66
+ If tAuthorized=0 {
67
+
68
+ #; Don't want the session token
69
+ Set %response.OutputSessionToken=0
70
+
71
+ #; Set the Http Status
72
+ Set %response.Status=..#HTTP403FORBIDDEN
73
+
74
+ #; Done
75
+ Quit
76
+ }
77
+
78
+ #; Extract the match url from the application name
79
+ Set tMatchUrl = "/"_$Extract(tURL,$Length(%request.Application)+1,*)
80
+
81
+ #; Dispatch the request
82
+ Set tSC=..DispatchRequest(tMatchUrl,%request.Method)
83
+
84
+ } Catch (e) {
85
+ Set tSC=e.AsStatus()
86
+ }
87
+
88
+ If $$$ISERR(tSC) {
89
+
90
+ #; Don't want the session token
91
+ Set %response.OutputSessionToken=0
92
+
93
+ Do ..Http500(##class(%Exception.StatusException).CreateFromStatus(tSC))
94
+ }
95
+
96
+ #; Ensure that at least something is written out as the body
97
+ #; This will trigger the device redirect capture and force headers to be written
98
+ #; (if not already done)
99
+ Write ""
100
+
101
+ #; Reset redirect device if necessary
102
+ If tRedirected {
103
+
104
+ #; Use the original redirected routine
105
+ Use $io::("^"_tRedirectRoutine)
106
+
107
+ #; Switch device redirection on
108
+ Do ##class(%Library.Device).ReDirectIO(1)
109
+ }
110
+
111
+ if ..#DEVMODE {
112
+ #; Close the device to ensure next request starts with a new process
113
+ Close 0
114
+ }
115
+
116
+ Quit $$$OK
117
+ }
118
+
119
+ ClassMethod OnPreDispatch(
120
+ pUrl As %String,
121
+ pMethod As %String,
122
+ ByRef pContinue As %Boolean) As %Status
123
+ {
124
+ Set path = ..#CLASSPATHS
125
+ Set appName = ..#APPNAME
126
+ Set module = ..#MODULENAME
127
+ Set devmode = ..#DEVMODE
128
+ Set pContinue = 1
129
+ Do ..DispatchREST(pUrl, path, appName, module, devmode)
130
+ Quit $$$OK
131
+ }
132
+
133
+ ClassMethod DispatchREST(
134
+ PathInfo As %String,
135
+ appPath As %String,
136
+ appName As %String,
137
+ module As %String,
138
+ devmode As %Boolean = 1) As %Status
139
+ {
140
+ Set builtins = ##CLASS(%SYS.Python).Builtins()
141
+ Set interface = ##CLASS(%SYS.Python).Import("grongier.pex.wsgi.handlers")
142
+ Set rawformdata = ""
143
+ Set environ = builtins.dict()
144
+ Set key = %request.NextCgiEnv("")
145
+
146
+ // Let's check if the WSGI application has been loaded or not for this session.
147
+
148
+ If (($DATA(%session.Data("application")) && $ISOBJECT(%session.Data("application"))) && 'devmode) {
149
+ Set application = %session.Data("Application")
150
+ }
151
+ Else{
152
+
153
+ Set application = ..GetPythonClass(appName, module, appPath)
154
+ If application = "" {
155
+ throw ##class(%Exception.General).%New("Error loading WSGI application: "_module_"."_appName_" from "_appPath)
156
+ }
157
+ Else {
158
+ Set %session.Data("Application") = application
159
+ }
160
+ }
161
+
162
+ // Editing some CGI variables that may be incorrect in %request
163
+ // Also filling in environ with as many CGI variables as possible from %request
164
+ // WSGI states that all CGI variables are valid and should be included if possible
165
+ While (key'="") {
166
+ Set value = %request.GetCgiEnv(key)
167
+ If key = "PATH_INFO" {
168
+ Set app=$$getapp^%SYS.cspServer(%request.URL,.path,.match,.updatedurl)
169
+ Set value = $EXTRACT(updatedurl,$LENGTH(path),*)
170
+ }
171
+ If key = "SCRIPT_NAME" {
172
+ //%request will sometimes have Script_name include Path_info
173
+ Set value = $PIECE(%request.Application, "/",1,*-1)
174
+ }
175
+ Do environ."__setitem__"(key,value)
176
+ Set key = %request.NextCgiEnv(key)
177
+ }
178
+
179
+ //Have to set up a correct wsgi.input stream from %request
180
+ Set stream = %request.Content
181
+
182
+ Set contentType = %request.ContentType
183
+ Set contentLength = 0
184
+
185
+ If contentType = "application/x-www-form-urlencoded" {
186
+ Set formdict = builtins.dict()
187
+ Set key = $ORDER(%request.Data(""))
188
+ While (key'="") {
189
+ Set value = $GET(%request.Data(key,1))
190
+ Do formdict."__setitem__"(key,value)
191
+ Set key = $ORDER(%request.Data(key))
192
+ }
193
+ Do environ."__setitem__"("formdata", formdict)
194
+ }
195
+ ElseIf contentType = "multipart/form-data" {
196
+ Set boundary = $PIECE(%request.GetCgiEnv("CONTENT_TYPE"), "=",2)
197
+ Set stream = ##CLASS(%CSP.BinaryStream).%New()
198
+
199
+ Do stream.Write($CHAR(13,10))
200
+
201
+ //Get the Form Data values
202
+
203
+ Set key = $ORDER(%request.Data(""))
204
+ While (key'="") {
205
+ Do stream.Write("--")
206
+ Do stream.Write(boundary)
207
+ Do stream.Write($CHAR(13,10))
208
+ Set value = $GET(%request.Data(key,1))
209
+ Do stream.Write("Content-Disposition: form-data; name=")
210
+ Do stream.Write(""""_key_"""")
211
+ Do stream.Write($CHAR(13,10,13,10))
212
+ Do stream.Write(value)
213
+ Do stream.Write($CHAR(13,10))
214
+ Set key = $ORDER(%request.Data(key))
215
+ }
216
+
217
+ //Now get the possible MIME data streams
218
+ Set key = %request.NextMimeData("")
219
+ While key'="" {
220
+ Set numMimeStreams = %request.CountMimeData(key)
221
+ Set index = %request.NextMimeDataIndex(key, "")
222
+ Do stream.Write("--")
223
+ Do stream.Write(boundary)
224
+ Do stream.Write($CHAR(13,10))
225
+ If numMimeStreams > 1 {
226
+ //I need to create a boundary for a nested multipart content type
227
+ Set internalboundary = "--"
228
+ For i = 1 : 1 : 7 {
229
+ Set internalboundary = internalboundary _ $RANDOM(10)
230
+ }
231
+ While index '= "" {
232
+ Set mimestream = %request.GetMimeData(key, index)
233
+ Set headers = mimestream.Headers
234
+ Do stream.Write("--")
235
+ Do stream.Write(internalboundary)
236
+ Do stream.Write($CHAR(13,10))
237
+ Do stream.Write(headers)
238
+ Do stream.Write($CHAR(13,10,13,10))
239
+ Set sc = stream.CopyFrom(mimestream)
240
+ //TODO error handling
241
+ Do stream.Write($CHAR(13,10))
242
+ Set index = %request.NextMimeDataIndex(key, index)
243
+ }
244
+ Do stream.Write("--")
245
+ Do stream.Write(internalboundary)
246
+ Do stream.Write("--")
247
+ }
248
+ Else {
249
+ Set mimestream = %request.GetMimeData(key, index)
250
+ Set headers = mimestream.Headers
251
+ Do stream.Write(headers)
252
+ Do stream.Write($CHAR(13,10,13,10))
253
+ Set sc = stream.CopyFrom(mimestream)
254
+ //TODO error handling
255
+ Do stream.Write($CHAR(13,10))
256
+ }
257
+ Set key = %request.NextMimeData(key)
258
+ }
259
+ Do stream.Write("--")
260
+ Do stream.Write(boundary)
261
+ Do stream.Write("--")
262
+ Do stream.Rewind()
263
+ }
264
+
265
+
266
+ Try {
267
+ Do interface."make_request"(environ, stream, application, appPath)
268
+ }
269
+ Catch exception {
270
+ throw exception
271
+ }
272
+ Quit $$$OK
273
+ }
274
+
275
+ ClassMethod GetPythonClass(
276
+ pClassname As %String,
277
+ pModule As %String,
278
+ pClasspath As %String) As %SYS.Python
279
+ {
280
+ Try {
281
+ If pClasspath '="" {
282
+ set sys = ##class(%SYS.Python).Import("sys")
283
+
284
+ for i=0:1:(sys.path."__len__"()-1) {
285
+ Try {
286
+ if sys.path."__getitem__"(i) = pClasspath {
287
+ do sys.path."__delitem__"(i)
288
+ }
289
+ }
290
+ Catch ex {
291
+ // do nothing
292
+ }
293
+
294
+ }
295
+ do sys.path.insert(0, pClasspath)
296
+ }
297
+
298
+ Set importlib = ##class(%SYS.Python).Import("importlib")
299
+ Set builtins = ##class(%SYS.Python).Import("builtins")
300
+ Set module = importlib."import_module"(pModule)
301
+ Set class = builtins.getattr(module, pClassname)
302
+ }
303
+ Catch ex {
304
+ throw ##class(%Exception.General).%New("Error loading WSGI application: "_pModule_"."_pClassname_" from "_pClasspath)
305
+ }
306
+
307
+ Quit class
308
+ }
309
+
310
+ }
iop/cls/IOP/Test.cls ADDED
@@ -0,0 +1,85 @@
1
+ /// Description
2
+ Class IOP.Test Extends %Persistent
3
+ {
4
+
5
+ /// Description
6
+ ClassMethod TestJsonStringMessage() As %Status
7
+ {
8
+ set msg = ##class(IOP.Message).%New()
9
+ set msg.classname = "IOP.Message"
10
+ set msg.json = "{""name"":""John""}"
11
+ set tset = msg.json
12
+ set tst = msg.jstr
13
+ QUIT $$$OK
14
+ }
15
+
16
+ ClassMethod TestJsonStreamMessage() As %Status
17
+ {
18
+ set msg = ##class(IOP.Message).%New()
19
+ set msg.classname = "IOP.Message"
20
+ set stream = ##class(%Stream.GlobalCharacter).%New()
21
+ set sc = stream.Write("{""name"":""John""}")
22
+ set msg.json = stream
23
+ set tset = msg.json
24
+ set tst = msg.jstr
25
+ QUIT $$$OK
26
+ }
27
+
28
+ /// Register
29
+ ClassMethod Register() As %Status
30
+ {
31
+ Set sc = $$$OK
32
+ zw ##class(IOP.Utils).RegisterComponent("MyBusinessOperationWithAdapter","MyBusinessOperationWithAdapter","/irisdev/app/src/python/demo/",1,"PEX.MyBusinessOperationWithAdapter")
33
+ #dim array as %ArrayOfObjects
34
+ Return sc
35
+ }
36
+
37
+ ClassMethod TestBO() As %Status
38
+ {
39
+ try {
40
+ Set sc = $$$OK
41
+ set mybo = ##class(IOP.BusinessOperation).%New("mybo")
42
+ set mybo.%classpaths = "/irisdev/app/src/python/demo"
43
+ set mybo.%module = "MyBusinessOperationWithAdapter"
44
+ set mybo.%classname = "MyBusinessOperationWithAdapter"
45
+ $$$ThrowOnError(mybo.OnInit())
46
+ set request = ##class(Ens.StringRequest).%New("hello")
47
+ set request = ##class(EnsLib.PEX.Message).%New()
48
+ set request.%classname = "MyRequest.MyRequest"
49
+ set dyna = {"requestString":"hello!"}
50
+ set request.%jsonObject = dyna
51
+ Try {
52
+ $$$ThrowOnError(mybo.OnMessage(request,.response))
53
+ zw response
54
+ } catch importEx {
55
+ WRITE $System.Status.GetOneStatusText(importEx.AsStatus(),1),!
56
+ }
57
+ } catch ex {
58
+ WRITE $System.Status.GetOneStatusText(ex.AsStatus(),1),!
59
+ }
60
+
61
+ Return sc
62
+ }
63
+
64
+ /// List
65
+ ClassMethod PythonList() [ Language = python ]
66
+ {
67
+ return [ 1, 3 ]
68
+ }
69
+
70
+ Storage Default
71
+ {
72
+ <Data name="TestDefaultData">
73
+ <Value name="1">
74
+ <Value>%%CLASSNAME</Value>
75
+ </Value>
76
+ </Data>
77
+ <DataLocation>^IOP.TestD</DataLocation>
78
+ <DefaultData>TestDefaultData</DefaultData>
79
+ <IdLocation>^IOP.TestD</IdLocation>
80
+ <IndexLocation>^IOP.TestI</IndexLocation>
81
+ <StreamLocation>^IOP.TestS</StreamLocation>
82
+ <Type>%Storage.Persistent</Type>
83
+ }
84
+
85
+ }