@@ -45,14 +45,9 @@ def heading(self):
45
45
"""
46
46
if self ._heading is None :
47
47
self ._heading = Heading () # instance-level heading
48
- if not self ._heading : # lazy loading of heading
49
- if self .connection is None :
50
- raise DataJointError (
51
- 'DataJoint class is missing a database connection. '
52
- 'Missing schema decorator on the class? (e.g. @schema)' )
53
- else :
54
- self ._heading .init_from_database (
55
- self .connection , self .database , self .table_name , self .declaration_context )
48
+ if not self ._heading and self .connection is not None : # lazy loading of heading
49
+ self ._heading .init_from_database (
50
+ self .connection , self .database , self .table_name , self .declaration_context )
56
51
return self ._heading
57
52
58
53
def declare (self , context = None ):
@@ -411,7 +406,7 @@ def delete(self, verbose=True):
411
406
print ('About to delete:' )
412
407
413
408
if not already_in_transaction :
414
- self . connection .start_transaction ()
409
+ conn .start_transaction ()
415
410
total = 0
416
411
try :
417
412
for name , table in reversed (list (delete_list .items ())):
@@ -423,25 +418,25 @@ def delete(self, verbose=True):
423
418
except :
424
419
# Delete failed, perhaps due to insufficient privileges. Cancel transaction.
425
420
if not already_in_transaction :
426
- self . connection .cancel_transaction ()
421
+ conn .cancel_transaction ()
427
422
raise
428
423
else :
429
424
assert not (already_in_transaction and safe )
430
425
if not total :
431
426
print ('Nothing to delete' )
432
427
if not already_in_transaction :
433
- self . connection .cancel_transaction ()
428
+ conn .cancel_transaction ()
434
429
else :
435
430
if already_in_transaction :
436
431
if verbose :
437
432
print ('The delete is pending within the ongoing transaction.' )
438
433
else :
439
434
if not safe or user_choice ("Proceed?" , default = 'no' ) == 'yes' :
440
- self . connection .commit_transaction ()
435
+ conn .commit_transaction ()
441
436
if verbose or safe :
442
437
print ('Committed.' )
443
438
else :
444
- self . connection .cancel_transaction ()
439
+ conn .cancel_transaction ()
445
440
if verbose or safe :
446
441
print ('Cancelled deletes.' )
447
442
0 commit comments