On Nov 2, 2011, at 7:59 AM, Carlos wrote:

> I'm using web2py latest trunk on win7.
> 
> As soon as I applied the following changeset:
> 
>     ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch
> 
> I got errors both in shell and web requests ...
> 
>     auth.settings.hmac_key = 'sha512:5fd2a4d2-d703-476c-8184-800b84e453b8'
>      File "C:\web2py\gluon\storage.py", line 199, in __setattr__
>         raise SyntaxError, 'setting key \'%s\' does not exist' % key
>     SyntaxError: setting key 'hmac_key' does not exist
> 
> If I reload the immediate prior changeset, everything works ok again.
> 
> Based on what I see in this change, you are now removing the Storage key also 
> via __setitem__ (in addition to __setattr__).
> 
> But I need a way to assign None to a Storage key, for which I was using: 
> mystorage['key'] = None (which did assign None and did not remove the key).
> 
> Now I would have no way to assign a None value to a Storage key?.
> 
> Plus the above error I get in Settings.
> 
> Can this change be reverted?, or what do you recommend instead?.
> 

I'll take a look. The patch was intended to make Storage behave consistently 
with respect to access through attributes and through keys, mainly so that 
s.key and s['key'] would behave the same way--that is, both yield None when the 
key isn't present in the underlying dict.

The behavior on storing None is along those lines: "s.key = None" deletes the 
key+value from the dict, and the patch makes "s['key'] = None" do the same 
thing. I'm frankly not sure that deletion is a great idea in any case; deletion 
should IMO be explicit.

Finally, the settings error appears to be a bug.

I'll send Massimo a patch ASAP to revert the new deletion and fix the error; I 
need to add a case to the unit test.

Reply via email to