Commit 9106f40a authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Remove a management shim for setting SITE_URL

The hack was breaking the staticfiles app for the development server.
parent a6b9117f
Loading
Loading
Loading
Loading
+2 −43
Original line number Diff line number Diff line
import os
import sys
import logging
from django.core import management, exceptions


class ManagementUtility(management.ManagementUtility):

	def fetch_command(self, subcommand):
		try:
			from django.conf import settings
			from django.core.management.commands.runserver import Command
		except (exceptions.ImproperlyConfigured) as exc:
			sys.stderr.write(
				"cannot run '{0}' due to improperly configured settings: {1}\n"
				.format(subcommand, exc)
			);
			sys.exit(1)

		excluded_cmds = getattr(settings, 'EXCLUDED_COMMANDS', None)
		if excluded_cmds and subcommand in excluded_cmds:
			class DummyCommand(Command):
				def run(self, **opts):
					sys.stderr.write(
						"running '{0}' is disallowed by the package "
						"configuration.\n"
						.format(subcommand)
					);
					sys.exit(1)
			return DummyCommand()

		class RunserverCommand(Command):
			def run(self, **options):
				if not hasattr(settings, 'SITE_URL'):
					settings.SITE_URL = 'http://{0}:{1}'.format(
						self.addr or 'localhost',
						self.port
					)
				return super(RunserverCommand, self).run(**options)

		if subcommand == 'runserver':
			klass = RunserverCommand()
		else:
			klass = super(ManagementUtility, self).fetch_command(subcommand)
		return klass
from django.core import management


def main():
@@ -53,4 +12,4 @@ def main():
		"DJANGO_SETTINGS_MODULE",
		"kodo_sso.settings.production"
	)
	ManagementUtility(sys.argv).execute()
	management.ManagementUtility(sys.argv).execute()