Add scope="session" to <set>; replace setenv with it
<set name="x" value="..." scope="session"> now writes x to the session file (any name, no @ prefix); values are still read with $[@x]. storeVariable passes the scope through instead of repeating the global/local/parent checks for each value source. Convert every <setenv> use on barant-site and qualityiron-site to a plain <set> plus a scope="session" <set>, which keeps same-request $[name] reads working, and remove setenv from both SESSIONCTL.tag copies (sessionctl is deprecated for session management). Document session variables and the set tag scopes in the Jet manual. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
867ace3cb3
commit
08462ca996
26 files changed
+108
-82
No files matched your search
@@ -1254,6 +1254,17 @@ namespace jet {
|
||||
(*global.sessionFile)[sessionName] = value;
|
||||
return;
|
||||
}
|
||||
if(coreutils::MString(scope).toLower() == "session") {
|
||||
// <set name="x" scope="session"> - the supported way to write a
|
||||
// session variable (sessionctl's <setenv> and the "@name" prefix
|
||||
// above are deprecated). Any name, no '@'. Copied into its own
|
||||
// MString for the same JString::locate() reason as above.
|
||||
coreutils::MString sessionName(variable);
|
||||
if(global.sessionFile == NULL)
|
||||
throw coreutils::Exception("scope=\"session\" requested but no session is active (missing sessiondir keyword, or cgi mode is off).");
|
||||
(*global.sessionFile)[sessionName] = value;
|
||||
return;
|
||||
}
|
||||
if((scope == "global") || (scope == ""))
|
||||
global.variables[variable] = value;
|
||||
else if(scope == "local") {
|
||||
@@ -1309,38 +1320,19 @@ namespace jet {
|
||||
}
|
||||
|
||||
void Tag::storeVariable(coreutils::ZString variable) {
|
||||
if(keywordDefined("expr")) {
|
||||
if(!keywordDefined("scope") || (resolveKeyword("scope").toLower() == "global"))
|
||||
assignVariable(variable, Operand(keywords["expr"], *this).string, "global");
|
||||
else if(resolveKeyword("scope").toLower() == "local")
|
||||
assignVariable(variable, Operand(keywords["expr"], *this).string, "local");
|
||||
else if(resolveKeyword("scope").toLower() == "parent")
|
||||
assignVariable(variable, Operand(keywords["expr"], *this).string, "parent");
|
||||
} else if(hasContainer) {
|
||||
coreutils::MString scope("global");
|
||||
if(keywordDefined("scope"))
|
||||
scope = resolveKeyword("scope").toLower();
|
||||
if(keywordDefined("expr"))
|
||||
assignVariable(variable, Operand(keywords["expr"], *this).string, scope);
|
||||
else if(hasContainer) {
|
||||
processContainer(container);
|
||||
if(evaluate) {
|
||||
if(!keywordDefined("scope") || (resolveKeyword("scope").toLower() == "global"))
|
||||
assignVariable(variable, out, "global");
|
||||
else if(resolveKeyword("scope").toLower() == "local")
|
||||
assignVariable(variable, out, "local");
|
||||
else if(resolveKeyword("scope").toLower() == "parent")
|
||||
assignVariable(variable, out, "parent");
|
||||
} else {
|
||||
if(!keywordDefined("scope") || (resolveKeyword("scope").toLower() == "global"))
|
||||
assignVariable(variable, container, "global");
|
||||
else if(resolveKeyword("scope").toLower() == "local")
|
||||
assignVariable(variable, container, "local");
|
||||
else if(resolveKeyword("scope").toLower() == "parent")
|
||||
assignVariable(variable, container, "parent");
|
||||
}
|
||||
} else {
|
||||
if(!keywordDefined("scope") || (resolveKeyword("scope").toLower() == "global"))
|
||||
assignVariable(variable, resolveKeyword("value"), "global");
|
||||
else if(resolveKeyword("scope").toLower() == "local")
|
||||
assignVariable(variable, resolveKeyword("value"), "local");
|
||||
else if(resolveKeyword("scope").toLower() == "parent")
|
||||
assignVariable(variable, resolveKeyword("value"), "parent");
|
||||
}
|
||||
if(evaluate)
|
||||
assignVariable(variable, out, scope);
|
||||
else
|
||||
assignVariable(variable, container, scope);
|
||||
} else
|
||||
assignVariable(variable, resolveKeyword("value"), scope);
|
||||
}
|
||||
|
||||
coreutils::MString Tag::processModifier(coreutils::MString &value, coreutils::MString &modifier) {
|
||||
|
||||
Binary file not shown.
+51
-5
@@ -95,9 +95,12 @@ specifying the scope of global.
|
||||
\item Keyword - within a tag's container we may access the keyword
|
||||
values specified on the containing tag.
|
||||
|
||||
\item Environment -
|
||||
\item Session - values stored in the session file with the set tag and
|
||||
a scope of session. They persist across requests from the same browser.
|
||||
|
||||
\item CGI Variables -
|
||||
\item Environment -
|
||||
|
||||
\item CGI Variables -
|
||||
|
||||
\end{itemize}
|
||||
|
||||
@@ -120,6 +123,32 @@ the container where they are defined. Some containers may not be
|
||||
capable of storing local variables (i.e. set tag) and are inheriting
|
||||
the local scope from their parent tag.
|
||||
|
||||
\section{Session Variables}
|
||||
|
||||
Session variables are stored in the session file for the current
|
||||
session and remain available to later requests from the same browser.
|
||||
Session control must be enabled (see Session Control).
|
||||
|
||||
A session variable is written with the set tag and a scope of
|
||||
session:
|
||||
|
||||
\begin{verbatim}
|
||||
<set name="_login_id" value="$[login_id]" scope="session">
|
||||
\end{verbatim}
|
||||
|
||||
The name can be any variable name. It does not need an @ prefix.
|
||||
Session variables are read with the \$[@name] syntax, for example
|
||||
\$[@\_login\_id].
|
||||
|
||||
Setting a session variable does not also set a global variable of
|
||||
the same name. When the same request needs to read the value as
|
||||
\$[name], set it with both scopes:
|
||||
|
||||
\begin{verbatim}
|
||||
<set name="_login_id" value="$[login_id]">
|
||||
<set name="_login_id" value="$[login_id]" scope="session">
|
||||
\end{verbatim}
|
||||
|
||||
\section{Keyword Variables}
|
||||
|
||||
Keyword variables are set when they are specified on a containing tag.
|
||||
@@ -299,8 +328,16 @@ into the directory named after the token. Captured session data will
|
||||
become available to future requests coming into the server and made
|
||||
available through the variable formats for the session.
|
||||
|
||||
The <set> tag will also have an additional scope value that can be
|
||||
used to store the value in the session. This is scope="session".
|
||||
Under APIServer, session control is enabled for a site by its
|
||||
sessionDir setting in the server configuration instead of the <jet>
|
||||
tag.
|
||||
|
||||
Use the <set> tag with scope="session" to store a value in the
|
||||
session, and \$[@name] to read it back (see Session Variables).
|
||||
|
||||
The session tags in SESSIONCTL.tag are deprecated for session
|
||||
management. Its setenv tag has been removed, and the startsession and
|
||||
endsession tags are no longer provided. Use scope="session" instead.
|
||||
|
||||
|
||||
|
||||
@@ -488,7 +525,16 @@ value
|
||||
|
||||
container
|
||||
|
||||
scope
|
||||
scope - where the variable is stored. The values are:
|
||||
|
||||
\begin{itemize}
|
||||
\item global - the default. Available to all logic for the rest of the
|
||||
request.
|
||||
\item local - available only within the container where it is set.
|
||||
\item parent - stored in the scope of the enclosing tag.
|
||||
\item session - stored in the session file and kept across requests.
|
||||
Requires session control. See Session Variables.
|
||||
\end{itemize}
|
||||
|
||||
\section{sql}
|
||||
|
||||
|
||||
@@ -113,12 +113,6 @@
|
||||
document.forms[0].requestSubmit();"> <CONTAINER> </BUTTON>
|
||||
</TAG>
|
||||
|
||||
<tag name="setenv" keywords="name">
|
||||
<eval name="_envvalue" scope="local"><container></eval>
|
||||
<set name="#[name]" value="#[_envvalue]">
|
||||
<set name="@#[name]" value="#[_envvalue]">
|
||||
</tag>
|
||||
|
||||
<tag name="clearenv" keywords="name">
|
||||
<set name="#[name]" value="">
|
||||
<set name="@#[name]" value="">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<page>
|
||||
<title>CRYSTAL</title>
|
||||
<contents>
|
||||
<setenv name="_menubar"></setenv>
|
||||
<set name="_menubar" value=""><set name="_menubar" value="" scope="session">
|
||||
<sectionframe title="Crystal - High Security Communications">
|
||||
|
||||
<p>Coming soon. High security communications apps for iPhone and
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
<set name="login_email" value="$[login_email]">
|
||||
<set name="login_type" value="$[.type]">
|
||||
<set name="login_uuid" value="$[.uuid]">
|
||||
<setenv name="_login_id">$[login_id]</setenv>
|
||||
<setenv name="_login_name">$[login_name]</setenv>
|
||||
<setenv name="_login_email">$[login_email]</setenv>
|
||||
<setenv name="_login_type">$[login_type]</setenv>
|
||||
<setenv name="_login_uuid">$[login_uuid]</setenv>
|
||||
<set name="_login_id" value="$[login_id]"><set name="_login_id" value="$[login_id]" scope="session">
|
||||
<set name="_login_name" value="$[login_name]"><set name="_login_name" value="$[login_name]" scope="session">
|
||||
<set name="_login_email" value="$[login_email]"><set name="_login_email" value="$[login_email]" scope="session">
|
||||
<set name="_login_type" value="$[login_type]"><set name="_login_type" value="$[login_type]" scope="session">
|
||||
<set name="_login_uuid" value="$[login_uuid]"><set name="_login_uuid" value="$[login_uuid]" scope="session">
|
||||
<sql>update users set last_login=now() where id=$[login_id]</sql>
|
||||
<sql>select group_concat(to_base64(host),':',to_base64(email),':',to_base64(password) order by id separator ';') as accounts_list,
|
||||
(select host from email_accounts where user_id=$[login_id] order by id limit 1) as first_host,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<page>
|
||||
<title>LOGIN</title>
|
||||
<contents>
|
||||
<setenv name="start">$[start:0]</setenv>
|
||||
<set name="start" value="$[start:0]"><set name="start" value="$[start:0]" scope="session">
|
||||
<sectionframe title="LOGIN">
|
||||
<p>Please enter your information below to login.</p>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<page>
|
||||
<title>BARANT Technology Group</title>
|
||||
<contents>
|
||||
<setenv name="_menubar"></setenv>
|
||||
<set name="_menubar" value=""><set name="_menubar" value="" scope="session">
|
||||
<div id="main-subpage">
|
||||
<if value1="$[SUBPAGE]" value2="" type="eq">
|
||||
<include file="main-overview.subpage">
|
||||
|
||||
@@ -52,7 +52,7 @@ Payment already processed.
|
||||
</sql>
|
||||
<sql>select last_insert_id() as invoice_id</sql>
|
||||
<set name="invoice_id" value="$[.invoice_id]">
|
||||
<setenv name="_invoice_id">$[invoice_id]</setenv>
|
||||
<set name="_invoice_id" value="$[invoice_id]"><set name="_invoice_id" value="$[invoice_id]" scope="session">
|
||||
<call pgm="/usr/bin/jq" arg1="-j" arg2=".payment.status" input="$[payment]" name="card_charged">
|
||||
<call pgm="/usr/bin/jq" arg1="-j" arg2=".payment.card_details.card.card_brand" input="$[payment]" name="card_brand">
|
||||
<call pgm="/usr/bin/jq" arg1="-j" arg2=".payment.card_details.card.last_4" input="$[payment]" name="last_4_digits">
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
audio.play();
|
||||
}
|
||||
</script>
|
||||
<setenv name="_menubar"></setenv>
|
||||
<set name="_menubar" value=""><set name="_menubar" value="" scope="session">
|
||||
<sectionframe title="Modular1 Patches">
|
||||
|
||||
<div style="width: 48%;">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<title>PROJECT MANAGER</title>
|
||||
<contents>
|
||||
<retain name="project_id">
|
||||
<setenv name="_menubar">projman.bar</setenv>
|
||||
<set name="_menubar" value="projman.bar"><set name="_menubar" value="projman.bar" scope="session">
|
||||
<sectionframe title="Project Manager">
|
||||
<p>An advanced project management methodology not unlike Agile but
|
||||
with a better definition towards software development and the release
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<process>
|
||||
<setenv name="_product_sku">$[sku]</setenv>
|
||||
<set name="_product_sku" value="$[sku]"><set name="_product_sku" value="$[sku]" scope="session">
|
||||
</process>
|
||||
@@ -6,7 +6,7 @@
|
||||
join users on projects.owner_id=users.id
|
||||
where projects.id=$[project_id]
|
||||
</sql>$[sqlerror]
|
||||
<setenv name="_project_id">$[project_id]</setenv>
|
||||
<setenv name="_project_title">$[projman.text]</setenv>
|
||||
<setenv name="_menubar">projman.bar</setenv>
|
||||
<set name="_project_id" value="$[project_id]"><set name="_project_id" value="$[project_id]" scope="session">
|
||||
<set name="_project_title" value="$[projman.text]"><set name="_project_title" value="$[projman.text]" scope="session">
|
||||
<set name="_menubar" value="projman.bar"><set name="_menubar" value="projman.bar" scope="session">
|
||||
</process>
|
||||
@@ -1,3 +1,3 @@
|
||||
<process>
|
||||
<setenv name="_request_id">$[request_id]</setenv>
|
||||
<set name="_request_id" value="$[request_id]"><set name="_request_id" value="$[request_id]" scope="session">
|
||||
</process>
|
||||
@@ -9,8 +9,8 @@
|
||||
join projects on requests.project_id=projects.id
|
||||
where tasks.id=$[task_id]
|
||||
</sql>
|
||||
<setenv name="_task_id">$[task_id]</setenv>
|
||||
<setenv name="_request_id">$[projman.request_id]</setenv>
|
||||
<setenv name="_project_id">$[projman.project_id]</setenv>
|
||||
<setenv name="_project_title">$[projman.title]</setenv>
|
||||
<set name="_task_id" value="$[task_id]"><set name="_task_id" value="$[task_id]" scope="session">
|
||||
<set name="_request_id" value="$[projman.request_id]"><set name="_request_id" value="$[projman.request_id]" scope="session">
|
||||
<set name="_project_id" value="$[projman.project_id]"><set name="_project_id" value="$[projman.project_id]" scope="session">
|
||||
<set name="_project_title" value="$[projman.title]"><set name="_project_title" value="$[projman.title]" scope="session">
|
||||
</process>
|
||||
@@ -1,7 +1,7 @@
|
||||
<page>
|
||||
<title>BARANT Technology Group</title>
|
||||
<contents>
|
||||
<setenv name="_menubar"></setenv>
|
||||
<set name="_menubar" value=""><set name="_menubar" value="" scope="session">
|
||||
<div id="services-subpage">
|
||||
<if value1="$[SUBPAGE]" value2="" type="eq">
|
||||
<include file="services-overview.subpage">
|
||||
|
||||
@@ -1 +1 @@
|
||||
<setenv name="_player_state">$[state]</setenv>
|
||||
<set name="_player_state" value="$[state]"><set name="_player_state" value="$[state]" scope="session">
|
||||
@@ -1 +1 @@
|
||||
<setenv name="_player_volume">$[volume]</setenv>
|
||||
<set name="_player_volume" value="$[volume]"><set name="_player_volume" value="$[volume]" scope="session">
|
||||
@@ -1,7 +1,7 @@
|
||||
<page>
|
||||
<title>Wordpress Plugins</title>
|
||||
<contents>
|
||||
<setenv name="_menubar"></setenv>
|
||||
<set name="_menubar" value=""><set name="_menubar" value="" scope="session">
|
||||
|
||||
<sectionframe title="BARANT Shopping Cart for WordPress">
|
||||
<div style="display: table; width: 100%;">
|
||||
|
||||
@@ -113,12 +113,6 @@
|
||||
document.forms[0].requestSubmit();"> <CONTAINER> </BUTTON>
|
||||
</TAG>
|
||||
|
||||
<tag name="setenv" keywords="name">
|
||||
<eval name="_envvalue" scope="local"><container></eval>
|
||||
<set name="#[name]" value="#[_envvalue]">
|
||||
<set name="@#[name]" value="#[_envvalue]">
|
||||
</tag>
|
||||
|
||||
<tag name="clearenv" keywords="name">
|
||||
<set name="#[name]" value="">
|
||||
<set name="@#[name]" value="">
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
<if value1="$[_session_id]" value2="" type="eq">
|
||||
<createsession>
|
||||
</if>
|
||||
<setenv name="_login_id">$[_login_id]</setenv>
|
||||
<setenv name="_login_name">$[_login_name]</setenv>
|
||||
<setenv name="_login_email">$[_login_email]</setenv>
|
||||
<set name="_login_id" value="$[_login_id]"><set name="_login_id" value="$[_login_id]" scope="session">
|
||||
<set name="_login_name" value="$[_login_name]"><set name="_login_name" value="$[_login_name]" scope="session">
|
||||
<set name="_login_email" value="$[_login_email]"><set name="_login_email" value="$[_login_email]" scope="session">
|
||||
<sql>update users set last_login=now() where id=$[_login_id]</sql>
|
||||
<setpage name="home">
|
||||
</ifrow>
|
||||
@@ -1,6 +1,6 @@
|
||||
<process>
|
||||
<setenv name="_login_id"></setenv>
|
||||
<setenv name="_login_email"></setenv>
|
||||
<setenv name="_login_name"></setenv>
|
||||
<set name="_login_id" value=""><set name="_login_id" value="" scope="session">
|
||||
<set name="_login_email" value=""><set name="_login_email" value="" scope="session">
|
||||
<set name="_login_name" value=""><set name="_login_name" value="" scope="session">
|
||||
<setpage name="login">
|
||||
</process>
|
||||
@@ -1,3 +1,3 @@
|
||||
<process>
|
||||
<setenv name="_selected_contractor_id">$[selected_contractor_id]</setenv>
|
||||
<set name="_selected_contractor_id" value="$[selected_contractor_id]"><set name="_selected_contractor_id" value="$[selected_contractor_id]" scope="session">
|
||||
</process>
|
||||
@@ -1,3 +1,3 @@
|
||||
<process>
|
||||
<setenv name="_selected_customer_id">$[selected_customer_id]</setenv>
|
||||
<set name="_selected_customer_id" value="$[selected_customer_id]"><set name="_selected_customer_id" value="$[selected_customer_id]" scope="session">
|
||||
</process>
|
||||
@@ -1,3 +1,3 @@
|
||||
<process>
|
||||
<setenv name="_selected_job_id">$[selected_job_id]</setenv>
|
||||
<set name="_selected_job_id" value="$[selected_job_id]"><set name="_selected_job_id" value="$[selected_job_id]" scope="session">
|
||||
</process>
|
||||
@@ -1,3 +1,3 @@
|
||||
<process>
|
||||
<setenv name="_selected_user_id">$[selected_user_id]</setenv>
|
||||
<set name="_selected_user_id" value="$[selected_user_id]"><set name="_selected_user_id" value="$[selected_user_id]" scope="session">
|
||||
</process>
|
||||
Reference in new issue
Block a user