MCPcopy Create free account
hub / github.com/webpy/webpy / attrget

Function attrget

web/form.py:13–27  ·  view source on GitHub ↗
(obj, attr, value=None)

Source from the content-addressed store, hash-verified

11
12
13def attrget(obj, attr, value=None):
14 try:
15 if hasattr(obj, "has_key") and attr in obj:
16 return obj[attr]
17 except TypeError:
18 # Handle the case where has_key takes different number of arguments.
19 # This is the case with Model objects on appengine. See #134
20 pass
21 if (
22 hasattr(obj, "keys") and attr in obj
23 ): # needed for Py3, has_key doesn't exist anymore
24 return obj[attr]
25 elif hasattr(obj, attr):
26 return getattr(obj, attr)
27 return value
28
29
30class Form:

Callers 1

validatesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected