This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def clone_model(model): | |
| """Clone an arbitrary sqlalchemy model object without its primary key values.""" | |
| # Ensure the model’s data is loaded before copying. | |
| model.id | |
| table = model.__table__ | |
| non_pk_columns = [k for k in table.columns.keys() if k not in table.primary_key] | |
| data = {c: getattr(model, c) for c in non_pk_columns} | |
| data.pop('id') | |
| return data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """ | |
| ListeningSocketHandler | |
| ====================== | |
| A python logging handler. | |
| logging.handlers.SocketHandler is a TCP Socket client that sends log | |
| records to a tcp server. | |
| This class is the opposite. |