Commit 90690d217baa489c9159f2e53bd553813115437c

Authored by David RENÉ
1 parent db235768

add Serialized type to Session_Field. This is not a new type but a serialization…

… of $T type which is stored into Session_Field in ByteArray
Showing 2 changed files with 77 additions and 8 deletions   Show diff stats
generic/session.anubis
... ... @@ -1059,6 +1059,70 @@ public define One
1059 1059 remove_any(_fields, fields_set_t, _field_name)
1060 1060 .
1061 1061  
  1062 + /*************** Serialized Type *****************/
  1063 +
  1064 +public define One
  1065 + put_Serialized_type
  1066 + (
  1067 + Var(List(Session_Field)) fields,
  1068 + String _field_name,
  1069 + $T _field_value
  1070 + )=
  1071 + put_ByteArray(fields, _field_name, serialize(_field_value))
  1072 +.
  1073 +
  1074 +public define One
  1075 + replace_Serialized_type
  1076 + (
  1077 + Var(List(Session_Field)) _fields,
  1078 + String _field_name,
  1079 + $T _field_value
  1080 + )=
  1081 + replace_any(_fields, byte_array_t, _field_name, byte_array(serialize(_field_value)))
  1082 +.
  1083 +
  1084 +public define One
  1085 + remove_Serialized_type
  1086 + (
  1087 + Var(List(Session_Field)) _fields,
  1088 + String _field_name
  1089 + )=
  1090 + remove_any(_fields, byte_array_t, _field_name)
  1091 +.
  1092 +
  1093 +public define Maybe($T)
  1094 + get_Serialized_type
  1095 + (
  1096 + Var(List(Session_Field)) fields,
  1097 + String _field_name,
  1098 + ) =
  1099 +
  1100 + if get_ByteArray(fields, _field_name) is
  1101 + {
  1102 + failure then failure,
  1103 + success(ba_type) then unserialize(ba_type)
  1104 + }
  1105 +.
  1106 +
  1107 +public define $T
  1108 + get_Serialized_type
  1109 + (
  1110 + Var(List(Session_Field)) fields,
  1111 + String _field_name,
  1112 + $T default
  1113 + ) =
  1114 +
  1115 + if get_ByteArray(fields, _field_name) is
  1116 + {
  1117 + failure then default,
  1118 + success(ba_type) then
  1119 + if unserialize(ba_type) is
  1120 + {
  1121 + failure then default,
  1122 + success(value) then value
  1123 + }
  1124 + }
  1125 +.
1062 1126  
1063 1127 /************************************************/
1064 1128  
... ...
web/CXM_web_session.anubis
... ... @@ -89,14 +89,19 @@ public define One set_page(WEB_Session s, String n)= replace_String(s.fields
89 89 public define One set_page(Var(List(Session_Field)) fields, String n)= replace_String(fields, "AWS_CURRENT_PAGE", n).
90 90 public define String get_page(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_PAGE", "").
91 91  
92   -public define One set_page_title(WEB_Session s, String n)= replace_String(s.fields, "AWS_CURRENT_PAGE_TITLE", n).
93   -public define One set_page_title(Var(List(Session_Field)) fields, String n)= replace_String(fields, "AWS_CURRENT_PAGE_TITLE", n).
94   -public define String get_page_title(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_PAGE_TITLE", "").
95   -
96   -public define One set_renderer(WEB_Session s, String n) = replace_String(s.fields, "AWS_CURRENT_PAGE_RENDERER", n).
97   -public define One set_renderer(Var(List(Session_Field)) fields, String n) = replace_String(fields, "AWS_CURRENT_PAGE_RENDERER", n).
98   -public define String get_renderer(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_PAGE_RENDERER", "").
99   -
  92 +public define One set_page_title(WEB_Session s, String n) = replace_String(s.fields, "AWS_CURRENT_PAGE_TITLE", n).
  93 +public define One set_page_title(Var(List(Session_Field)) fields, String n) = replace_String(fields, "AWS_CURRENT_PAGE_TITLE", n).
  94 +public define String get_page_title(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_PAGE_TITLE", "").
  95 +
  96 +public define One set_renderer(WEB_Session s, String n) = replace_String(s.fields, "AWS_CURRENT_PAGE_RENDERER", n).
  97 +public define One set_renderer(Var(List(Session_Field)) fields, String n) = replace_String(fields, "AWS_CURRENT_PAGE_RENDERER", n).
  98 +public define String get_renderer(WEB_Session s) = get_String (s.fields, "AWS_CURRENT_PAGE_RENDERER", "").
  99 +
  100 +public define One put_Serialized_type(WEB_Session s, String n, $T type) = put_Serialized_type(s.fields, n, type).
  101 +public define One replace_Serialized_type(WEB_Session s, String n, $T type) = replace_Serialized_type(s.fields, n, type).
  102 +public define Maybe($T) get_Serialized_type(WEB_Session s, String n) = get_Serialized_type(s.fields, n).
  103 +public define $T get_Serialized_type(WEB_Session s, String n, $T default) = get_Serialized_type(s.fields, n, default).
  104 +public define One remove_Serialized_type(WEB_Session s, String n) = remove_Serialized_type(s.fields, n).
100 105  
101 106 public define String
102 107 dump_WEB_Session_Fields
... ...