[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnumed-devel] changes to gmBusinessDBObject
From: |
Ian Haywood |
Subject: |
[Gnumed-devel] changes to gmBusinessDBObject |
Date: |
Wed, 15 Dec 2004 22:30:46 +1100 |
User-agent: |
Mozilla Thunderbird 0.8 (X11/20041012) |
Karsten suggested on IRC that gmBusinessDBObject should be used for the
new gmDemographicRecord,
I have added support for caching of 'extended' methods, heres the patch:
71c71
< import sys, copy
---
> import sys, copy, types
119a120
> self.__ext_cache = {} # the cache for extended method's
results
175c176
< try:
---
> if self._idx.has_key (attribute):
177,180c178,189
< except KeyError:
< _log.Log(gmLog.lWarn, '[%s]: no attribute [%s]'
% (self.__class__.__name__, attribute))
< _log.Log(gmLog.lWarn, '[%s]: valid attributes:
%s' % (self.__class__.__name__, str(self._idx.keys())))
< raise
gmExceptions.NoSuchBusinessObjectAttributeError, '[%s]: no attribute
[%s]' % (self.__class__.__name__, attribute)
---
> elif self.__ext_cache.has_key (attribute):
> return self.__ext_cache.has_key (attribute):
> else:
> func = getattr (self, "get_%s" % attribute, None)
> if func is None:
> _log.Log(gmLog.lWarn, '[%s]: no
attribute [%s]' % (self.__class__.__name__, attribute))
> _log.Log(gmLog.lWarn, '[%s]: valid
attributes: %s' % (self.__class__.__name__, str(self._idx.keys())))
> raise
gmExceptions.NoSuchBusinessObjectAttributeError, '[%s]: no attribute
[%s]' % (self.__class__.__name__, attribute)
> else:
> self.__ext_cache[attribute] = func ()
> return self.__ext_cache[attribute]
>
182a192,199
> func = getattr (self, "set_%s" % attribute, None)
> if func:
> if self.__ext_cache.has_key [attribute):
> del self.__ext_cache[attribute]
> if type (value) is types.TupleType:
> return func (*value)
> else:
> return func (value)
I envisage that most of the extended set_/get_ methods will be for
linking and unlinking related objects (addresses, comms, etc.), so they
will only be doing INSERT and DELETE, thus avoiding most concurrency
issues (either someone's already inserted it, or already deleted it,
which doesn't matter)
signature.asc
Description: OpenPGP digital signature
- [Gnumed-devel] changes to gmBusinessDBObject,
Ian Haywood <=