Typo3 cache not used with globalVar typoscript condition - caching

I have a multi language Typo3 (7.6.22) setup which causes some caching problems. If I use the following TypoScript condition, only the first accessed language page gets cachhed.
[globalVar = LIT:0 < {$lib.sys_language_uid}]
lib.lang.home_action.value = http://{$lib.url.domain}{$lib.url.basePath}{$lib.language}.html
[global]
with $lib.sys_language_uid defined this way
[globalVar = GP:L > 0]
lib.sys_language_uid = 1
[global]
[globalVar = GP:L = 2]
lib.sys_language_uid = 2
[global]
...
I now wondering, what causes this problem and how I could solve this, without putting the condition inside my fluid templates.

I think the problem occurs as your conditions are very complicated to evaluate.
Caching in TYPO3 is done for each condition evaluation (true - false).
ATM I can't say whether conditions in the Constants part are enough to make up separate caches. and also unclear if the evaluation with (changing) constants [*] will create separate caches.
let's see what will happen with differnt values for URL parameter L:
&L=0 (or not set)
in constant part no condition is true, so lib.sys_language_uid does not get set at all.
So in setup we have:
[globalVar = LIT:0 < {$lib.sys_language_uid}]
and this is literally (0 < '{$lib.sys_language_uid}') as the constant is not defined. So it evaluates to TRUE.
&L=1
constants:
[globalVar = GP:L > 0]
lib.sys_language_uid = 1
[global]
this part is true and we have lib.sys_language_uid set to 1.
in setup we now have the condition
[globalVar = LIT:0 < 1]
which also evaluates to true.
&L=2
[globalVar = GP:L > 0]
lib.sys_language_uid = 1
[global]
[globalVar = GP:L = 2]
lib.sys_language_uid = 2
[global]
both parts are true and we have lib.sys_language_uid set to 2.
in setup we now have the condition
[globalVar = LIT:0 < 2]
which also evaluates to true.
&L=3 (or further values)
constants:
[globalVar = GP:L > 0]
lib.sys_language_uid = 1
[global]
only the first part is true and we have lib.sys_language_uid set to 1.
in setup we now have the condition
[globalVar = LIT:0 < 1]
which also evaluates to true.
This is the same condition as for &L=1 and this will use the same cache! BOOM!!
Result:
[*] changing constants is a bad concept!
use the evaluation of the URL-Parameter in the setup part of TS templates instead of crypt it in the constants part.

It is may the naming convention, but usually things with "lib." are defined in the setup section.
[globalVar = LIT:0 < {$lib.sys_language_uid}]
If it is the case and you defined it there, then it is a problem, because its value stays the same independent from the language.
The condition "LIT" can handle only constants.
{$lib.sys_language_uid} should be a constant.
BTW
If I have such a problem I always try to "print" the value of that TypoScript constant or cObject into the markup, like:
page.headerData.123456 = TEXT
page.headerData.123456 {
value = {$lib.sys_language_uid}
wrap = <test>|</test>
}

Related

Latex nested loop not displaying correctly

Hi I'm new to latex I use here the Algorithmic package to write my pseudo code the problem I faced is that 'some text' is displayed correctly under the second loop but the 'return' statement which needs to be outside the first for loop isn't showing correctly also it does not mark the end of each loop (the vertical tic is missing), the execution result is shown in the image:
\documentclass{article}
\usepackage[utf8,linesnumbered,ruled,vlined]{algorithm2e}
\usepackage {algpseudocode}
\usepackage{algorithmicx}
\usepackage{algcompatible}
\begin{document}
\begin{algorithm}
\ContinuedFloat
\caption{My algorithm}
\textbf{Input:} solution,bound, data\_matrix, vehicle\_capacity, demand\_data,k\_max,operations\_data, move\_type,tenure, max\_number\_of\_moves,max\_iter,non\_improvement\_maxiter,itermax,epsilon\\
\textbf{Output:} $best$ $solution$ \\[0.1in]
routes = extract routes from \textbf{solution}\\
oldfitness = fitness(\textbf{solution})\\
ls\_move\_type = inversion\\
best\_solution = routes\\[0.1in]
\For{0 \leq i \leq itermax}{
new\_routes = [ ]\\
desc = 'normal route'\\
\For{route \textbf{in} routes}{
n=length(route)\\
comb = int($\frac{n!}{(n-2)!}$)\\
\If{n \geq 4}{
tabu\_list\_tenure = $\frac{comb}{5}$\\
ls\_maxiteration = 50 \\
ls\_move\_type = 'inversion'\\
}
\If{3 \leq n \leq 4}{
tabu\_list_tenure = $\frac{comb}{4}$ \\
ls\_maxiteration = 25\\
ls\_move\_type = 'relocation'\\
}
\Else{
append \textbf{route} to \textbf{new\_routes}\\
desc = 'short route'\\
}\\[0.1in]
}
some action
}
return
\end{algorithm}
\end{document}
There is no point in wondering about the output as long as you get errors in your .log file. After an error, latex only recovers enough to syntax check the rest of the document, not necessarily producing sensible output.
Some of the most critical problems:
never ignore error messages!
utf8 isn't a valid option for the algorithm2e package
\ContinuedFloat is not defined by default. If you want to use it, you need a package which defines it. Maybe you want to use the caption package?
never ever use math mode to fake italic text as in $best$ $solution$. This completely messes up the kerning
some of your _ are not escaped
you mustn't use math commands like 0 \leq i \leq outside of math mode
use something like \Return to properly format it
using \\ for line breaks is already quite questionable, but using them two times in a row is simply an error.
because one can't say it often enough: never ignore error messages!
\documentclass{article}
\usepackage[
%utf8,
linesnumbered,ruled,vlined]{algorithm2e}
\usepackage {algpseudocode}
\usepackage{algorithmicx}
\usepackage{algcompatible}
\begin{document}
\begin{algorithm}
%\ContinuedFloat
\caption{My algorithm}
\textbf{Input:} solution,bound, data\_matrix, vehicle\_capacity, demand\_data,k\_max,operations\_data, move\_type,tenure, max\_number\_of\_moves,max\_iter,non\_improvement\_maxiter,itermax,epsilon
\textbf{Output:} \emph{best solution}
\medskip
routes = extract routes from \textbf{solution}
oldfitness = fitness(\textbf{solution})
ls\_move\_type = inversion
best\_solution = routes
\medskip
\For{$0 \leq i \leq$ itermax}{
new\_routes = [ ]
desc = 'normal route'
\For{route \textbf{in} routes}{
n=length(route)
comb = int($\frac{n!}{(n-2)!}$)
\If{$n \geq 4$}{
tabu\_list\_tenure = $\frac{comb}{5}$
ls\_maxiteration = 50
ls\_move\_type = 'inversion'
}
\If{$3 \leq n \leq 4$}{
tabu\_list\_tenure = $\frac{comb}{4}$
ls\_maxiteration = 25
ls\_move\_type = 'relocation'
}
\Else{
append \textbf{route} to \textbf{new\_routes}
desc = 'short route'
}
\medskip
}
some action
}
\Return
\end{algorithm}
\end{document}

Entry only needs num and plus validate below 8length[:8] not working

below Code is needs only num and below 8length is possible to only input number
two have purpose codes are confusion each other, therefore that is to have been made one module.
def validate(*args):
if not flowNum.get().isnumeric():
corrected = ''.join(filter(str.isnumeric, flowNum.get()))
flowNum.set(corrected)
#------------------------------------------------------------
value = limitNum.get()
if len(value) > 2:
limitNum.set(value[:8])
flowNum = tk.StringVar()
flowNum.trace('w', validate)
limitNum = StringVar()
limitNum.trace('w', limitnameFunc)
numinput = Entry(startframe, bd=0, textvariable=flowNum, width=6, font=(
'verdana', 18))

How to check if two or more conditions are met vs only one of them is true?

I'm using the following script with a software which reads a CheckBox using OMR and outputs the data to an XML file.
Is there a way I can change it to say if more than one box has been checked, the data output should be the first checked box in the list?
Hope this makes sense.
Any help would be appreciated.
Dim installer
q_a1= Metadata.Values("OMR_FRED_P2")
q_a2= Metadata.Values("OMR_JON_P2")
q_a3= Metadata.Values("OMR_MATT_P2")
q_a4= Metadata.Values("OMR_STEVE_P2")
If q_a1 = "Filled" Then
installer = "Fred"
End If
If q_a2 = "Filled" then
installer = "Jon"
End If
If q_a3 = "Filled" then
installer = "Matt"
End If
If q_a4 = "Filled" then
installer = "Steve"
End If
call Metadata.SetValues("CompleteBy",installer)
You could do something like this:
Dim a1Checked, a2Checked, a3Checked, a4Checked
Dim numberOfChecked
a1Checked = (q_a1 = "Filled")
a2Checked = (q_a2 = "Filled")
a3Checked = (q_a3 = "Filled")
a4Checked = (q_a4 = "Filled")
numberOfChecked = Abs(a1Checked + a2Checked + a3Checked + a4Checked)
If a1Checked Or numberOfChecked > 1 Then
installer = "Fred"
ElseIf a2Checked Then
installer = "Jon"
ElseIf a3Checked Then
installer = "Matt"
ElseIf a4Checked Then
installer = "Steve"
Else
' Decide what you want to do if none is checked.
End If
Call Metadata.SetValues("CompleteBy", installer)
In VBScript, the numeric value of a "boolean true" value is -1 and of the false value is 0.
The above code simply adds the values together. If two conditions are met, the total would be -2, then we use the Abs function to get the abstract value (i.e., returning 2 instead of -2). After that, you can easily check if two or more conditions are met by using numberofChecked > 1.

IF, invalid syntax error

if volt.isalpha() or res.isalpha() or amp.isalpha():
What did I do wrong here? I get an INVALID SYNTAX, I am using this for a calculator program I am making. It calculates voltage, resistance, and amperage. But thats the easy part, I am just trying to make it fool proof. I have 3 variables in the code (volt, amp, res) that are inputted by the user. I just wanna make sure that they don't type in anything stupid. Like letters for e.g. ...
try:
float(volt) >= 0 and float(res) >= 0 and float(amp) >= 0
print("")
print("You put a value for everything. You don't need the calculator.")
allowed = 0
if volt.isalpha() or res.isalpha() or amp.isalpha():
print("You typed in characters for one of the values, this calculator doesn't use letters.")
allowed = 0
def find_voltage(a,b): # V = I * R
voltage = a * b
return(voltage)`
You don't have an except block after try - it is required. Do something like:
try:
float(volt) >= 0 and float(res) >= 0 and float(amp) >= 0
print("")
print("You put a value for everything. You don't need the calculator.")
allowed = 0
except ValueError:
print("Oops, you messed up.")
Additionally, the line
float(volt) >= 0 and float(res) >= 0 and float(amp) >= 0
doesn't do anything. You'll need to assign it to a variable, then check the results of the variable - if True, do one thing, if False, do something else.

"undocumented" constants in Ruby/Rdoc

The following code snipped:
# ansi console color constants
COLOR_BLACK = 0
COLOR_RED = 1
COLOR_GREEN = 2
COLOR_YELLOW = 3
COLOR_BLUE = 4
COLOR_MAGENTA = 5
COLOR_CYAN = 6
COLOR_WHITE = 7
# functional color aliases
COLOR_WARN = COLOR_YELLOW
COLOR_ALERT = COLOR_RED
COLOR_CONFIRM = COLOR_GREEN
COLOR_NOTE = COLOR_BLUE
gets reported as 10 undocumented constants. Is there a way to "comment constants by groups" in RDoc? Documenting each constant separately would be slightly idiotic, and I don't want to omit them from doc.
I got the following answer per mail from a rdoc-developer, after i suggested implementing a :constlist: directive, that would get COLOR_BLACK = 0 simply documented as COLOR_BLACK(0):
I'll see what I can do, but I may not be able to add it to RDoc 4.0 as my time is limited.
I think I can make this work by putting the constants in a section (internally) using a separate directive that also marks them as documented for the purposes of the coverage report.

Resources