Merge lp:~kissiel/checkbox/use-pyotherside1.4 into lp:checkbox
- use-pyotherside1.4
- Merge into trunk
Proposed by
Maciej Kisielewski
Status: | Merged |
---|---|
Approved by: | Zygmunt Krynicki |
Approved revision: | 3814 |
Merged at revision: | 3813 |
Proposed branch: | lp:~kissiel/checkbox/use-pyotherside1.4 |
Merge into: | lp:checkbox |
Diff against target: |
417 lines (+97/-193) 6 files modified
checkbox-touch/checkbox-touch.qml (+3/-7) checkbox-touch/components/CheckboxTouchApplication.qml (+5/-4) checkbox-touch/components/PythonLogger.qml (+13/-7) checkbox-touch/components/PythonObjectHandle.qml (+0/-76) checkbox-touch/components/PythonObjectRef.qml (+69/-0) checkbox-touch/py/checkbox_touch.py (+7/-99) |
To merge this branch: | bzr merge lp:~kissiel/checkbox/use-pyotherside1.4 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Zygmunt Krynicki (community) | Approve | ||
Review via email: mp+260106@code.launchpad.net |
Commit message
Description of the change
Migration from PythonObjectHandle to PythonObjectRef (pyotherside-1.4)
To post a comment you must log in.
- 3811. By Maciej Kisielewski
-
checkbox-touch: add PythonObjectRef component
This patch adds qml component that handles referencing python objects from qml
side.Signed-off-by: Maciej Kisielewski <email address hidden>
- 3812. By Maciej Kisielewski
-
checkbox-touch: migrate CheckboxTouchAp
plication class to PythonObjectRef This patch moves main CheckboxTouchAp
plication class to be used through
PythonObjectRef from QML side. - 3813. By Maciej Kisielewski
-
checkbox-touch: migrate PythonLogger to PythonObjectRef
Signed-off-by: Maciej Kisielewski <email address hidden>
- 3814. By Maciej Kisielewski
-
checkbox-touch: remove PythonObjectHandle
Signed-off-by: Maciej Kisielewski <email address hidden>
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'checkbox-touch/checkbox-touch.qml' | |||
2 | --- checkbox-touch/checkbox-touch.qml 2015-05-20 07:56:01 +0000 | |||
3 | +++ checkbox-touch/checkbox-touch.qml 2015-05-27 06:52:22 +0000 | |||
4 | @@ -23,7 +23,7 @@ | |||
5 | 23 | import Ubuntu.Components 1.1 | 23 | import Ubuntu.Components 1.1 |
6 | 24 | import Ubuntu.Components.Popups 0.1 | 24 | import Ubuntu.Components.Popups 0.1 |
7 | 25 | import QtQuick.Layouts 1.1 | 25 | import QtQuick.Layouts 1.1 |
9 | 26 | import io.thp.pyotherside 1.2 | 26 | import io.thp.pyotherside 1.4 |
10 | 27 | import "components" | 27 | import "components" |
11 | 28 | import "components/ErrorLogic.js" as ErrorLogic | 28 | import "components/ErrorLogic.js" as ErrorLogic |
12 | 29 | import "components/CbtDialogLogic.js" as CbtDialogLogic | 29 | import "components/CbtDialogLogic.js" as CbtDialogLogic |
13 | @@ -110,9 +110,7 @@ | |||
14 | 110 | // create_app_object() function and assign the resulting handle | 110 | // create_app_object() function and assign the resulting handle |
15 | 111 | // back to the application component. | 111 | // back to the application component. |
16 | 112 | py.importModule("checkbox_touch", function() { | 112 | py.importModule("checkbox_touch", function() { |
20 | 113 | call("checkbox_touch.create_app_object", [], function(handle) { | 113 | app.construct("checkbox_touch.create_app_object", []) |
18 | 114 | app.handle = handle; | ||
19 | 115 | }); | ||
21 | 116 | }); | 114 | }); |
22 | 117 | } | 115 | } |
23 | 118 | onError: { | 116 | onError: { |
24 | @@ -146,9 +144,7 @@ | |||
25 | 146 | Component.onCompleted: { | 144 | Component.onCompleted: { |
26 | 147 | py.Component.onCompleted.connect(function() { | 145 | py.Component.onCompleted.connect(function() { |
27 | 148 | py.importModule("checkbox_touch", function() { | 146 | py.importModule("checkbox_touch", function() { |
31 | 149 | py.call("checkbox_touch.get_qml_logger", [], function(handle) { | 147 | construct("checkbox_touch.get_qml_logger", []); |
29 | 150 | logger.handle = handle; | ||
30 | 151 | }); | ||
32 | 152 | }); | 148 | }); |
33 | 153 | }); | 149 | }); |
34 | 154 | } | 150 | } |
35 | 155 | 151 | ||
36 | === modified file 'checkbox-touch/components/CheckboxTouchApplication.qml' | |||
37 | --- checkbox-touch/components/CheckboxTouchApplication.qml 2015-05-12 09:58:35 +0000 | |||
38 | +++ checkbox-touch/components/CheckboxTouchApplication.qml 2015-05-27 06:52:22 +0000 | |||
39 | @@ -1,10 +1,11 @@ | |||
40 | 1 | /* | 1 | /* |
41 | 2 | * This file is part of Checkbox | 2 | * This file is part of Checkbox |
42 | 3 | * | 3 | * |
44 | 4 | * Copyright 2014 Canonical Ltd. | 4 | * Copyright 2014-2015 Canonical Ltd. |
45 | 5 | * | 5 | * |
46 | 6 | * Authors: | 6 | * Authors: |
47 | 7 | * - Zygmunt Krynicki <zygmunt.krynicki@canonical.com> | 7 | * - Zygmunt Krynicki <zygmunt.krynicki@canonical.com> |
48 | 8 | * - Maciej Kisielewski <maciej.kisielewski@canonical.com> | ||
49 | 8 | * | 9 | * |
50 | 9 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
51 | 10 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
52 | @@ -24,7 +25,7 @@ | |||
53 | 24 | import "ErrorLogic.js" as ErrorLogic | 25 | import "ErrorLogic.js" as ErrorLogic |
54 | 25 | 26 | ||
55 | 26 | 27 | ||
57 | 27 | PythonObjectHandle { | 28 | PythonObjectRef { |
58 | 28 | id: app | 29 | id: app |
59 | 29 | // Version of the application | 30 | // Version of the application |
60 | 30 | property string applicationVersion | 31 | property string applicationVersion |
61 | @@ -37,7 +38,7 @@ | |||
62 | 37 | signal appReady(); | 38 | signal appReady(); |
63 | 38 | 39 | ||
64 | 39 | // Signal sent when a session becomes ready | 40 | // Signal sent when a session becomes ready |
66 | 40 | signal sessionReady(); | 41 | signal sessionReady() |
67 | 41 | 42 | ||
68 | 42 | // Create a new session | 43 | // Create a new session |
69 | 43 | // | 44 | // |
70 | @@ -168,7 +169,7 @@ | |||
71 | 168 | 169 | ||
72 | 169 | // Internal handler that triggers a call to python to query for runtime and | 170 | // Internal handler that triggers a call to python to query for runtime and |
73 | 170 | // application versions. | 171 | // application versions. |
75 | 171 | onHandleReady: { | 172 | onObjectReady: { |
76 | 172 | request("get_version_pair", [], function(result) { | 173 | request("get_version_pair", [], function(result) { |
77 | 173 | app.applicationVersion = result.application_version; | 174 | app.applicationVersion = result.application_version; |
78 | 174 | app.plainboxVersion = result.plainbox_version; | 175 | app.plainboxVersion = result.plainbox_version; |
79 | 175 | 176 | ||
80 | === modified file 'checkbox-touch/components/PythonLogger.qml' | |||
81 | --- checkbox-touch/components/PythonLogger.qml 2015-02-09 14:19:45 +0000 | |||
82 | +++ checkbox-touch/components/PythonLogger.qml 2015-05-27 06:52:22 +0000 | |||
83 | @@ -20,7 +20,7 @@ | |||
84 | 20 | */ | 20 | */ |
85 | 21 | 21 | ||
86 | 22 | /*! \brief Python-driven logger | 22 | /*! \brief Python-driven logger |
88 | 23 | \inherits PythonObjectHandle | 23 | \inherits PythonObjectRef |
89 | 24 | 24 | ||
90 | 25 | This component uses pyotherside to forward logging events to python. | 25 | This component uses pyotherside to forward logging events to python. |
91 | 26 | It monkey-patches console.log and console.error to capture their calls | 26 | It monkey-patches console.log and console.error to capture their calls |
92 | @@ -28,7 +28,8 @@ | |||
93 | 28 | */ | 28 | */ |
94 | 29 | import QtQuick 2.0 | 29 | import QtQuick 2.0 |
95 | 30 | 30 | ||
97 | 31 | PythonObjectHandle { | 31 | PythonObjectRef { |
98 | 32 | id: pythonLogger | ||
99 | 32 | 33 | ||
100 | 33 | function debug(msg) { | 34 | function debug(msg) { |
101 | 34 | invoke('debug', [msg], function() {}); | 35 | invoke('debug', [msg], function() {}); |
102 | @@ -63,13 +64,18 @@ | |||
103 | 63 | 64 | ||
104 | 64 | /** Overridden invoke that doesn't log invoke calls */ | 65 | /** Overridden invoke that doesn't log invoke calls */ |
105 | 65 | function invoke(func, args, callback) { | 66 | function invoke(func, args, callback) { |
108 | 66 | if (py !== null && handle > 0) { | 67 | if (py !== null && object !== null) { |
109 | 67 | py.call("py_invoke", [handle, func, args], function(response) { | 68 | var callable = py.getattr(object, func); |
110 | 69 | if (!callable) { | ||
111 | 70 | console.error("Unable to invoke " + func + " on python logger"); | ||
112 | 71 | throw "trying to invoke not existing method" | ||
113 | 72 | } | ||
114 | 73 | py.call(callable, args, function(response) { | ||
115 | 68 | callback(response); | 74 | callback(response); |
116 | 69 | }); | 75 | }); |
117 | 70 | } else { | 76 | } else { |
120 | 71 | _original_console_error("unable to py_invoke: " + handle + ", " + func + ", " + JSON.stringify(args)); | 77 | _original_console_error("unable to invoke " + func + " on python logger"); |
121 | 72 | throw "py_invoke called without ready py and handle"; | 78 | throw "invoke called without py initiated and/or object constructed"; |
122 | 73 | } | 79 | } |
123 | 74 | } | 80 | } |
124 | 75 | 81 | ||
125 | @@ -79,7 +85,7 @@ | |||
126 | 79 | _original_console_error = console.error; | 85 | _original_console_error = console.error; |
127 | 80 | } | 86 | } |
128 | 81 | 87 | ||
130 | 82 | onHandleReady: { | 88 | onObjectReady: { |
131 | 83 | /* monkey-patch console.log and console.error */ | 89 | /* monkey-patch console.log and console.error */ |
132 | 84 | console.log = function() { debug(_argsToString(arguments)); }; | 90 | console.log = function() { debug(_argsToString(arguments)); }; |
133 | 85 | console.error = function() { error(_argsToString(arguments)); }; | 91 | console.error = function() { error(_argsToString(arguments)); }; |
134 | 86 | 92 | ||
135 | === removed file 'checkbox-touch/components/PythonObjectHandle.qml' | |||
136 | --- checkbox-touch/components/PythonObjectHandle.qml 2014-09-29 19:18:47 +0000 | |||
137 | +++ checkbox-touch/components/PythonObjectHandle.qml 1970-01-01 00:00:00 +0000 | |||
138 | @@ -1,76 +0,0 @@ | |||
139 | 1 | /* | ||
140 | 2 | * This file is part of Checkbox | ||
141 | 3 | * | ||
142 | 4 | * Copyright 2014 Canonical Ltd. | ||
143 | 5 | * | ||
144 | 6 | * Authors: | ||
145 | 7 | * - Zygmunt Krynicki <zygmunt.krynicki@canonical.com> | ||
146 | 8 | * | ||
147 | 9 | * This program is free software; you can redistribute it and/or modify | ||
148 | 10 | * it under the terms of the GNU General Public License as published by | ||
149 | 11 | * the Free Software Foundation; version 3. | ||
150 | 12 | * | ||
151 | 13 | * This program is distributed in the hope that it will be useful, | ||
152 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
153 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
154 | 16 | * GNU General Public License for more details. | ||
155 | 17 | * | ||
156 | 18 | * You should have received a copy of the GNU General Public License | ||
157 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
158 | 20 | */ | ||
159 | 21 | import QtQuick 2.0 | ||
160 | 22 | |||
161 | 23 | |||
162 | 24 | QtObject { | ||
163 | 25 | // Reference to pyotherside's Python object | ||
164 | 26 | property var py: null | ||
165 | 27 | // Handle to a python object (via RemoteObjectLifecycleManager) | ||
166 | 28 | // if it is < 0 then it is an error of some kind | ||
167 | 29 | // if it is 0 (default) then the handle is just invalid | ||
168 | 30 | // if it is > 0 then it represents a valid object handle | ||
169 | 31 | property int handle: 0 | ||
170 | 32 | // Flag set just prior to sending the handleReady() signal | ||
171 | 33 | property bool _ready: false | ||
172 | 34 | |||
173 | 35 | // Signal sent when the handle is initially assigned *and* py is already | ||
174 | 36 | // assigned (so when the python object is ready to be interacted with) | ||
175 | 37 | signal handleReady(); | ||
176 | 38 | |||
177 | 39 | // Dereference the python object when we are shutting down | ||
178 | 40 | Component.onDestruction: _unref() | ||
179 | 41 | // Maybe send the handleReady signal (once) when handle is changed | ||
180 | 42 | onHandleChanged: _maybeReady() | ||
181 | 43 | // Maybe send the handleReady signal (once) when 'py' is changed | ||
182 | 44 | onPyChanged: _maybeReady() | ||
183 | 45 | |||
184 | 46 | /** Send the handleReady() signal (once) if both py and handle are ready */ | ||
185 | 47 | function _maybeReady() { | ||
186 | 48 | if (handle > 0 && py !== null && _ready == false) { | ||
187 | 49 | _ready = true; | ||
188 | 50 | handleReady() | ||
189 | 51 | } | ||
190 | 52 | } | ||
191 | 53 | |||
192 | 54 | /** Dereference this object */ | ||
193 | 55 | function _unref() { | ||
194 | 56 | if (py !== null && handle > 0) { | ||
195 | 57 | // console.log("py_unref: " + handle); | ||
196 | 58 | py.call("py_unref", [handle]); | ||
197 | 59 | handle = 0; | ||
198 | 60 | } | ||
199 | 61 | } | ||
200 | 62 | |||
201 | 63 | /** Call a method on this object */ | ||
202 | 64 | function invoke(func, args, callback) { | ||
203 | 65 | if (py !== null && handle > 0) { | ||
204 | 66 | console.log("py_invoke(" + handle + ", " + func + ", " + JSON.stringify(args) + ") ..."); | ||
205 | 67 | py.call("py_invoke", [handle, func, args], function(response) { | ||
206 | 68 | console.log("py_invoke(" + handle + ", " + func + ", " + JSON.stringify(args) + ") -> " + JSON.stringify(response)); | ||
207 | 69 | callback(response); | ||
208 | 70 | }); | ||
209 | 71 | } else { | ||
210 | 72 | console.error("unable to py_invoke: " + handle + ", " + func + ", " + JSON.stringify(args)); | ||
211 | 73 | throw "py_invoke called without ready py and handle"; | ||
212 | 74 | } | ||
213 | 75 | } | ||
214 | 76 | } | ||
215 | 77 | 0 | ||
216 | === added file 'checkbox-touch/components/PythonObjectRef.qml' | |||
217 | --- checkbox-touch/components/PythonObjectRef.qml 1970-01-01 00:00:00 +0000 | |||
218 | +++ checkbox-touch/components/PythonObjectRef.qml 2015-05-27 06:52:22 +0000 | |||
219 | @@ -0,0 +1,69 @@ | |||
220 | 1 | /* | ||
221 | 2 | * This file is part of Checkbox | ||
222 | 3 | * | ||
223 | 4 | * Copyright 2015 Canonical Ltd. | ||
224 | 5 | * | ||
225 | 6 | * Authors: | ||
226 | 7 | * - Maciej Kisielewski <maciej.kisielewski@canonical.com> | ||
227 | 8 | * | ||
228 | 9 | * This program is free software; you can redistribute it and/or modify | ||
229 | 10 | * it under the terms of the GNU General Public License as published by | ||
230 | 11 | * the Free Software Foundation; version 3. | ||
231 | 12 | * | ||
232 | 13 | * This program is distributed in the hope that it will be useful, | ||
233 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
234 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
235 | 16 | * GNU General Public License for more details. | ||
236 | 17 | * | ||
237 | 18 | * You should have received a copy of the GNU General Public License | ||
238 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
239 | 20 | */ | ||
240 | 21 | import QtQuick 2.0 | ||
241 | 22 | |||
242 | 23 | |||
243 | 24 | QtObject { | ||
244 | 25 | id: pythonObjectRef | ||
245 | 26 | |||
246 | 27 | // Reference to pyotherside's Python object | ||
247 | 28 | property var py: null | ||
248 | 29 | |||
249 | 30 | // PyObjectRef to the object | ||
250 | 31 | property var object: null | ||
251 | 32 | |||
252 | 33 | // Signal sent when the object reference is ready to use | ||
253 | 34 | signal objectReady() | ||
254 | 35 | |||
255 | 36 | // Creation method name that were used to get the reference to the object | ||
256 | 37 | property var creationMethodName: null | ||
257 | 38 | |||
258 | 39 | function construct(creationMethodName, args) { | ||
259 | 40 | if (!py) { | ||
260 | 41 | console.error("Trying to get reference to python object without py initiated!"); | ||
261 | 42 | } else { | ||
262 | 43 | console.info("Getting reference to python object via " + creationMethodName); | ||
263 | 44 | py.call(creationMethodName, args, function(result) { | ||
264 | 45 | object = result; | ||
265 | 46 | pythonObjectRef.creationMethodName = creationMethodName; | ||
266 | 47 | objectReady(); | ||
267 | 48 | }); | ||
268 | 49 | } | ||
269 | 50 | } | ||
270 | 51 | /** Call a method on this object */ | ||
271 | 52 | function invoke(func, args, callback) { | ||
272 | 53 | if (py !== null && object !== null) { | ||
273 | 54 | console.log("invoking " + func + " on object created with" + pythonObjectRef.creationMethodName + ", with args: " + JSON.stringify(args) + " ..."); | ||
274 | 55 | var callable = py.getattr(object, func); | ||
275 | 56 | if (!callable) { | ||
276 | 57 | console.log("Unable to invoke " + func + " on object " + JSON.stringify(pythonObjectRef)); | ||
277 | 58 | throw "trying to invoke inexistent method" | ||
278 | 59 | } | ||
279 | 60 | py.call(callable, args, function(response) { | ||
280 | 61 | console.log(func + " on object created with" + pythonObjectRef.creationMethodName + ", with args: " + JSON.stringify(args) + " returned: " + JSON.stringify(response)); | ||
281 | 62 | callback(response); | ||
282 | 63 | }); | ||
283 | 64 | } else { | ||
284 | 65 | console.error("Unable to invoke " + func + " on object " + JSON.stringify(pythonObjectRef)); | ||
285 | 66 | throw "invoke called without py initiated and/or object constructed"; | ||
286 | 67 | } | ||
287 | 68 | } | ||
288 | 69 | } | ||
289 | 0 | 70 | ||
290 | === modified file 'checkbox-touch/py/checkbox_touch.py' | |||
291 | --- checkbox-touch/py/checkbox_touch.py 2015-05-18 11:20:02 +0000 | |||
292 | +++ checkbox-touch/py/checkbox_touch.py 2015-05-27 06:52:22 +0000 | |||
293 | @@ -65,72 +65,9 @@ | |||
294 | 65 | from embedded_providers import EmbeddedProvider1PlugInCollection | 65 | from embedded_providers import EmbeddedProvider1PlugInCollection |
295 | 66 | 66 | ||
296 | 67 | _logger = logging.getLogger('checkbox.touch') | 67 | _logger = logging.getLogger('checkbox.touch') |
363 | 68 | _manager = None | 68 | |
364 | 69 | 69 | ||
365 | 70 | 70 | class PlainboxApplication(metaclass=abc.ABCMeta): | |
300 | 71 | class VerboseLifecycle: | ||
301 | 72 | """ | ||
302 | 73 | Mix-in class for verbose lifecycle reporting | ||
303 | 74 | """ | ||
304 | 75 | |||
305 | 76 | def __new__(cls, *args, **kwargs): | ||
306 | 77 | self = super().__new__(cls, *args, **kwargs) | ||
307 | 78 | _logger.debug("new %s %x", cls.__name__, id(self)) | ||
308 | 79 | return self | ||
309 | 80 | |||
310 | 81 | def __del__(self): | ||
311 | 82 | _logger.debug("del %s %x", self.__class__.__name__, id(self)) | ||
312 | 83 | |||
313 | 84 | |||
314 | 85 | class RemoteObjectLifecycleManager(VerboseLifecycle): | ||
315 | 86 | """ | ||
316 | 87 | Remote object life-cycle manager | ||
317 | 88 | |||
318 | 89 | This class aids in handling non-trivial objects that are referenced from | ||
319 | 90 | QML (via pyotherside) but really stored on the python side. | ||
320 | 91 | """ | ||
321 | 92 | |||
322 | 93 | def __init__(self): | ||
323 | 94 | self._count = 0 | ||
324 | 95 | self._handle_map = {} | ||
325 | 96 | |||
326 | 97 | def unref(self, handle: int): | ||
327 | 98 | """ | ||
328 | 99 | Remove a reference represented by the specified handle | ||
329 | 100 | """ | ||
330 | 101 | _logger.debug("unref %s", handle) | ||
331 | 102 | del self._handle_map[handle] | ||
332 | 103 | |||
333 | 104 | def ref(self, obj: object) -> int: | ||
334 | 105 | """ | ||
335 | 106 | Store a reference to an object and return the handle | ||
336 | 107 | """ | ||
337 | 108 | self._count += 1 | ||
338 | 109 | handle = self._count | ||
339 | 110 | self._handle_map[handle] = obj | ||
340 | 111 | _logger.debug("ref %r -> %s", obj, handle) | ||
341 | 112 | return handle | ||
342 | 113 | |||
343 | 114 | def invoke(self, handle: int, func: str, args): | ||
344 | 115 | """ | ||
345 | 116 | Call a method on a object represented by the handle | ||
346 | 117 | |||
347 | 118 | :param handle: | ||
348 | 119 | A (numeric) handle to the objecet | ||
349 | 120 | :param func: | ||
350 | 121 | The (name of the) function to call | ||
351 | 122 | :param args: | ||
352 | 123 | A list of positional arguments to pass | ||
353 | 124 | :returns: | ||
354 | 125 | The value returned by the called method | ||
355 | 126 | """ | ||
356 | 127 | obj = self._handle_map[handle] | ||
357 | 128 | impl = getattr(obj, func) | ||
358 | 129 | retval = impl(*args) | ||
359 | 130 | return retval | ||
360 | 131 | |||
361 | 132 | |||
362 | 133 | class PlainboxApplication(VerboseLifecycle, metaclass=abc.ABCMeta): | ||
366 | 134 | """ | 71 | """ |
367 | 135 | Base class for plainbox-based applications. | 72 | Base class for plainbox-based applications. |
368 | 136 | 73 | ||
369 | @@ -141,16 +78,6 @@ | |||
370 | 141 | def __repr__(self): | 78 | def __repr__(self): |
371 | 142 | return "<{}>".format(self.__class__.__name__) | 79 | return "<{}>".format(self.__class__.__name__) |
372 | 143 | 80 | ||
373 | 144 | @classmethod | ||
374 | 145 | def create_and_get_handle(cls): | ||
375 | 146 | """ | ||
376 | 147 | Create an instance of the high-level PlainBox object | ||
377 | 148 | |||
378 | 149 | :returns: | ||
379 | 150 | A handle to a fresh instance of :class:`PlainBox` | ||
380 | 151 | """ | ||
381 | 152 | return _manager.ref(cls()) | ||
382 | 153 | |||
383 | 154 | @abc.abstractmethod | 81 | @abc.abstractmethod |
384 | 155 | def get_version_pair(self): | 82 | def get_version_pair(self): |
385 | 156 | """ | 83 | """ |
386 | @@ -820,27 +747,8 @@ | |||
387 | 820 | self._password = password | 747 | self._password = password |
388 | 821 | 748 | ||
389 | 822 | 749 | ||
390 | 823 | def bootstrap(): | ||
391 | 824 | logging.basicConfig(level=logging.INFO, stream=sys.stderr) | ||
392 | 825 | logging.info("environ: %r", os.environ) | ||
393 | 826 | logging.info("path: %r", sys.path) | ||
394 | 827 | # from plainbox.impl.logging import adjust_logging | ||
395 | 828 | # from plainbox.impl.logging import setup_logging | ||
396 | 829 | # Setup logging | ||
397 | 830 | # setup_logging() | ||
398 | 831 | # adjust_logging(logging.DEBUG, ['checkbox.stack'], True) | ||
399 | 832 | # Create the Javascript <=> Python remote object lifecycle manager | ||
400 | 833 | manager = RemoteObjectLifecycleManager() | ||
401 | 834 | # Expose top-level functions for pyotherside's simplicity | ||
402 | 835 | builtins.py_ref = manager.ref | ||
403 | 836 | builtins.py_unref = manager.unref | ||
404 | 837 | builtins.py_invoke = manager.invoke | ||
405 | 838 | return manager | ||
406 | 839 | |||
407 | 840 | |||
408 | 841 | def get_qml_logger(): | 750 | def get_qml_logger(): |
414 | 842 | return _manager.ref(logging.getLogger('checkbox.touch.qml')) | 751 | return logging.getLogger('checkbox.touch.qml') |
415 | 843 | 752 | ||
416 | 844 | 753 | ||
417 | 845 | create_app_object = CheckboxTouchApplication.create_and_get_handle | 754 | create_app_object = CheckboxTouchApplication |
413 | 846 | _manager = bootstrap() |
Looks good, thanks for changing this. +1