Switch to unified view

a/scripts/rethumb.py b/scripts/rethumb.py
...
...
5
import Image
5
import Image
6
import tg
6
import tg
7
from pylons import c
7
from pylons import c
8
from paste.deploy.converters import asint
8
from paste.deploy.converters import asint
9
9
10
from ming.orm import MappedClass, mapper, ThreadLocalORMSession, session, state
10
from ming.orm import mapper, ThreadLocalORMSession, session, state, Mapper
11
from allura.command import base
11
from allura.command import base
12
import forgetracker.model
12
import forgetracker.model
13
13
14
14
15
class RethumbCommand(base.Command):
15
class RethumbCommand(base.Command):
...
...
56
#        self.basic_setup()
56
#        self.basic_setup()
57
57
58
        existing_thumbs = 0
58
        existing_thumbs = 0
59
        base.log.info('Collecting application attachment classes')
59
        base.log.info('Collecting application attachment classes')
60
        package_model_map = {}
60
        package_model_map = {}
61
        for name, cls in MappedClass._registry.iteritems():
61
        for m in Mapper.all_mappers():
62
            sess = m.session
63
            cls = m.mapped_class
62
            if issubclass(cls, M.BaseAttachment):
64
            if issubclass(cls, M.BaseAttachment):
63
                if cls.__mongometa__.session is M.project_orm_session:
65
                if sess is M.project_orm_session:
64
                    package = cls.__module__.split('.', 1)[0]
66
                    package = cls.__module__.split('.', 1)[0]
65
                    l = package_model_map.get(package, [])
67
                    l = package_model_map.get(package, [])
66
                    l.append(cls)
68
                    l.append(cls)
67
                    package_model_map[package] = l
69
                    package_model_map[package] = l
68
70