Commits

Lars Yencken committed 0464d24

Fixes a bug in the build command for nested apps.

Comments (0)

Files changed (2)

 #----------------------------------------------------------------------------#
 
 # Default include path for python, version inspecific.
-scons_python_version = sysconfig.get_config_var('VERSION')
+#scons_python_version = sysconfig.get_config_var('VERSION')
+scons_python_version = '2.7'
 python_version = ARGUMENTS.get('python') or scons_python_version 
 
 print 'Using Python %s' % python_version

simsearch/search/management/commands/build.py

 #
 
 """
+Adds a command to automatically run a build for each app used.
 """
 
 from django.core.management.base import BaseCommand, CommandError
     help = 'Builds the initial similarity database.'
 
     def handle(self, *args, **kwargs):
+        found_one = False
         for app_name in settings.INSTALLED_APPS:
-            app = __import__(app_name)
-            if hasattr(app, 'build'):
-                print app
-                app.build()
+            module = __import__(app_name)
+            for part in app_name.split('.')[1:]:
+                module = getattr(module, part)
+
+            if hasattr(module, 'build'):
+                module.build()
+                found_one = True
+
+        if not found_one:
+            raise Exception('no apps had build commands')
 
 # vim: ts=4 sw=4 sts=4 et tw=78: