Yaws Parameter pass between out/1

Casper <>
Thu Jun 9 05:37:11 CEST 2005


Thanks for your advice.

I later found the {bindings, [{Key, Value}]}, which does exactly what I

- Eranga

-----Original Message-----
From:  [mailto:] 
Sent: Wednesday, June 08, 2005 4:31 PM
To: Casper
Cc: ; 
Subject: Re: Yaws Parameter pass between out/1

On Wed, Jun 08, 2005 at 10:21:17AM +0600, Casper wrote:
> Hi All,
> In yaws, can I pass parameters between out/1 calls? 
> What I tried below doesn't work. I tried to use #arg.state to pass data
> first out/1 call to the second out/1. Please explain how to do it right.
> 	<erl>
> 		out(A) ->
> 			io:fwrite("State1: ~p~n", [A#arg.state]),
> 			{get_more, A#arg.cont, "Testing"}.
> 	</erl>
> 	<erl>
> 		out(A) ->
> 			io:fwrite("State2: ~p~n", [A#arg.state]),
> 			{html, "Funky Stuff"}.
> 	</erl>

There is no explicit support for this in Yaws.
It is however guaranteed that the two out/1 functions 
will execute inside the same process.

Thus, to share state between two out/1 functions
in the same .yaws file it's possible to use the process dictionary
to pass data.

To pass data between different out/1 functions in different
.yaws file, some external thing must be used, such as a
gen_server, an ets table or a mnesia table.

Also, your code above looks odd. To return the {get_more ...
from the first out/1 function and then have another out/1 function
later will be bad.
The {get_more ... construct is only used to handle large POSTs
where all data from the client isn't yet available.
Take a look at upload.yaws in the www directory in the src distribution
or at http://yaws.hyber.org/upload0.yaws to understand this.


Claes Wikstrom                        -- Caps lock is nowhere and
http://www.hyber.org                  -- everything is under control

More information about the erlang-questions mailing list