[Flask] Macro expansion/evaluation?
jicenhower at yahoo.com
Wed Oct 14 19:19:46 CEST 2015
Hi All,I'm sure this is a newbie question but I haven't been able to find the answer by searching. Probably because I don't know what this technique is called in Python. I have created a class which extends the Flask-Appbuilder Model class which extends a SQLAlchemy class. I'm trying to validate that all required fields are populated. I have created this function that returns all the mapped attributes of the class:
mapper = inspect(dbObj)
This is my main class:
EventID = Column(Integer, primary_key=True)
EventKey = Column(String(30), unique=True, nullable=False)
Name = Column(String(100), nullable=False)
Description = Column(Text(1000), nullable=False)
BeginDate = Column(Date)
EndDate = Column(Date)
RegBeginDate = Column(Date)
RegEndDate = Column(Date)
Location = Column(String(200))
Address1 = Column(String(200))
Address2 = Column(String(200))
City = Column(String(20))
State = Column(String(2))
Zip = Column(String(10))
URL = Column(String(100))
Email = Column(String(100))
Phone = Column(String(20))Which contains the following method: def isValid(self):
columns = get_obj_mapped_columns(self)
for column in columns:
if (NOT column.nullable):
I would like to substitute the value in <column.name> in such a way that it is evaluated as the field name of the Event object.
Any guidance would be greatly appreciated!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Flask