I'm not 100% sure, but yeah, I think you can do this in the manner you have
described.

You can't really have objects make changes to other objects and have that
persist across contexts, but you can certainly create an ObjectTemplate for
your "Session" , create an ObjectTemplate for "Request", and then have
"Requests" parent be ObjectTemplate.

Refer to this section of the v8 docs for ideas on how to do that:

http://bespin.cz/~ondras/html/classv8_1_1FunctionTemplate.html#aa2bcc2652b5f0fdbc666d943ccf72021

On Wed, Jun 6, 2012 at 11:54 AM, MikeM <[email protected]> wrote:

> I'm trying to determine if it is possible to chain two global objects
> together via prototype chain.
> My setup is basically a "web server" where there are two global
> objects in play.
> Each trip to the web server (a request) runs server side JS.
>
> The 1st is the "request global'.  This global holds any objects/
> functions/properties that live only for the duration of the request
> itself.
> The 2nd is the "session global".  If a "session" is started during the
> request this global is used to hold anything that must be persisted
> across requests.
> The session global will hold all standard class prototypes (like
> Object, String, Function etc) plus anything added by the user.
> The request global will NOT have standard classes defined on it.
> The request global will be chained to the session global via prototype
> chain.
> That should enable any scripts run against the request global to see
> the same standard classes (prototypes) with each trip back to the
> server.
> An object named "Session" will be defined on the request global that
> points to the session global directly.
> This would allow a script to set properties directly on the session
> global if necessary to persistent them until the next request.
> At the end of each request the "request global" will be destroyed.
>
> I'm a long time Spidermonkey user & V8 newbie, making the leap to V8.
> Any help in how to accomplish this would be most appreciated.
> Don't spare the details.
>
> Thanks!
>
> Mike
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to