Child: [bea16d] (diff)

Download this file

015-add-neighborhood_id-to-blog-posts.py    22 lines (17 with data), 564 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import sys
import logging
from pylons import c
from ming.orm import session
from ming.orm.ormsession import ThreadLocalORMSession
from forgeblog import model as BM
log = logging.getLogger(__name__)
def main():
broken_posts = BM.BlogPost.query.find(dict(neighborhood_id=None)).all()
for post in broken_posts:
c.project = post.app.project
c.app = post.app
post.neighborhood_id = post.app.project.neighborhood_id
ThreadLocalORMSession.flush_all()
ThreadLocalORMSession.close_all()
if __name__ == '__main__':
main()