Re: Any practical reason type(environ) must be dict (not subclass)?

Cory Benfield <[email protected]> Fri, 25 Mar 2016 17:23:35 +0000
Newsgroups gmane.comp.python.web
Message-ID <[email protected]>
--===============6330583209688529843==
Content-Type: multipart/signed; boundary="Apple-Mail=_73377672-72AE-4AAD-AEF5-E6CCE2E9F106"; protocol="application/pgp-signature"; micalg=pgp-sha256


--Apple-Mail=_73377672-72AE-4AAD-AEF5-E6CCE2E9F106
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8


> On 25 Mar 2016, at 15:04, Jason Madden <[email protected]> =
wrote:
>=20
>=20
>> On Mar 25, 2016, at 05:01, Cory Benfield <[email protected]> wrote:
>>=20
>> Given that gevent is keeping hold of its own reference to the =
environ, why does gevent not simply wrap the environ dict in a class =
that implements this functionality directly? In that manner, gevent can =
expose its own error handling behaviour as desired, and continue to =
follow PEP-3333.
>=20
> I did consider that, but didn't want to do that unless there were =
actual practical problems passing the same object that gevent =
references. Making a copy just to pass to the application adds =
additional time and memory requirements that are always nice to avoid in =
a server.

For what it=E2=80=99s worth, I=E2=80=99m not advocating a copy. I=E2=80=99=
m advocating a class like this:


class SecureDictWrapper(collections.MutableMapping):
    def __init__(self, environ):
        self._environ =3D environ

That class would then implement the MutableMapping API and delegate its =
calls through to the dictionary itself. There would still only be one =
dictionary: the only new allocation is for the wrapper class. The =
overhead is small. =3D)

Cory


--Apple-Mail=_73377672-72AE-4AAD-AEF5-E6CCE2E9F106
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail

-----BEGIN PGP SIGNATURE-----

iQIcBAEBCAAGBQJW9XQYAAoJEHD+F/imQ+Fbb98P/jG68qdq/0YQ2wn+iTSNugHM
9PY+6NhSmZtyoDnAUes3BWZT142entSX4IyrfffdAcUqNf780wUGyG0lgF9WRNjt
rTjgdVjavWb+Gud5BTI1ZJRQl50I2cGOVjw9OjKMzvLaJUvbCkmoBIhqTZ/7pq9Y
qJrJSs+svVfeF08+AJrX8/8ZywxEvqvKuAS1BvrU72HKhO02N5OE+fIerLKhw0K4
n/ZN2J1Ii772ycahFMX+TIlM67avKZMPehd9Oya1wU0dCfA+pRQr9fVhh3FSMCpf
bJeDraom8CDtDHW+mIK4YNesBhpUWQy4kjAXOjGKkWPFeICxavk6f/PUNPz7p6Ne
fHWXqot5cwgR4xPXyUjXhs2rAMKEtefzJNfP9BwuEIFM+VlvWWSnVg0dWL+qqed7
8qprJGmzAKllU5EXRKQl6M4r3Ikh2+Azj9Wb3LRpx63qgbk2K06idODYHFNJhjuw
Br6yE01MR7/CrF5fUsAFSj+Dz5C3e/uBdCBPj18NSQTvC37MLx40wqRW+O4X8ZKR
Qp+MTpd7dWXlXHa47DiDdeG+rHAG5O3hl9DSDNEJDE0fRb4B26wQNIKll4WGsbqU
a7sOp2S0Os79hunlBF8hvkU0cih0lsmLhzUVPB8XEoqQ3u6o2NtPiNHGnAQdMVFq
VUS/5RI+seTGQszlDlXe
=mFMb
-----END PGP SIGNATURE-----

--Apple-Mail=_73377672-72AE-4AAD-AEF5-E6CCE2E9F106--

--===============6330583209688529843==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Web-SIG mailing list
[email protected]
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: https://mail.python.org/mailman/options/web-sig/gcpw-web-sig%40m.gmane.org

--===============6330583209688529843==--