Re: libseed-list __script_path__ in sandbox contexts



Committed
Regards
Alan

 --- On 30/Jun/2010, Jonatan Liljedahl wrote: 
> This seems to work, now a script can do
> 
> c = new imports.sandbox.Context;
> c.add_globals();
> c.eval("foo = imports.foo");
> 
> and it will find 'foo' in same dir as above script.
> 
> /Jonatan
> 
> Jonatan Liljedahl wrote:
> > I think ctx.add_globals() should copy the __script_path__ so that doing 
> > imports in the new context does the '.' replacement trick. (Otherwise 
> > '.' will be interpreted as current directory)
> > 
> > Something like this:
> > 
> > diff --git a/modules/sandbox/seed-sandbox.c 
> > b/modules/sandbox/seed-sandbox.c
> > index b33e57d..a1c80a6 100644
> > --- a/modules/sandbox/seed-sandbox.c
> > +++ b/modules/sandbox/seed-sandbox.c
> > @@ -84,6 +84,10 @@ seed_sandbox_context_add_globals (SeedContext ctx,
> >      }
> >    seed_prepare_global_context (c);
> > 
> > +  SeedObject g = seed_context_get_global_object (c);
> > +  SeedObject global = seed_context_get_global_object (ctx);
> > +  seed_object_set_property (c, g, "__script_path__", 
> > seed_object_get_property (ctx, global, "__script_path__"));
> > +
> >    return seed_make_null (ctx);
> >  }
> > 
> > /Jonatan
> > _______________________________________________
> > libseed-list mailing list
> > libseed-list gnome org
> > http://mail.gnome.org/mailman/listinfo/libseed-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]