Show More
@@ -101,4 +101,4 b' gitwash-update:' | |||||
101 | cd source/development/gitwash && rename 's/.rst/.txt/' *.rst |
|
101 | cd source/development/gitwash && rename 's/.rst/.txt/' *.rst | |
102 |
|
102 | |||
103 | nightly: dist |
|
103 | nightly: dist | |
104 | rsync -avH --delete dist/ ipython:www/doc/nightly No newline at end of file |
|
104 | rsync -avH --delete dist/ ipython:www/doc/nightly |
@@ -130,20 +130,9 b' Messages on the XREP/XREQ socket' | |||||
130 | Execute |
|
130 | Execute | |
131 | ------- |
|
131 | ------- | |
132 |
|
132 | |||
133 | The execution request contains a single string, but this may be a multiline |
|
133 | This message type is used by frontends to ask the kernel to execute code on | |
134 | string. The kernel is responsible for splitting this into possibly more than |
|
134 | behalf of the user, in a namespace reserved to the user's variables (and thus | |
135 | one block and deciding whether to compile these in 'single' or 'exec' mode. |
|
135 | separate from the kernel's own internal code and variables). | |
136 | We're still sorting out this policy. The current inputsplitter is capable of |
|
|||
137 | splitting the input for blocks that can all be run as 'single', but in the long |
|
|||
138 | run it may prove cleaner to only use 'single' mode for truly single-line |
|
|||
139 | inputs, and run all multiline input in 'exec' mode. This would preserve the |
|
|||
140 | natural behavior of single-line inputs while allowing long cells to behave more |
|
|||
141 | likea a script. This design will be refined as we complete the implementation. |
|
|||
142 |
|
||||
143 | .. Note:: |
|
|||
144 |
|
||||
145 | What today we call 'prompt requests' will be encoded in the |
|
|||
146 | ``state_template`` field. |
|
|||
147 |
|
136 | |||
148 | Message type: ``execute_request``:: |
|
137 | Message type: ``execute_request``:: | |
149 |
|
138 | |||
@@ -162,25 +151,75 b' Message type: ``execute_request``::' | |||||
162 | # The default is False. |
|
151 | # The default is False. | |
163 | 'silent' : bool, |
|
152 | 'silent' : bool, | |
164 |
|
153 | |||
165 | # An optional string to request arbitrary state information from the |
|
154 | # A list of variable names from the user's namespace to be retrieved. What | |
166 | # kernel. This string is evaluated via the itpl module, and it can |
|
155 | # returns is a JSON string of the variable's repr(), not a python object. | |
167 | # therefore contain arbitrary code for execution. |
|
156 | 'user_variables' : list, | |
168 |
|
157 | |||
169 | 'state_template' : str, |
|
158 | # Similarly, a dict mapping names to expressions to be evaluated in the | |
|
159 | # user's dict. | |||
|
160 | 'user_expressions' : dict, | |||
170 | } |
|
161 | } | |
171 |
|
162 | |||
|
163 | The ``code`` field contains a single string, but this may be a multiline | |||
|
164 | string. The kernel is responsible for splitting this into possibly more than | |||
|
165 | one block and deciding whether to compile these in 'single' or 'exec' mode. | |||
|
166 | We're still sorting out this policy. The current inputsplitter is capable of | |||
|
167 | splitting the input for blocks that can all be run as 'single', but in the long | |||
|
168 | run it may prove cleaner to only use 'single' mode for truly single-line | |||
|
169 | inputs, and run all multiline input in 'exec' mode. This would preserve the | |||
|
170 | natural behavior of single-line inputs while allowing long cells to behave more | |||
|
171 | likea a script. This design will be refined as we complete the implementation. | |||
|
172 | ||||
|
173 | The ``user_`` fields deserve a detailed explanation. In the past, IPython had | |||
|
174 | the notion of a prompt string that allowed arbitrary code to be evaluated, and | |||
|
175 | this was put to good use by many in creating prompts that displayed system | |||
|
176 | status, path information, and even more esoteric uses like remote instrument | |||
|
177 | status aqcuired over the network. But now that IPython has a clean separation | |||
|
178 | between the kernel and the clients, the notion of embedding 'prompt' | |||
|
179 | maninpulations into the kernel itself feels awkward. Prompts should be a | |||
|
180 | frontend-side feature, and it should be even possible for different frontends | |||
|
181 | to display different prompts while interacting with the same kernel. | |||
|
182 | ||||
|
183 | We have therefore abandoned the idea of a 'prompt string' to be evaluated by | |||
|
184 | the kernel, and instead provide the ability to retrieve from the user's | |||
|
185 | namespace information after the execution of the main ``code``, with two fields | |||
|
186 | of the execution request: | |||
|
187 | ||||
|
188 | - ``user_variables``: If only variables from the user's namespace are needed, a | |||
|
189 | list of variable names can be passed and a dict with these names as keys and | |||
|
190 | their :func:`repr()` as values will be returned. | |||
|
191 | ||||
|
192 | - ``user_expressions``: For more complex expressions that require function | |||
|
193 | evaluations, a dict can be provided with string keys and arbitrary python | |||
|
194 | expressions as values. The return message will contain also a dict with the | |||
|
195 | same keys and the :func:`repr()` of the evaluated expressions as value. | |||
|
196 | ||||
|
197 | With this information, frontends can display any status information they wish | |||
|
198 | in the form that best suits each frontend (a status line, a popup, inline for a | |||
|
199 | terminal, etc). | |||
|
200 | ||||
|
201 | .. Note:: | |||
|
202 | ||||
|
203 | In order to obtain the current execution counter for the purposes of | |||
|
204 | displaying input prompts, frontends simply make an execution request with an | |||
|
205 | empty code string and ``silent=True``. | |||
|
206 | ||||
172 | Execution semantics |
|
207 | Execution semantics | |
173 |
Upon e |
|
208 | Upon completion of the execution request, the kernel *always* sends a | |
174 |
with a status code indicating what happened and additional data |
|
209 | reply, with a status code indicating what happened and additional data | |
175 | on the outcome. |
|
210 | depending on the outcome. | |
|
211 | ||||
|
212 | The ``code`` field is executed first, and then the ``user_variables`` and | |||
|
213 | ``user_expressions`` are computed. This ensures that any error in the | |||
|
214 | latter don't harm the main code execution. | |||
176 |
|
215 | |||
177 | Any code in the ``state_template`` string is evaluated, but full exceptions |
|
216 | Any error in retrieving the ``user_variables`` or evaluating the | |
178 | that may occur are *not* propagated back. If any error occurs during the |
|
217 | ``user_expressions`` will result in a simple error message in the return | |
179 | evaluation, the value of the string will simply be:: |
|
218 | fields of the form:: | |
180 |
|
219 | |||
181 |
[ERROR |
|
220 | [ERROR] ExceptionType: Exception message | |
182 |
|
221 | |||
183 |
The user can simply send the same |
|
222 | The user can simply send the same variable name or expression for | |
184 | evaluation to see a regular traceback. |
|
223 | evaluation to see a regular traceback. | |
185 |
|
224 | |||
186 | Execution counter (old prompt number) |
|
225 | Execution counter (old prompt number) | |
@@ -280,7 +319,7 b' Message type: ``getattr_request``::' | |||||
280 |
|
319 | |||
281 | content = { |
|
320 | content = { | |
282 | # The (possibly dotted) name of the attribute |
|
321 | # The (possibly dotted) name of the attribute | |
283 | 'name' : str |
|
322 | 'name' : str, | |
284 | } |
|
323 | } | |
285 |
|
324 | |||
286 | When a ``getattr_request`` fails, there are two possible error types: |
|
325 | When a ``getattr_request`` fails, there are two possible error types: | |
@@ -296,20 +335,20 b' Message type: ``getattr_reply``::' | |||||
296 |
|
335 | |||
297 | content = { |
|
336 | content = { | |
298 | # One of ['ok', 'AttributeError', 'AccessError']. |
|
337 | # One of ['ok', 'AttributeError', 'AccessError']. | |
299 | 'status' : str |
|
338 | 'status' : str, | |
300 | # If status is 'ok', a JSON object. |
|
339 | # If status is 'ok', a JSON object. | |
301 | 'value' : object |
|
340 | 'value' : object, | |
302 | } |
|
341 | } | |
303 |
|
342 | |||
304 | Message type: ``setattr_request``:: |
|
343 | Message type: ``setattr_request``:: | |
305 |
|
344 | |||
306 | content = { |
|
345 | content = { | |
307 | # The (possibly dotted) name of the attribute |
|
346 | # The (possibly dotted) name of the attribute | |
308 | 'name' : str |
|
347 | 'name' : str, | |
309 |
|
348 | |||
310 | # A JSON-encoded object, that will be validated by the Traits |
|
349 | # A JSON-encoded object, that will be validated by the Traits | |
311 | # information in the kernel |
|
350 | # information in the kernel | |
312 | 'value' : object |
|
351 | 'value' : object, | |
313 | } |
|
352 | } | |
314 |
|
353 | |||
315 | When a ``setattr_request`` fails, there are also two possible error types with |
|
354 | When a ``setattr_request`` fails, there are also two possible error types with | |
@@ -319,7 +358,7 b' Message type: ``setattr_reply``::' | |||||
319 |
|
358 | |||
320 | content = { |
|
359 | content = { | |
321 | # One of ['ok', 'AttributeError', 'AccessError']. |
|
360 | # One of ['ok', 'AttributeError', 'AccessError']. | |
322 | 'status' : str |
|
361 | 'status' : str, | |
323 | } |
|
362 | } | |
324 |
|
363 | |||
325 |
|
364 | |||
@@ -391,13 +430,13 b' Message type: ``object_info_reply``::' | |||||
391 | # The name of the varargs (*args), if any |
|
430 | # The name of the varargs (*args), if any | |
392 | varargs : str, |
|
431 | varargs : str, | |
393 | # The name of the varkw (**kw), if any |
|
432 | # The name of the varkw (**kw), if any | |
394 | varkw : str |
|
433 | varkw : str, | |
395 | # The values (as strings) of all default arguments. Note |
|
434 | # The values (as strings) of all default arguments. Note | |
396 | # that these must be matched *in reverse* with the 'args' |
|
435 | # that these must be matched *in reverse* with the 'args' | |
397 | # list above, since the first positional args have no default |
|
436 | # list above, since the first positional args have no default | |
398 | # value at all. |
|
437 | # value at all. | |
399 | func_defaults : list |
|
438 | func_defaults : list, | |
400 | } |
|
439 | }, | |
401 |
|
440 | |||
402 | # For instances, provide the constructor signature (the definition of |
|
441 | # For instances, provide the constructor signature (the definition of | |
403 | # the __init__ method): |
|
442 | # the __init__ method): | |
@@ -487,6 +526,7 b' Message type: ``history_reply``::' | |||||
487 | # respectively. |
|
526 | # respectively. | |
488 | 'history' : dict, |
|
527 | 'history' : dict, | |
489 | } |
|
528 | } | |
|
529 | ||||
490 | Messages on the PUB/SUB socket |
|
530 | Messages on the PUB/SUB socket | |
491 | ============================== |
|
531 | ============================== | |
492 |
|
532 | |||
@@ -539,10 +579,10 b' Message type: ``pyout``::' | |||||
539 | # The data is typically the repr() of the object. |
|
579 | # The data is typically the repr() of the object. | |
540 | 'data' : str, |
|
580 | 'data' : str, | |
541 |
|
581 | |||
542 |
# The |
|
582 | # The counter for this execution is also provided so that clients can | |
543 |
# |
|
583 | # display it, since IPython automatically creates variables called _N (for | |
544 |
# |
|
584 | # prompt N). | |
545 | 'prompt_number' : int, |
|
585 | 'execution_count' : int, | |
546 | } |
|
586 | } | |
547 |
|
587 | |||
548 | Python errors |
|
588 | Python errors |
General Comments 0
You need to be logged in to leave comments.
Login now