diff --git a/asyncron/admin.py b/asyncron/admin.py index a6c1232..c96a1b4 100644 --- a/asyncron/admin.py +++ b/asyncron/admin.py @@ -173,6 +173,7 @@ class TraceAdmin( BaseModelAdmin ): #readonly_fields = [ f.name for f in Trace._meta.fields ] def has_add_permission( self, request, obj = None ): return False + def has_change_permission( self, request, obj = None ): return False def execution( self, obj ): if obj.last_run_datetime: diff --git a/asyncron/extender.py b/asyncron/extender.py index 4889391..8cafbc2 100644 --- a/asyncron/extender.py +++ b/asyncron/extender.py @@ -2,6 +2,8 @@ import collections import functools from .utils import rgetattr +from django.core.exceptions import SynchronousOnlyOperation + class Extender: capturing_instance = None @@ -39,8 +41,17 @@ class Extender: break if check_failed: continue - if any( rgetattr(self, k.replace("__", ".")) != v for k, v in filters.items() ): - continue + try: + for k, v in filters.items(): + assert rgetattr(self, k.replace("__", ".")) == v + except AssertionError: continue + except SynchronousOnlyOperation: + raise SynchronousOnlyOperation( + f"Finding the correct method from extensions should not rely on a database hit!\n" + f" - Hint: Try caching the needed field ({k}) with prefetch_related if it's from a query set,\n" + " - Or use the eval_related function that comes bundled with asyncron.base.BaseModel before you call this method." + ) + return f( self, *args, **kwargs ) raise NotImplementedError(f"{self} Did not match any extensions for '{extended_name}'.") diff --git a/asyncron/migrations/0003_alter_task_self_aware.py b/asyncron/migrations/0003_alter_task_self_aware.py new file mode 100644 index 0000000..f973d44 --- /dev/null +++ b/asyncron/migrations/0003_alter_task_self_aware.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.2 on 2025-08-09 09:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('asyncron', '0002_task_self_aware'), + ] + + operations = [ + migrations.AlterField( + model_name='task', + name='self_aware', + field=models.BooleanField(default=True, help_text="Whether It's first argument is 'self', being a trace instance."), + ), + ] diff --git a/asyncron/models.py b/asyncron/models.py index d85bce6..ec2f151 100644 --- a/asyncron/models.py +++ b/asyncron/models.py @@ -60,7 +60,7 @@ class Task( BaseModel ): null = True, blank = True ) #None will mean it's a "service" like task gracetime = models.DurationField( default = timezone.timedelta( minutes = 1 ) ) - self_aware = models.BooleanField( default = False, help_text = "Whether It's first argument is 'self', being a trace instance." ) + self_aware = models.BooleanField( default = True, help_text = "Whether It's first argument is 'self', being a trace instance." ) #Periodic Tasks interval = models.DurationField( null = True, blank = True ) diff --git a/setup.py b/setup.py index 9d68464..277f58e 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='asyncron', - version='0.1.9.4', + version='0.1.9.5', packages=find_packages(), #include_package_data=True, # Include static files from MANIFEST.in install_requires=[