35 |
|
|
36 |
class Error(StandardError): |
class Error(StandardError): |
37 |
# Base exception |
# Base exception |
38 |
pass |
value = "" |
39 |
|
def __init__(self, value): |
40 |
|
self.value = value |
41 |
|
def __str__(self): |
42 |
|
return self.value |
43 |
|
|
44 |
class LoginError(Error): |
class LoginError(Error): |
45 |
# Raised when invalid login user/pass was provided |
# Raised when invalid login user/pass was provided |
440 |
|
|
441 |
|
|
442 |
# Post changes to the database |
# Post changes to the database |
443 |
def post(self, foreign_keys={}): |
def post(self, foreign_keys={},autoCommit=1): |
444 |
# post our changes |
# post our changes |
445 |
self._update_cursor = self._dataObject._dataConnection.cursor() |
self._update_cursor = self._dataObject._dataConnection.cursor() |
446 |
|
|
472 |
self._cachedRecords.pop(recordPosition) |
self._cachedRecords.pop(recordPosition) |
473 |
self._recordCount -= 1 |
self._recordCount -= 1 |
474 |
|
|
475 |
record.post() |
record.post(autoCommit) |
476 |
|
|
477 |
# Move to record 0 if all preceding records were deleted |
# Move to record 0 if all preceding records were deleted |
478 |
# (or set to -1 if all records were deleted) |
# (or set to -1 if all records were deleted) |
664 |
|
|
665 |
|
|
666 |
# Posts changes to database |
# Posts changes to database |
667 |
def post(self): |
def post(self,autoCommit=1): |
668 |
# Should a post() to a read only datasource cause a ReadOnlyError? |
# Should a post() to a read only datasource cause a ReadOnlyError? |
669 |
# It does no harm to attempt to post since nothing will be posted, |
# It does no harm to attempt to post since nothing will be posted, |
670 |
# But does this allow sloppy programming? |
# But does this allow sloppy programming? |
689 |
# start from the beginning and run the triggers again. |
# start from the beginning and run the triggers again. |
690 |
# |
# |
691 |
if status != (self._insertFlag, self._deleteFlag, self._updateFlag): |
if status != (self._insertFlag, self._deleteFlag, self._updateFlag): |
692 |
self.post() |
self.post(autoCommit) |
693 |
return |
return |
694 |
|
|
695 |
|
|
697 |
GDebug.printMesg(5,'Posting datasource %s' % self._parent._dataObject.name) |
GDebug.printMesg(5,'Posting datasource %s' % self._parent._dataObject.name) |
698 |
|
|
699 |
if self.isPending(): |
if self.isPending(): |
700 |
self._postChanges() |
self._postChanges(autoCommit) |
701 |
|
|
702 |
|
|
703 |
# Post all detail records |
# Post all detail records |
708 |
for i in range(len(c._masterfields)): |
for i in range(len(c._masterfields)): |
709 |
fk[c._detailfields[i]] = self.getField(c._masterfields[i]) |
fk[c._detailfields[i]] = self.getField(c._masterfields[i]) |
710 |
|
|
711 |
self._cachedDetailResultSets[child].post(foreign_keys=fk) |
self._cachedDetailResultSets[child].post(foreign_keys=fk,autoCommit=autoCommit) |
712 |
|
|
713 |
|
|
714 |
# Sets the ResultSet associated with this master record |
# Sets the ResultSet associated with this master record |
721 |
### |
### |
722 |
|
|
723 |
# Post any changes to database |
# Post any changes to database |
724 |
def _postChanges(self): |
def _postChanges(self,autoCommit=1): |
725 |
return 1 |
return 1 |
726 |
|
|
727 |
|
|