@@ -45,14 +45,9 @@ def heading(self):
4545 """
4646 if self ._heading is None :
4747 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 )
5651 return self ._heading
5752
5853 def declare (self , context = None ):
@@ -411,7 +406,7 @@ def delete(self, verbose=True):
411406 print ('About to delete:' )
412407
413408 if not already_in_transaction :
414- self . connection .start_transaction ()
409+ conn .start_transaction ()
415410 total = 0
416411 try :
417412 for name , table in reversed (list (delete_list .items ())):
@@ -423,25 +418,25 @@ def delete(self, verbose=True):
423418 except :
424419 # Delete failed, perhaps due to insufficient privileges. Cancel transaction.
425420 if not already_in_transaction :
426- self . connection .cancel_transaction ()
421+ conn .cancel_transaction ()
427422 raise
428423 else :
429424 assert not (already_in_transaction and safe )
430425 if not total :
431426 print ('Nothing to delete' )
432427 if not already_in_transaction :
433- self . connection .cancel_transaction ()
428+ conn .cancel_transaction ()
434429 else :
435430 if already_in_transaction :
436431 if verbose :
437432 print ('The delete is pending within the ongoing transaction.' )
438433 else :
439434 if not safe or user_choice ("Proceed?" , default = 'no' ) == 'yes' :
440- self . connection .commit_transaction ()
435+ conn .commit_transaction ()
441436 if verbose or safe :
442437 print ('Committed.' )
443438 else :
444- self . connection .cancel_transaction ()
439+ conn .cancel_transaction ()
445440 if verbose or safe :
446441 print ('Cancelled deletes.' )
447442
0 commit comments