added REQUEST.execution_variables ... to provide a solution to store data during request execution

could be used for SESSION, or any "shared" data inside the same Request
This commit is contained in:
Jocelyn Fiat
2011-12-18 12:57:24 +01:00
parent 6b50ab8c55
commit 83346c92a7
5 changed files with 119 additions and 0 deletions

View File

@@ -38,6 +38,11 @@ feature -- Visitor
process_iterable_of_value (v)
end
process_any (v: WSF_ANY)
do
end
;note
copyright: "2011-2011, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -25,6 +25,10 @@ feature -- Visitor
do
end
process_any (v: WSF_ANY)
do
end
;note
copyright: "2011-2011, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -35,6 +35,12 @@ feature -- Visitor
deferred
end
process_any (v: WSF_ANY)
require
v_attached: v /= Void
deferred
end
;note
copyright: "2011-2011, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -0,0 +1,65 @@
note
description: "Summary description for {WSF_ANY}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_ANY
inherit
WSF_VALUE
create
make
feature {NONE} -- Initialization
make (a_name: READABLE_STRING_8; a_value: like item)
do
name := url_decoded_string (a_name)
item := a_value
end
feature -- Access
name: READABLE_STRING_32
item: detachable ANY
feature -- Status report
is_string: BOOLEAN = False
-- Is Current as a WSF_STRING representation?
feature -- Query
string_representation: STRING_32
-- String representation of Current
-- if possible
do
if attached item as i then
Result := i.generating_type
else
Result := "Void"
end
end
feature -- Visitor
process (vis: WSF_VALUE_VISITOR)
do
vis.process_any (Current)
end
note
copyright: "2011-2011, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -47,6 +47,10 @@ feature {NONE} -- Initialization
raw_post_data_recorded := True
create {STRING_32} empty_string.make_empty
create execution_variables_table.make (0)
execution_variables_table.compare_objects
execution_variables := execution_variables_table
initialize
analyze
end
@@ -215,6 +219,39 @@ feature -- Access: global variable
end
end
feature -- Execution variables
execution_variable (a_name: READABLE_STRING_8): detachable ANY
-- Execution variable related to `a_name'
require
a_name_valid: a_name /= Void and then not a_name.is_empty
do
if attached execution_variables_table.item (a_name) as v then
Result := v.item
end
end
execution_variables: ITERABLE [WSF_ANY]
-- Execution variables values
set_execution_variable (a_name: READABLE_STRING_32; a_value: detachable ANY)
do
execution_variables_table.force (create {WSF_ANY}.make (a_name, a_value), a_name)
ensure
param_set: attached {WSF_ANY} execution_variable (a_name) as val and then val ~ a_value
end
unset_execution_variable (a_name: READABLE_STRING_32)
do
execution_variables_table.remove (a_name)
ensure
param_unset: execution_variable (a_name) = Void
end
feature {NONE} -- Execution variables: implementation
execution_variables_table: HASH_TABLE [WSF_ANY, READABLE_STRING_32]
feature -- Access: CGI Meta variables
meta_variable (a_name: READABLE_STRING_8): detachable WSF_STRING
@@ -802,6 +839,8 @@ feature {NONE} -- Cookies
v := s.substring (i + 1, j - 1)
p := j + 1
end
k.left_adjust
k.right_adjust
add_value_to_table (k, v, l_cookies)
end
end