MCPcopy Index your code
hub / github.com/webpy/webpy / Storage

Class Storage

web/utils.py:74–111  ·  view source on GitHub ↗

A Storage object is like a dictionary except `obj.foo` can be used in addition to `obj['foo']`. >>> o = storage(a=1) >>> o.a 1 >>> o['a'] 1 >>> o.a = 2 >>> o['a'] 2 >>> del o.a >>> o.a Traceback (most r

Source from the content-addressed store, hash-verified

72
73
74class Storage(dict):
75 """
76 A Storage object is like a dictionary except `obj.foo` can be used
77 in addition to `obj['foo']`.
78
79 >>> o = storage(a=1)
80 >>> o.a
81 1
82 >>> o['a']
83 1
84 >>> o.a = 2
85 >>> o['a']
86 2
87 >>> del o.a
88 >>> o.a
89 Traceback (most recent call last):
90 ...
91 AttributeError: 'a'
92
93 """
94
95 def __getattr__(self, key):
96 try:
97 return self[key]
98 except KeyError as k:
99 raise AttributeError(k)
100
101 def __setattr__(self, key, value):
102 self[key] = value
103
104 def __delattr__(self, key):
105 try:
106 del self[key]
107 except KeyError as k:
108 raise AttributeError(k)
109
110 def __repr__(self):
111 return "<Storage " + dict.__repr__(self) + ">"
112
113
114storage = Storage

Callers 5

storifyFunction · 0.85
sendMethod · 0.85
send_with_awsMethod · 0.85
send_with_smtpMethod · 0.85
default_email_senderMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected