{"id":16624276,"url":"https://github.com/dcramer/logan","last_synced_at":"2025-04-07T06:07:48.703Z","repository":{"id":2474090,"uuid":"3446866","full_name":"dcramer/logan","owner":"dcramer","description":"Logan is a toolkit for building standalone Django applications","archived":false,"fork":false,"pushed_at":"2016-07-27T16:15:14.000Z","size":56,"stargazers_count":204,"open_issues_count":6,"forks_count":19,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-31T04:05:55.955Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dcramer.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-15T05:24:55.000Z","updated_at":"2024-11-28T16:29:42.000Z","dependencies_parsed_at":"2022-07-08T19:45:07.500Z","dependency_job_id":null,"html_url":"https://github.com/dcramer/logan","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcramer%2Flogan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcramer%2Flogan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcramer%2Flogan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcramer%2Flogan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcramer","download_url":"https://codeload.github.com/dcramer/logan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601448,"owners_count":20964864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T03:45:45.727Z","updated_at":"2025-04-07T06:07:48.683Z","avatar_url":"https://github.com/dcramer.png","language":"Python","funding_links":[],"categories":["Videos","视频"],"sub_categories":[],"readme":"Logan\n=====\n\nLogan is a toolkit for running standalone Django applications. It provides you\nwith tools to create a CLI runner, manage settings, and the ability to bootstrap\nthe process.\n\nLet's take the Sentry project for example, it specifies that it wants to use logan\nfor running the application::\n\n    setup(\n        name='sentry',\n        install_requires=['logan'],\n        entry_points={\n            'console_scripts': [\n                'sentry = logan.runner:run_app',\n            ],\n        },\n    )\n\nIt then defines several Django Management Commands as part of it's project, via the\nstandard structure of sentry/management/commands/\u003ccommand name\u003e.py.\n\nNow when we call sentry. it's actually piping that to the logan runner. Logan simply\nloads the predefined settings file (which defaults to PROJECT_CONF, or ~/.project/project.conf.py)\nand then passes the command off to Django's internal representation of django-admin.py. In this case,\nPROJECT is determined by the caller of logan.runner, which is \"sentry\". If it were \"foo-bar\", PROJECT\nwould be FOO_BAR, and \"project\" would still be \"foo-bar\".\n\nIn most cases, you're also going to want to provide a default configuration to inherit from,\nas well as a template to generate for the user if their configuration does not exist.\n\nTo do this, within our sentry project we create a simple script, lets call put it in ``sentry/logan_runner.py``::\n\n    from logan.runner import run_app\n\n    def generate_settings():\n        \"\"\"\n        This command is run when ``default_path`` doesn't exist, or ``init`` is\n        run and returns a string representing the default data to put into their\n        settings file.\n        \"\"\"\n        return \"\"\n\n    def main():\n        run_app(\n            project='sentry',\n            default_config_path='~/.sentry/',\n            default_settings='sentry.conf.defaults',\n            settings_initializer='sentry.logan_runner.generate_settings',\n            settings_envvar='SENTRY_CONF',\n        )\n\n    if __name__ == '__main__':\n        main()\n\nWe'd then slightly adjust our entry point in our ``setup.py``::\n\n    setup(\n        name='sentry',\n        install_requires=['logan'],\n        entry_points={\n            'console_scripts': [\n                'sentry = sentry.logan_runner:main',\n            ],\n        },\n    )\n\nYou'll now be able to access the ``sentry`` command as if it were django-admin.py. Even better, it will\nbe configurable via an arbitrary settings file, and inherit any default settings you've specified::\n\n    # Note: run_gunicorn is provided by the gunicorn package\n    sentry run_gunicorn 0.0.0.0:8000 -w 3\n\nExtra Applications\n------------------\n\nA need might come up to allow the user to register additional settings. These will automatically apply\nbased on keynames prefixed with ``EXTRA_`` assuming the base key (the latter part of the setting name) is\nof type list or tuple.\n\nFor example, to register additional ``INSTALLED_APPS``, you would simply specify this in your custom\n(user) configuration::\n\n    EXTRA_INSTALLED_APPS = (\n        'foo.bar',\n    )\n\nThis will ensure your default setting's ``INSTALLED_APPS`` do not have to be modified, and the user\ncan specify additional apps with ease.\n\nIf you wish to disable this functionality, simply pass ``allow_extra=False`` to ``run_app``::\n\n    run_app(\n        # ...,\n        allow_extras=False,\n    )\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcramer%2Flogan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcramer%2Flogan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcramer%2Flogan/lists"}