Minor improvements and version bump
Made traces uneditable in django admin (looks better now) Extender gives better error message on lazy related fields in async context made self_aware default True for tasks
This commit is contained in:
parent
ba4c7fb772
commit
f6ce4fc374
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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}'.")
|
||||
|
|
|
|||
18
asyncron/migrations/0003_alter_task_self_aware.py
Normal file
18
asyncron/migrations/0003_alter_task_self_aware.py
Normal file
|
|
@ -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."),
|
||||
),
|
||||
]
|
||||
|
|
@ -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 )
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user