Description
For a production instance in which the default for expiration should be 'never' - so this entry in the dropdown is also preselected - the cleanup_snippets management script fails, since it relies on an integer value in the config.EXPIRE_DEFAULT setting.
Environment
Both dockerized setup (containers via docker hub) and local development via docker-compose.
Steps to reproduce
- Edit
dpaste/settings/local.py and add the following custom ProductionDpasteAppConfig:
from dpaste.apps import dpasteAppConfig
from django.utils.translation import gettext_lazy as _
class ProductionDpasteAppConfig(dpasteAppConfig):
EXPIRE_DEFAULT = "never"
INSTALLED_APPS.remove('dpaste.apps.dpasteAppConfig')
INSTALLED_APPS.append('dpaste.settings.local.ProductionDpasteAppConfig')
- Start your instance (e.g., via
docker-compose up
- Run the cleanup_snippets script (e.g., via
docker-compose exec app ./manage.py cleanup_snippets
Expected result
The script currently joins two queries - one for snippets with an expire time set, and one for onetime snippets that haven't yet been viewed. It is the second query that fails to build:
Snippet.objects.filter(
expire_type=Snippet.EXPIRE_ONETIME,
published__lte=(
timezone.now() - timedelta(seconds=config.EXPIRE_DEFAULT)
),
)
IMHO that script should, in case the EXPIRE_DEFAULT isn't set to an int value, simply omit checking for these one-time snippets.
Actual result
Here's the stacktrace:
Traceback (most recent call last):
File "/app/manage.py", line 34, in <module>
main()
File "/app/manage.py", line 30, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/app/dpaste/management/commands/cleanup_snippets.py", line 38, in handle
timezone.now() - timedelta(seconds=config.EXPIRE_DEFAULT)
TypeError: unsupported type for timedelta seconds component: str
Description
For a production instance in which the default for expiration should be 'never' - so this entry in the dropdown is also preselected - the cleanup_snippets management script fails, since it relies on an integer value in the config.EXPIRE_DEFAULT setting.
Environment
Both dockerized setup (containers via docker hub) and local development via docker-compose.
Steps to reproduce
dpaste/settings/local.pyand add the following custom ProductionDpasteAppConfig:docker-compose updocker-compose exec app ./manage.py cleanup_snippetsExpected result
The script currently joins two queries - one for snippets with an expire time set, and one for onetime snippets that haven't yet been viewed. It is the second query that fails to build:
IMHO that script should, in case the EXPIRE_DEFAULT isn't set to an int value, simply omit checking for these one-time snippets.
Actual result
Here's the stacktrace: