FoxInCloud
Custom object changing data session
Gravatar is a globally recognized avatar based on your email address. Custom object changing data session
  Paul
  All
  Feb 20, 2019 @ 03:22pm

Hi,

I am running V 2.28.1-beta.2

Situation : public object - DefaultsObject has a property - Object2

DefaultsObject.Object2 = createobject("SomeClass")

The class SomeClass is based on sficcst (custom) and has some methods on it.

Problem :
Following on from my previous post the methods on the object now work, but the datasession is changing whenever a method is run on the object - but only if I log on for the second time.

Symptom :

  1. navigate to login form (default datasession)
  2. from inside the form, create the object and run a method on it - all fine
  3. close the browser tab
  4. new tab, navigate to login form (default datasession)
  5. log in
  6. from inside the form, create the object and run a method on it - crash - the datasession is different so the database set("database") is not set

The first time through the datasession = 2, Awapphost.
The first time through the datasession = 9, Awappuserenv.

Any ideas?

Thanks
Paul

Gravatar is a globally recognized avatar based on your email address. re: Custom object changing data session
  FoxInCloud Support - Thierry N.
  Paul
  Feb 21, 2019 @ 02:23am

Hi Paul,

1- I would create the object once for all in xxxSets.Init(), and set it up for the user after .wUserLogIn() and cleanup after .wUserLogOff(); it'd be simpler and faster when restoring the user's state than discarding the object and re-creating it when user logs back in; in short I would keep all public objects (and child objects) alive across the life of the application.

You get the rationale behind: while in a desktop application dealing with a single user you can create and discard resources for a single use, FoxInCloud shares resources across users and saves and restores their state upon each action (except when the same user hits the same server twice in a row).

Not sure how much change it would imply for you, you may just use thisForm.wlLAN or wlLAN() as a condition to discard Object2

2- However I don't understand how your object's code can run in the dataSession of the object that restores the application environment for the user (awAppUserEnv).
Even if awAppUserEnv has (re)created Object2, the code in a custom object always executes in the dataSession of the caller; in your case the login form running in the default datasession, which should be the awAppHost dataSession (unless it runs in the awAppUserEnv dataSession, and I don't see any reason for this to happen).

Would you mind trying to understand this dataSession switching mystery?

3- Anyway, before restoring a public variable of type Object, awAppUserEnv should switch to the application's dataSession (awAppHost) where public variables are created initially, so that .Init() and/or *_assign() code executes in the application's datasession.

We've implemented this change in a experimental aw.app that you can download from ftp://foxincloud.com/aw.app and save to home(1) + "tools\ab\aw\aw.app" (updated: removed _source\)

Please feedback if this fixes this issue.

© 1996-2019