Ferreteria/v0.5/stash

From Woozle Writes Code
< Ferreteria‎ | v0.5
Revision as of 13:43, 19 December 2022 by Woozle (talk | contribs)
Jump to navigation Jump to search
Ferreteria 0.5: message stashing

About

Sometimes a process emits output right before a redirect needs to happen -- most commonly in response to a form submission (we do a redirect right after processing POST input in order to prevent accidental data resubmissions).

For this reason, the redirect system checks for output (which would/should not yet have been sent to the screen anyway), saves it in the user's browser via the stash cookie, and then does the redirect. The page object should always look for any stashed content to display, adding it at the top of any content it adds to the render. (This last part is currently not working, 2022-12-03.)

Design

Conceptually, there are two ways to "stash" data that needs to persist for a given browser session across plural http loads:

  • put the data in the browser cookie
  • put the data in the session record

The first one results in Ferreteria using two browser cookies (one for the Session ID, one for the stashed data) while the second uses only one (the Session ID loads the session data, including the stash).

Classes/Methods

  • The message text gets submitted to caPageContent->AddText(), which presumably adds it to the output buffer that the redirect process fetches from to toss over to the stash.
  • It looks like the stashed content is supposed to be retrieved by caPageContent->OnFigure()
  • storing/fetching the stash:
    • cookie method:
      • csAppCookie has the capability of reading/writing browser cookies
    • database method:
      • The ferret\login\session\card\cCalc class can read/write Session Stash data.

History

  • 2022-12-19 Given EU regulations around cookies, I'm thinking it might be a "selling point" to be able to say that Ferreteria uses exactly one cookie, without any caveats. The ability for apps to use cookie-stashing for their own purposes will still be there; we just won't use it for any core Ferreteria functionality (in this case, displaying a message generated by a redirected page).
  • 2022-12-18 Currently trying to track down which of the two designs I actually implemented. Tentatively, I may have done a mishmash of both, which could be why it isn't working right just at the moment...
    • The message is, in fact, stashed in the cookie under gmine-stash (the Session ID is in gmine-session).
    • It looks like the Session Calc class is trying to access it in the Session data, however... and it's not stored there. (The username is, though, for some reason.)