ข้ามไปเนื้อหา

ผลต่างระหว่างรุ่นของ "CuneiForm"

เพิ่มขึ้น 1,146 ไบต์ ,  15 เมษายน 2567
บรรทัดที่ 610: บรรทัดที่ 610:
#* If yes, the invoked instacalc is dumped.
#* If yes, the invoked instacalc is dumped.
# Once this point is reached, the invoked instacalc is processed.
# Once this point is reached, the invoked instacalc is processed.
==== Instacalc Route Template ====
Although instacalc is a form-based procedure, a very similar and related procedure is also presented in [[CuneiTable]], specifically when a column in the table is not presented in the database but is calculated on the fly before being sent over to the client-side. Thus, it is advised that an instacalc route be written with such 'internal calls' in mind.
Below is the model of a typical instacalc route:
<syntaxhighlight lang="python" line="1">
@<blueprint>.route('<instacalc_path>', methods=['POST'])
@login_required # Optional
def <function_name>(internal_args=None):
    # 'internal_args' is given as a dict when instacalc is internally called.
    if internal_args is None:
        identifiers = json.loads(request.form.get('identifier'))
        <input0> = identifiers['<input0_key>']
        <input1> = identifiers['<input1_key>']
        ...
    else:
        <input0> = internal_args.get('<input0_key>')
        <input1> = internal_args.get('<input1_key>')
        ...
    # Calculation block
    ...
    ...
    return {'<output0_key>':<output0>, '<output1_key>':<output1>, ...}
</syntaxhighlight>


=== Navigation & Focusing ===
=== Navigation & Focusing ===