It's nothing wrong with using copy module of standard python, I just find it more convenient with a .copy() method. And plus, since Storage inherits dict, developer can call .copy() and expect a Storage object returned. Currently it returns dict and that breaks the coherence of the behaviour of Storage.
Sorry I didn't test the patch thoroughly. I'll post another later. 2009/11/15 mdipierro <mdipie...@cs.depaul.edu>: > > I like idea but there is a problem. It break backward compatibility > for apps that use a session variable named 'copy' > >>>> class A(dict): > ... def __getattr__(self,key): return self[key] > ... def __setattr__(self,key,value): self[key]=value > ... def copy(self): return self >>>> a=A() >>>> a.b=5 >>>> a.b > 5 >>>> a.copy() > {'b': 5} >>>> a.copy=6 >>>> a.copy > <bound method A.copy of {'copy': 6, 'b': 5}> > should be 6 for backward compatibility > > what is wrong with? > from copy import copy > a=Storage() > b=copy(a) > > On Nov 15, 1:56 am, "Xie&Tian" <mft...@gmail.com> wrote: >> Here is a patch for gluon.storage.Storage object. I added a "copy()" >> method so that when copying an storage object you can get another >> storage object instead of a dict. Note that this is a simple shadow >> copy. >> >> Hope it helps. >> >> -- >> Luyun Xie >> 谢路云http://magefromhell.blogspot.com/ >> (http://blog.hellmage.info/) >> >> storage.py.diff >> < 1KViewDownload > > > -- Luyun Xie 谢路云 http://magefromhell.blogspot.com/ (http://blog.hellmage.info/) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---