A city saved in the database.
| 436 | |
| 437 | |
| 438 | class City(object): |
| 439 | """ |
| 440 | A city saved in the database. |
| 441 | """ |
| 442 | |
| 443 | |
| 444 | def makeCookie(self): |
| 445 | while True: |
| 446 | cookie = MakeRandomCookie().decode('utf8') |
| 447 | if not City.query.filter_by(cookie=cookie).first(): |
| 448 | self.cookie = cookie |
| 449 | return |
| 450 | |
| 451 | |
| 452 | def destroy(self): |
| 453 | |
| 454 | # TODO: clear parent pointers of sub-cities. |
| 455 | session.delete(self) |
| 456 | |
| 457 | |
| 458 | class Product(object): |