so wondering server error occurs in production (when app identical between production , development).
so, using flask-admin, display basic crud interface, model views rely on model's __repr__ method provide readable string in list view. in production (new app, same data dev), server error when __repr__ method inadvertently stupid. in development, same stupid behavior ignored or unnoticed.
for example:
model:
class author(db.model): first_name = db.column(db.string(50), nullable=true) middle_name = db.column(db.string(50), nullable=true) last_name = db.column(db.string(50), nullable=true) # ... def __repr__(): return '{}'.format(' '.join([self.first_name, self.middle_name, self.last_name])) # edited: checked repository , did have arguments correct -- wrote off top of head.
__repr__() in case causes error on server (which wsgi on apache) when first name, middle name, or last name null. attempts concatenate null , string join , causes variant of "expected string, got null" raised.
but, on development server, never see these errors (nor warnings).
i have since changed repr method check first name, middle name , last name before concatenating, @ loss why error occurs in production (wsgi app) not in development (flask dev server or cherrypi server).
so, ideas? different between 2 situations?
i had similar issue. solved strangely converting null none.
for example create function called in views , converts null values none type. way both in development , in production worked flawlessly.
i used flask dev server in development , wsgi , apache2 in production...
why worked can't tell you!
Comments
Post a Comment