[Zope-Coders] Re: [ZC] 490/ 2 Resolve ""Object" class for PythonScripts"

Casey Duncan casey@zope.com
Wed, 4 Sep 2002 22:58:34 -0400


Why a __setitem__ as opposed to __setattr__? Is it because that is forbid=
den=20
in general in the bytecode interpreter?

I'm a little confused what this gains us over just using a dict (but I am=
=20
happy to be enlightened). Also this should be documented somewhere, like =
the=20
scripting section of the Zope book ;^)

-Casey

On Wednesday 04 September 2002 06:20 pm, Collector: Zope Bugs, Features, =
and=20
Patches ... wrote:
> Issue #490 Update (Resolve) ""Object" class for PythonScripts"
>  Status Resolved, Zope/feature+solution low
> To followup, visit:
>   http://collector.zope.org/Zope/490
>=20
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> =3D Resolve - Entry #2 by evan on Sep 4, 2002 6:20 pm
>=20
>  Status: Accepted =3D> Resolved
>=20
> Checked into trunk, so it should make the 2.6 branch.
> ________________________________________
> =3D Request - Entry #1 by evan on Jul 26, 2002 3:48 pm
>=20
>  Status: Pending =3D> Accepted
>=20
>  Supporters added: evan
>=20
> It would be handy for Scripts to be able to create unsecured, mutable=20
objects to hand around during a request.  This could be accomplished by=20
adding the following lines to Products/PythonScripts/standard.py:
>=20
>     security.declarePublic('Object')
>     def Object():
>         # Don't expose classes
>         return _Object()
>     from ZPublisher.HTTPRequest import record
>     class _Object(record):
>         _guarded_writes =3D 1
> =20
>         def __setitem__(self, key, value):
>             self.__dict__[str(key)] =3D value
>=20
> If there aren't any objections I'd like to check this into the trunk.
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
>=20