Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
cookbooks:transformations:devel [2009/10/21 16:33] 87.95.89.72 |
cookbooks:transformations:devel [2011/11/09 12:34] (current) 193.146.38.124 old revision restored |
||
---|---|---|---|
Line 66: | Line 66: | ||
< | < | ||
- | xlog("MD4 over From username: $(fU{s.md5})" | + | xlog("md5 over From username: $(fU{s.md5})" |
</ | </ | ||
+ | |||
==== {s.substr, | ==== {s.substr, | ||
Line 139: | Line 140: | ||
Return string with upper case ASCII letters. | Return string with upper case ASCII letters. | ||
+ | ==== {s.strip, | ||
+ | |||
+ | Return string after removing starting ' | ||
+ | |||
+ | Example: | ||
+ | |||
+ | <code c> | ||
+ | $var(x) = " | ||
+ | $var(y) = $(var(x){s.strip, | ||
+ | </ | ||
+ | |||
+ | ==== {s.striptail, | ||
+ | |||
+ | Return string after removing ending ' | ||
+ | |||
+ | ==== {s.prefixes[, | ||
+ | |||
+ | Return series of comma separated prefixes of the pv. Parameter ' | ||
+ | |||
+ | Example: | ||
+ | <code c> | ||
+ | $var(x) = " | ||
+ | $(var(x){s.prefixes}) => 1, | ||
+ | $(var(x){s.prefixes, | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== {s.prefixes.quoted[, | ||
+ | |||
+ | Return series of comma separated quoted prefixes of the pv. Parameter ' | ||
+ | |||
+ | Example: | ||
+ | <code c> | ||
+ | $var(x) = " | ||
+ | $(var(x){s.prefixes.quoted} => ' | ||
+ | $(var(x){s.prefixes.quoted, | ||
+ | </ | ||
===== URI Transformations ===== | ===== URI Transformations ===== | ||
Line 318: | Line 356: | ||
<hi # | <hi # | ||
- | Access parts of a ToBody-like structure. | ||
- | |||
==== {re.subst, | ==== {re.subst, | ||
Line 325: | Line 361: | ||
Perform Perl-like substitutions on string value pseudo-variables. | Perform Perl-like substitutions on string value pseudo-variables. | ||
- | < | + | < |
# Assign Request-URI user to PV | # Assign Request-URI user to PV | ||
$var(user) = $(ru{re.subst,/ | $var(user) = $(ru{re.subst,/ | ||
</ | </ | ||
- | < | + | < |
# Assign Request-URI user to PV, where every ' | # Assign Request-URI user to PV, where every ' | ||
- | $var(user) = $(rU{re.subst,/ | + | $var(user) = $(rU{re.subst,/ |
</ | </ | ||
+ | |||
+ | The prototype is: | ||
+ | |||
+ | <code c> | ||
+ | {re.subst,/ | ||
+ | </ | ||
+ | |||
+ | * match_expression - Posix regular expression | ||
+ | * replacement_expression - substitution expression with back references to matched tokes: \1, \2, ..., \9 | ||
+ | * flags: | ||
+ | * i - match ignore case | ||
+ | * s - match within multi-lines strings | ||
+ | * g - replace all matches | ||
+ | |||
+ | ===== SQL Transformations ===== | ||
+ | |||
+ | <hi # | ||
+ | |||
+ | ==== {sql.val} ==== | ||
+ | |||
+ | This transformation outputs valid SQL values for various PV values: | ||
+ | * < | ||
+ | * integers are output as integers | ||
+ | * everything else is output as quoted and escaped string | ||
+ | | ||
+ | <code c> | ||
+ | $var(null) = $null; | ||
+ | $avp(null) = $null; | ||
+ | $avp(str) = " | ||
+ | $avp(nr) = 12345; | ||
+ | $avp(strnr) = " | ||
+ | | ||
+ | xlog(" | ||
+ | xlog(" | ||
+ | xlog(" | ||
+ | xlog(" | ||
+ | xlog(" | ||
+ | xlog(" | ||
+ | |||
+ | Output: | ||
+ | $rm = ACK = ' | ||
+ | $var(null) = 0 = 0 | ||
+ | $avp(null) = < | ||
+ | $avp(str) = String with \ illegal \characters = ' | ||
+ | $avp(nr) = 12345 = 12345 | ||
+ | $avp(strnr) = 12345 = ' | ||
+ | </ | ||
+ | |||
+ | ==== {sql.val.int} ==== | ||
+ | |||
+ | Like sql.val, but output number 0 for null values. | ||
+ | |||
+ | ==== {sql.val.str} ==== | ||
+ | |||
+ | Like sql.val, but output string '' | ||
===== Examples ===== | ===== Examples ===== |