[interchange-docs] xmldocs - docelic modified 7 files
docs at icdevgroup.org
docs at icdevgroup.org
Tue Aug 15 16:22:02 EDT 2006
User: docelic
Date: 2006-08-15 20:22:02 GMT
Modified: . TODO
Modified: refs HouseKeeping MaxServers PreFork
Added: howtos category-based-vat
Added: check-for-errors-in-form-submission
Added: make-data-structure-modifiable
Log:
- slight adjustments to existing stuff
- 3 new howtos
Revision Changes Path
1.93 +3 -0 xmldocs/TODO
rev 1.93, prev_rev 1.92
Index: TODO
===================================================================
RCS file: /var/cvs/xmldocs/TODO,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -r1.92 -r1.93
--- TODO 12 Aug 2006 22:43:11 -0000 1.92
+++ TODO 15 Aug 2006 20:22:02 -0000 1.93
@@ -8,6 +8,9 @@
- that howto entries get automatic title if start with < in first line
- unit testing
- remove NEW from <meta>
+- In tags, make XSLT code print position number besides "Yes" word in
+ positional parameters for tags
+- add search box to guides/index.xml
Outstanding:
=======
1.1 xmldocs/howtos/category-based-vat
rev 1.1, prev_rev 1.0
Index: category-based-vat
===================================================================
Use Category-dependent Tax Rates
</para></question>
<answer><para>
Many european countries use product category-dependent tax rates.
The question is, how to implement this in &IC;.
</para><para>
A quick and dirty way is to write a &glos-usertag; for calculation
and include it in <database>salestax</database> database.
<programlisting><![CDATA[
UserTag vat-calc Order table field
UserTag vat-calc addAttr
UserTag vat-calc Routine <<EOR
sub {
my ($table, $field, $opt) = @_;
my $error = sub {
my $msg = shift;
Log($msg);
return undef;
};
my $tax = 0;
foreach my $item (@$Vend::Items) {
my $taxrate = tag_data($table, $field, $item->{code});
$tax += ($taxrate * $item->{quantity});
}
return $tax;
}
EOR
]]></programlisting>
(If you add the above in &ccf; instead of &gcf;, you will have to
make sure you reference the <database>products</database> database
before this code runs). <!-- exactly how to do this? -->
</para><para>
Create <filename>salestax.asc</filename>:
<programlisting>
default [vat-calc products tax]
UK [vat-calc products tax]
FR [vat-calc products tax]
US 0
</programlisting>
Modify &ccf;:
<programlisting>
SalesTax country
</programlisting>
At this point, tax rates would be taken from the
<database class='field'>tax</database> field in the
<database>products</database> database.
</para><para>
Finally, to retrieve category-dependent tax rate, you can specify:
<programlisting>
AutoModifier products:category
</programlisting>
in &ccf; and use <code>$item->{category}</code> (in &conf-CommonAdjust;
for example) as the key to lookup tax value rate.
<!-- Full working example todo -->
1.1 xmldocs/howtos/check-for-errors-in-form-submission
rev 1.1, prev_rev 1.0
Index: check-for-errors-in-form-submission
===================================================================
Check for Errors in Form Submission
</para></question>
<answer><para>
<!--
(Below is as of 4.03, the equivalent in 4.02 is
\[if type=explicit compare="[error all=1 keep=1]"] ... [/if].)
To check errors without clearing them, you can use the idiom:
> [if errors]
> <FONT SIZE="+1" COLOR=RED>
> There were errors in your form submission.
> </FONT>
> <BLOCKQUOTE>
> [error all=1 show_error=1 joiner="<BR>"]
> </BLOCKQUOTE>
> [/if]
-->
1.1 xmldocs/howtos/make-data-structure-modifiable
rev 1.1, prev_rev 1.0
Index: make-data-structure-modifiable
===================================================================
Make Perl Hash Seemingly Modifiable
</para></question>
<answer><para>
Sometimes you want to make a data structure modifiable, without having the
changes permanently override original values. To do so, we can use &PERL;'s
<classname>Tie::ShadowHash</classname> module.
</para><para>
This is an old trick, generally not needed any more since &glos-configuration;
directives already are modifiable per-page (usually through an
&conf-Autoload; routine). However, you might find it useful. Here's the
usertag:
<programlisting><![CDATA[
UserTag modifiable Order thing
UserTag modifiable Routine <<EOR
require Tie::ShadowHash;
sub {
my $thing = shift || 'Variable';
my $ref = $Vend::Cfg->{$thing};
return undef if ref($ref) ne 'HASH';
my %hash;
tie %hash, 'Tie::ShadowHash', $ref;
my $new = \%hash;
$Vend::Cfg->{$thing} = $new;
if($thing eq 'Variable') {
$::Variable = $Vend::Interpolate::Variable = $new;
}
return "$thing set to modifiable";
}
EOR
]]></programlisting>
Establish initial value in &ccf:
<programlisting>
Variable FOO bar
</programlisting>
And test with the following code:
<programlisting>
FOO=__FOO__<br>
FOO=[var FOO]<br>
[modifiable]<br>
Set...[calc] $Variable->{FOO} = 'hosed'; [/calc]<br>
FOO=[var FOO]
</programlisting>
The output should be the same on every page reload.
1.6 +2 -2 xmldocs/refs/HouseKeeping
rev 1.6, prev_rev 1.5
Index: HouseKeeping
===================================================================
RCS file: /var/cvs/xmldocs/refs/HouseKeeping,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- HouseKeeping 22 May 2005 10:21:28 -0000 1.5
+++ HouseKeeping 15 Aug 2006 20:22:02 -0000 1.6
@@ -11,9 +11,9 @@
__NAME__ description
-Specify time &glos-interval;s at which should the Interchange server
+Specify periodic time &glos-interval; at which the Interchange server should
<emphasis>wake up</emphasis> and
-look for user reconfiguration requests and hung search processes. On some
+look for user reconfiguration requests and hung processes. On some
systems, this wakeup is the only time the server will terminate in response
to a stop command.
__END__
1.5 +0 -7 xmldocs/refs/MaxServers
rev 1.5, prev_rev 1.4
Index: MaxServers
===================================================================
RCS file: /var/cvs/xmldocs/refs/MaxServers,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MaxServers 4 May 2006 21:16:33 -0000 1.4
+++ MaxServers 15 Aug 2006 20:22:02 -0000 1.5
@@ -25,13 +25,6 @@
__END__
__NAME__ notes
-The directive is only used when &IC; is in <literal>PreFork</literal>
-&glos-ic-run-mode;.
-__END__
-
-
-__NAME__ missing
-Is this only in PreFork? if not, fix Notes section.
__END__
1.2 +1 -1 xmldocs/refs/PreFork
rev 1.2, prev_rev 1.1
Index: PreFork
===================================================================
RCS file: /var/cvs/xmldocs/refs/PreFork,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PreFork 20 Feb 2005 00:59:50 -0000 1.1
+++ PreFork 15 Aug 2006 20:22:02 -0000 1.2
@@ -18,7 +18,7 @@
__NAME__ description
For each new client connection, &IC; must spawn a new process that will
handle communication with the client.
-By using &conf-PreFork; it is possible to <emphasis>pre-fork</emphasis>
+By using &conf-PreFork;, it is possible to <emphasis>pre-fork</emphasis>
(or in other words, "start ahead of time") some number of &IC; servers
that will be ready to serve client requests immediately as they come in.
</para><para>
More information about the docs
mailing list