[docs] xmldocs - docelic modified 5 files

docs at icdevgroup.org docs at icdevgroup.org
Sun Sep 26 15:51:44 EDT 2004


User:      docelic
Date:      2004-09-26 19:51:44 GMT
Added:     howtos   custom-sendmail-routine quantity-in-basket
Removed:   howtos   custom-sendmail-routine.xml howtos.xml
Removed:            quantity-in-basket.xml
Log:
- s/\.xml$// not to clash with standard naming used elsewhere

Revision  Changes    Path
1.1                  xmldocs/howtos/custom-sendmail-routine


rev 1.1, prev_rev 1.0
Index: custom-sendmail-routine
===================================================================
<chapter id="DefineCustomSendmailRoutine">

	<chapterinfo>
		<title>Define Custom Sendmail Routine</title>
		<titleabbrev>customsendmail</titleabbrev>

		<keywordset>
			<keyword>custom</keyword>
			<keyword>send</keyword>
			<keyword>mail</keyword>
			<keyword>routine</keyword>
			<keyword>delay</keyword>
		</keywordset>

		<authorgroup>
			<author>
				<firstname>Mike</firstname>
				<surname>Heins</surname>
				<affiliation>
					<email>mheins at perusion.net</email>
				</affiliation>
			</author>
		</authorgroup>


	</chapterinfo>

	<sect1 id='introduction'>
		<title>Introduction</title>
		<para>
		Someone <ulink url="http://www.icdevgroup.org/pipermail/interchange-users/2004-July/039811.html">was wondering</ulink> how to optimize the order processing on a busy site. It was observed that about once in every ten times, the <filename>etc/mail_receipt</filename> takes a few <emphasis>extra</emphasis> seconds before it's mailed out.
		</para>
		<para>
		The delay occured because in the code used, the <option>SendMailProgram</option> ran in foreground so the ordering process "stalled" for a few seconds (or at least that's how the average customer saw it). The critical section was reduced to:
		</para>

		<screen>
<![CDATA[
[email to="[scratch to_email], __MAIL_RECEIPT_CC__"
       subject="__COMPANY__ Order #[value mv_order_number]: [scratch subject_end]"
       from=|"__COMPANY__ Order Confirmation" <orders at company.com>| ]

... email contents ...

[/email]
]]>
		</screen>
	</sect1>

	<sect1 id='solution'>
		<title>Solution</title>
		<para>
		To eliminate this "delay", you could use a custom script that accepts the message on standard input (STDIN), and then calls <application>Sendmail</application> in the background.
		</para> <para>
		Save the script with the following contents to <filename>/usr/local/bin/sendmail-bg</filename>:
		</para>

		<programlisting>
<![CDATA[
#!/usr/bin/perl

#use strict;
#use warnings;
use File::Temp;

my $basedir = '/tmp/sendmail';
my $sendmail = '/usr/sbin/sendmail -t';
umask 2;

mkdir $basedir unless -d $basedir;
my $tmp = File::Temp->new( DIR => $basedir );
my $tmpnam = $tmp->filename;

open OUT, "> $tmpnam" or die "Cannot create $tmpnam: $!\n";
my $cmdline = join " ", $sendmail, '<', $tmpnam, '&';
while(<>) { print OUT $_; }
close OUT;

system($cmdline);

if($?) { die "Failed to fork sendmail: $!\n" }

]]>
		</programlisting>

	<para>
	And of course, don't forget to add/modify the <option>SendMailProgram</option> directive:
	</para>

	<programlisting>
SendMailProgram /usr/local/bin/sendmail-bg
	</programlisting>

	</sect1>

</chapter>




1.1                  xmldocs/howtos/quantity-in-basket


rev 1.1, prev_rev 1.0
Index: quantity-in-basket
===================================================================
<chapter id="Provide Item Quantity Fields in the Basket Page">

	<chapterinfo>
		<title>Provide Item Quantity Fields in the Basket Page</title>
		<titleabbrev>quantityfields</titleabbrev>

		<keywordset>
			<keyword>quantity</keyword>
			<keyword>checkout</keyword>
			<keyword>basket</keyword>
			<keyword>item</keyword>
			<keyword>recalculate</keyword>
			<keyword>add</keyword>
			<keyword>remove</keyword>
			<keyword>total</keyword>
			<keyword>number</keyword>
			<keyword>client</keyword>
			<keyword>form</keyword>
			<keyword>data</keyword>
			<keyword>return</keyword>
			<keyword>todo</keyword>
			<keyword>action</keyword>
			<keyword>post</keyword>
		</keywordset>

		<authorgroup>
			<author>
				<firstname>Davor</firstname>
				<surname>Ocelic</surname>
				<affiliation>
					<email>docelic at icdevgroup.org</email>
				</affiliation>
			</author>
		</authorgroup>


	</chapterinfo>

	<sect1 id='introduction'>
		<title>Introduction</title>
		<para>
		On your Interchange pages, you must provide some kind of a HTML form
		if you want to receive any data from the client. We will use the 
		<filename>pages/ord/basket.html</filename> page from the
		<!-- XXX LINK IT -->
		tutorial catalog to demonstrate this.
		</para>
		<para>
		This particular HOWTO deals with the <emphasis>Item Quantity</emphasis>
		field, but you can take it as a general Interchange HTML form submission
		example. I hope you would recognize the enormous power of the
		Interchange server running behind the scene.
		</para>
		<para>
		The page we're starting with only displays a table of the products found
		in your shopping cart.
		The <database class='field'>Quantity</database> field is provided but
		the only way to increase the number is to click the appropriate 
		<guibutton>Order Now</guibutton> button multiple times. Reducing the
		quantity
		is not supported. Just to remind ourselves, here's how this initial
		page looks like:
		</para>
		<screen>
<xi:include parse='text' href='../files/tutorial-phase5/pages/ord/basket.html'/>
		</screen>
	</sect1>

	<sect1 id='solution'>
		<title>Solution</title>
		<para>
		What we need to do is:
		<itemizedlist>
			<listitem><para>
			Create an HTML form which is neccesary to submit any client information
			back to Interchange:<sbr/>
			<code><![CDATA[<form method='post' action='[process]'>]]></code>
			</para></listitem>
			<listitem><para>
			Replace the <database class='field'>Quantity</database> label 
			(<code>[item-quantity]</code>) with
			an HTML text field where quantity can be edited:<sbr/>
			<code><![CDATA[<input type='text' size='2' name='[quantity-name]' value='[item-quantity]'/>]]></code>
			</para>
			<para>
			What we have introduced here is the <tag>quantity-name</tag> tag.
			Interchange
			will expand it to the appropriate field name for each item in the
			cart (<literal>quantity0</literal>, <literal>quantity1</literal>,
			<literal>quantity2</literal>, ...). This all happens automatically and
			you have nothing to worry about.
			</para></listitem>
			<listitem><para>
			Provide the submit button that triggers an action and sends information
			back to Interchange:<sbr/>
			<screen><![CDATA[
[button text='Recalculate']
  mv_todo=refresh
[/button]
			]]>
			</screen>
			</para></listitem>
			<listitem><para>
			Close the HTML form with <code><![CDATA[</form>]]></code>.
			</para></listitem>
		</itemizedlist>
		</para>

		<para>
		Here's a copy of the finished <filename>pages/ord/basket.html</filename>.
		</para>

		<screen>
<xi:include parse='text' href='../files/various/tut-phase5-basket+quantity.html'/>
		</screen>

		<para>
		Test the <filename>ord/basket</filename> page in your browser. Try
		adjusting the quantity and pressing <guibutton>Recalculate</guibutton>.
		Note that setting <database class='field'>Quantity</database> to 
		<literal>0</literal> effectively removes the item from your shopping
		cart.
		</para>

		<para>
		Have a great time and enjoy hacking Interchange :-)
		</para>
	</sect1>

</chapter>









More information about the docs mailing list