Skip to content

Conversation

@cdvv7788
Copy link
Contributor

Summary

Refactor the way django is setup in the application

Related issues #496

Changes these areas

  • Bugfixes
  • Feature behavior
  • Command line interface
  • Configuration options
  • Internal architecture
  • Snapshot data layout on disk

}


def using_django(func):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is cool but I think it's too "magic" for not much gain. easier to just keep it as a function call at the top of all the ones that need it.

def add(urls: Union[str, List[str]], out_dir: Path):
    setup_django(out_dir=our_dir, check_db=True)
    ...

@pirate
Copy link
Member

pirate commented Oct 24, 2020

I have an idea, what if we initialize Django always, but if it's not in a data dir, we use a fake database in memory instead. This also lets us do oneshot easily, as we will write to the pretend database and immediately forget it on the next run.

settings.py:

DATABASE_FILE = Path(OUTPUT_DIR) / SQL_INDEX_FILENAME
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': str(DATABASE_FILE) if DATABASE_FILE.exists() else ':memory:',
    }
}

@cdvv7788 cdvv7788 mentioned this pull request Oct 26, 2020
6 tasks
@cdvv7788
Copy link
Contributor Author

Superseded by #515

@cdvv7788 cdvv7788 closed this Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants