Użytkownik Ed Leafe napisał:
> On Jan 20, 2010, at 6:32 AM, Jacek Kałucki wrote:
>
>
>> I see that Dabo has ability to retrieve fields set to their
>> default values on backend.
>>
> I don't know what you are referring to. We retrieve the contents of
> records from the database, no matter how they are set.
>
>
>> Unfortunately this feature is mutually exclusive with another feature.
>> If I set DefaultVales property there is no retrieving any more,
>> but I would like to use both features simultaneously.
>> I found two options till now:
>> - set DefaultValues=None and move settings to OnNew() method
>> - requery bizobj every new record save.
>> Don't you think that they should be independent each other?
>> Maybe there should be a NullDefaults tuple property instead?
>>
>
> I am not understanding what you are trying to accomplish. You'll need
> to explain better, perhaps with an example.
>
Look at dCursorMixin.__saverow() method.
There is code:
<code>
if newrec and self._nullDefaults:
# We need to retrieve any new default values
aux = self.AuxCursor
if not isinstance(self.KeyField, tuple):
keyFIelds = [self.KeyField]
else:
keyFIelds = self.KeyField
wheres = []
for kf in keyFIelds:
fld = self.BackendObject.encloseNames(kf,
self.AutoQuoteNames)
val = self.getFieldVal(kf)
if isinstance(val, basestring):
val = "'" + val.encode(self.Encoding) + "' "
elif isinstance(val, (datetime.date,
datetime.datetime)):
val = self.formatDateTime(val)
else:
val = str(val)
wheres.append("%s = %s" % (fld, val))
where = " and ".join(wheres)
aux.execute("select * from %s where %s" % (self.Table,
where))
try:
data = aux.getDataSet()[0]
for fld, val in data.items():
try:
self.setFieldVal(fld, val)
except dException.FieldNotFoundException:
# Field is not in the dataset
pass
except IndexError:
# For some reason we could not retrieve the
matching PK record
pass
</code>
Above code retrieve field values of new saved record from backend,
in case they were set by backend.
But it only works when self._nullDefaults equals True (default False).
This attribute is set in setDefaults() method but method is never
executed for non empty defaults.
As you see in setDefaults() method code, _nullDefaults equals True
only if DefaultValues bizobj property equals None,
it's mean that all fields are initialized to None value.
In other words, I can't mix default field values from framework and backend.
I can't choose that "field_1" is set to default on backend and
"field_2" in framework.
--
Regards
Jacek Kałucki
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]