think async

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

think async

andre hopkins
hi Lassoers

am trying to get async to work
  i have a site where you can email an entire book in the body of an
email.
the problem is the field for the book is so big that it takes a while
for the return page to load. so it was suggested that i try async so
that return page can load quickly.

so you can't get variables to work with async..? so i tried
action_param, which didnt seem to work.

so how can you pass a value from the previous page...? i also need to
pass the value into the include for the email body (to pull the right
book from the db)

tia,
Andre

EXAMPLE 1 -- this simple test worked and sent an email

[if: (action_param:'todo') == 'emailbooktoself']
<?LassoScript
Define_Tag: 'SendBook', -Namespace='Ex_', -Async;
Email_Send: -Host='mail.riapress.com',
-To='[hidden email]',
-From='[hidden email]',
-Subject='Your book from Riapress.com',
-Body='This is a test';
/Define_Tag;
?>
[Ex_SendBook]
[/if]

EXAMPLE 2 -- trying to pass with action_param didn't work

[if: (action_param:'todo') == 'emailbooktoself']
<?LassoScript
Define_Tag: 'SendBook', -Namespace='Ex_', -Async;
Email_Send: -Host='mail.riapress.com',
-To=(action_param:'emailto'),
-From='[hidden email]',
-Subject='Your book from Riapress.com',
-Body=(Include: 'email_book.lasso');
/Define_Tag;
?>
[Ex_SendBook]
[/if]




--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: think async

Adam Randall
Look at the -Required and -Optional parameters of the Define_Tag.  
That's how you send data into it, especially if you are specifying -
Async.

Adam.

On Jun 8, 2005, at 7:19 PM, andre hopkins wrote:

> hi Lassoers
>
> am trying to get async to work
>  i have a site where you can email an entire book in the body of an  
> email.
> the problem is the field for the book is so big that it takes a  
> while for the return page to load. so it was suggested that i try  
> async so that return page can load quickly.
>
> so you can't get variables to work with async..? so i tried  
> action_param, which didnt seem to work.
>
> so how can you pass a value from the previous page...? i also need  
> to pass the value into the include for the email body (to pull the  
> right book from the db)
>
> tia,
> Andre
>
> EXAMPLE 1 -- this simple test worked and sent an email
>
> [if: (action_param:'todo') == 'emailbooktoself']
> <?LassoScript
> Define_Tag: 'SendBook', -Namespace='Ex_', -Async;
> Email_Send: -Host='mail.riapress.com',
> -To='[hidden email]',
> -From='[hidden email]',
> -Subject='Your book from Riapress.com',
> -Body='This is a test';
> /Define_Tag;
> ?>
> [Ex_SendBook]
> [/if]
>
> EXAMPLE 2 -- trying to pass with action_param didn't work
>
> [if: (action_param:'todo') == 'emailbooktoself']
> <?LassoScript
> Define_Tag: 'SendBook', -Namespace='Ex_', -Async;
> Email_Send: -Host='mail.riapress.com',
> -To=(action_param:'emailto'),
> -From='[hidden email]',
> -Subject='Your book from Riapress.com',
> -Body=(Include: 'email_book.lasso');
> /Define_Tag;
> ?>
> [Ex_SendBook]
> [/if]
>
>
>
>
> --
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription:  http://www.listsearch.com/ 
> lassotalk.lasso?manage
>


--
Adam Randall <[hidden email]>
http://www.omnipilot.com/
(954) 874-3100
AIM/iChat: adamomni


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: think async

Greg Willits
In reply to this post by andre hopkins
On Jun 8, 2005, at 4:19 PM, andre hopkins wrote:

> am trying to get async to work
>  i have a site where you can email an entire book in the body of an
> email.
> the problem is the field for the book is so big that it takes a while
> for the return page to load. so it was suggested that i try async so
> that return page can load quickly.
>
> so you can't get variables to work with async..? so i tried
> action_param, which didnt seem to work.
>
> so how can you pass a value from the previous page...? i also need to
> pass the value into the include for the email body (to pull the right
> book from the db)

Async ctags don't have access to page data (vars, action_params, etc).
You have to either store the data in a global, or pass it as a
parameter to the ctag itself:


define_tag: 'myAsync',
        -async,
        -required = 'stufftosend'
        -required = 'mailTo',
        -required = 'mailFrom';

        email_send:....
                -to = #mailto,
                -from = #mailfrom,
                -body = #stuffToSend
                ....

/define_tag;


Then you call the tag like so:

        myAsync:
                -to = $yourAddress,
                -from = $myAddress,
                -body = $giantVarForBookStuff;


That's not complete code, but it should help you see the steps.

-- greg willits


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: think async

Fletcher Sandbeck
In reply to this post by andre hopkins
On 6/8/05 at 4:19 PM by [hidden email] (andre hopkins):

>hi Lassoers
>
>am trying to get async to work
>  i have a site where you can email an entire book in the body of an
>email.
>the problem is the field for the book is so big that it takes a while
>for the return page to load. so it was suggested that i try async so
>that return page can load quickly.
>
>so you can't get variables to work with async..? so i tried
>action_param, which didnt seem to work.
>
>so how can you pass a value from the previous page...? i also need to
>pass the value into the include for the email body (to pull the right
>book from the db)
>
>tia,
>Andre
>
>EXAMPLE 1 -- this simple test worked and sent an email
>
>[if: (action_param:'todo') == 'emailbooktoself']
><?LassoScript
>Define_Tag: 'SendBook', -Namespace='Ex_', -Async;
>Email_Send: -Host='mail.riapress.com',
>-To='[hidden email]',
>-From='[hidden email]',
>-Subject='Your book from Riapress.com',
>-Body='This is a test';
>/Define_Tag;
>?>
>[Ex_SendBook]
>[/if]
>
>EXAMPLE 2 -- trying to pass with action_param didn't work
>
>[if: (action_param:'todo') == 'emailbooktoself']
><?LassoScript
>Define_Tag: 'SendBook', -Namespace='Ex_', -Async;
>Email_Send: -Host='mail.riapress.com',
>-To=(action_param:'emailto'),
>-From='[hidden email]',
>-Subject='Your book from Riapress.com',
>-Body=(Include: 'email_book.lasso');
>/Define_Tag;
>?>
>[Ex_SendBook]
>[/if]

Rather than trying to create a new tag, you can just call the [Email_Send] tag itself asynchrnously.  First, store the parameters that you want to use to call the tag in an array, then call the tag using \Tag_Name to get a reference to the tag and the [Tag->AsAsync] tag to call it asynchronously.

It's easier than it sounds :)

[var: 'params' = (array:
        -Host='mail.riapress.com',
        -To=(action_param:'emailto'),
        -From='[hidden email]',
        -Subject='Your book from Riapress.com',
        -Body=(Include: 'email_book.lasso')
)]
[\email_send->(asasync: -params=$params)]

There are two problems with your second example. First is that the [Action_Param] isn't going to be available when the tag is running asynchronously.  Instead, you'd want to define a parameter for yoru [Ex_SendBook] tag and then reference this parameter within the tag.   Second, the [Include] isn't going to work within an asynchronous tag.  This would also need to be passed as a parameter.

The method I suggest gets around both these problems by first assembling the parameter array within the context of the current page where both [Action_Param] and [Include] work normally, then passing this array into the asynchronous tag.

One caveat, the method I suggest won't work if you are including attachments with the email.

[fletcher]
--
Fletcher Sandbeck                         [hidden email]
Lasso Product Specialist              [hidden email]
OmniPilot Software, Inc.                http://www.omnipilot.com

--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: think async

Göran Törnquist
In reply to this post by andre hopkins
Thanks Fletcher for pointing out a method of
invocation that I had forgotten about!

While at the subject, how much penalty do you pay
for an async calll in terms of additional memory,
execution overhead etc?

/Göran

At 16.46 -0700 05-06-08, Fletcher Sandbeck wrote:

>Rather than trying to create a new tag, you can
>just call the [Email_Send] tag itself
>asynchrnously.  First, store the parameters that
>you want to use to call the tag in an array,
>then call the tag using \Tag_Name to get a
>reference to the tag and the [Tag->AsAsync] tag
>to call it asynchronously.
>
>It's easier than it sounds :)
>
>[var: 'params' = (array:
> -Host='mail.riapress.com',
> -To=(action_param:'emailto'),
> -From='[hidden email]',
> -Subject='Your book from Riapress.com',
> -Body=(Include: 'email_book.lasso')
>)]
>[\email_send->(asasync: -params=$params)]
>

--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: think async

Fletcher Sandbeck
In reply to this post by andre hopkins
On 6/9/05 at 2:11 AM by [hidden email] (Göran   Törnquist):

>Thanks Fletcher for pointing out a method of
>invocation that I had forgotten about!
>
>While at the subject, how much penalty do you pay
>for an async calll in terms of additional memory,
>execution overhead etc?

I would expect an async call to incur somewhat less overhead than a page load.

[fletcher]
--
Fletcher Sandbeck                         [hidden email]
Lasso Product Specialist              [hidden email]
OmniPilot Software, Inc.                http://www.omnipilot.com

--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: think async

andre hopkins
In reply to this post by andre hopkins
>
> Rather than trying to create a new tag, you can just call the
> [Email_Send] tag itself asynchrnously.  First, store the parameters
> that you want to use to call the tag in an array, then call the tag
> using \Tag_Name to get a reference to the tag and the [Tag->AsAsync]
> tag to call it asynchronously.
>
> It's easier than it sounds :)

i appreciate the hand holding

<g>

Hey this works great !! thanks so much, this is a lot simpler as well.

Andre



>
> [var: 'params' = (array:
> -Host='mail.riapress.com',
> -To=(action_param:'emailto'),
> -From='[hidden email]',
> -Subject='Your book from Riapress.com',
> -Body=(Include: 'email_book.lasso')
> )]
> [\email_send->(asasync: -params=$params)]
>
> There are two problems with your second example. First is that the
> [Action_Param] isn't going to be available when the tag is running
> asynchronously.  Instead, you'd want to define a parameter for yoru
> [Ex_SendBook] tag and then reference this parameter within the tag.  
> Second, the [Include] isn't going to work within an asynchronous tag.  
> This would also need to be passed as a parameter.
>
> The method I suggest gets around both these problems by first
> assembling the parameter array within the context of the current page
> where both [Action_Param] and [Include] work normally, then passing
> this array into the asynchronous tag.
>
> One caveat, the method I suggest won't work if you are including
> attachments with the email.
>
> [fletcher]
> --
> Fletcher Sandbeck                         [hidden email]
> Lasso Product Specialist              [hidden email]
> OmniPilot Software, Inc.                http://www.omnipilot.com
>
> --
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription:
> http://www.listsearch.com/lassotalk.lasso?manage
>


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: think async

Göran Törnquist
In reply to this post by andre hopkins
Meaning, it's almost equivalent to another http
request minus the Apache-Lasso communication?

I am looking for ways to optimize a CMS solution
and some of the processing might be put in async
calls if the performance hit isn't too high.

/Göran

>On 6/9/05 at 2:11 AM by [hidden email] (Göran   Törnquist):
>
>>Thanks Fletcher for pointing out a method of
>  >invocation that I had forgotten about!
>  >
>  >While at the subject, how much penalty do you pay
>  >for an async calll in terms of additional memory,
>  >execution overhead etc?
>
>I would expect an async call to incur somewhat less overhead than a page load.
>
>[fletcher]
>--
>Fletcher Sandbeck                         [hidden email]
>Lasso Product Specialist              [hidden email]
>OmniPilot Software, Inc.                http://www.omnipilot.com
>
>--
>------------------------------
>Lasso Support: http://support.omnipilot.com/
>Search the list archives: http://www.listsearch.com/lassotalk.lasso
>Manage your list subscription:
>http://www.listsearch.com/lassotalk.lasso?manage


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: think async

Fletcher Sandbeck
In reply to this post by andre hopkins
On 6/9/05 at 2:38 AM by [hidden email] (Göran   Törnquist):

>Meaning, it's almost equivalent to another http
>request minus the Apache-Lasso communication?

That's my understanding :)  The async call runs essentially as a new page execution, but without some of the overhead of dealing with URL and form parameters, collecting output, etc.

>I am looking for ways to optimize a CMS solution
>and some of the processing might be put in async
>calls if the performance hit isn't too high.

This could definitely be a good strategy for increasing the responsiveness of the site.  But, it won't really ease the burden on the back-end database since all the actions will need to be executed eventually.

[fletcher]
--
Fletcher Sandbeck                         [hidden email]
Lasso Product Specialist              [hidden email]
OmniPilot Software, Inc.                http://www.omnipilot.com

--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage