I am trying to swap in the key name from a request.param
for an Elixir object attribute. Below, the Elixir object bk
is a Book()
which has an attribute PrintTitle
. PrintTitle
also comes in from a form as a request.param
. Rather than manually map all the parameters to the Book attributes, I would like to map them based on a simple if in
. However, it doesn't work, because I have the wrong syntax or method at bk.k
.
if len(request.params) != 0:
bk = Book()
for k, v in request.params.items():
print k, v # gives me love
bk.k = v # no love here
print 'Print Title:', bk.PrintTitle # value is None (obviously)