>> hi >> 1st one: i am saving some object; the mapperExtension of the object >> fires additional atomic updates of other things elsewhere >> (aggregator). >> These things has to be expired/refreshed... if i only knew them. >> For certain cases, the object knows exactly which are these target >> things. How (when) is best to expire these instances, i.e. assure that >> nexttime they are used they will be re-fetched? >> a) in the mapperext - this would be before the flush? >> b) later, after flush, marking them somehow ? >> > > the "public" way to mark an instance as expired is > session.expire(instance). if you wanted to do this inside the mapper > extension, i think its OK as long as you do the expire *after* the > object has been inserted/updated (i.e. in after_insert() or > after_update()). > ok i'll go this way then. > We also have the capability to mark any group of attributes as > expired. however I havent gotten around to building a nice public API > for that, though i can show you the non-public way if you want to play > with it. This API is used by the mapper after it saves your instance > to mark attribues which require a post-fetch. > > What I'd like to do, and this has been frustrating me a bit, is to > bring the "expire the whole instance", "expire a group of attributes", > "reload a group of attributes", and "reload an instance" under one > implementation umbrella - right now theres some repetition in there > among Mapper, Query._get() and DeferredColumnLoader. I've sort of > wanted to address the whole thing at once. > hmm, these seems to me like one
def reload( instance, later=False, attribs= ()): ... with later=True meaning expire(), and non-empty attribs meaning "only these". but then this is generalizing the API not the implementation... >> and, why atomic updates also have with commit after them? or is this >> sqlite-specific? >> > every CRUD operation requires a commit. DBAPI is always inside of a > transaction. > mmm i mean i have bunch of inserts and updates without a commit, and then several atomic updates come with their own commits. and then one more commit at the end. e.g. * SA: INFO BEGIN * SA: INFO UPDATE "SequenceCounter" SET "curNum"=? WHERE "SequenceCounter".db_id = ? * SA: INFO [2, 8] * SA: INFO INSERT INTO "Nalichnost" (kolvo_kym, cena, obj_id, data_godnost, sklad_id, disabled, time_valid, kolvo_ot, stoka_id, time_trans) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) * SA: INFO ['0', '978', None, None, 3, 0, None, '0', 1, None] * SA: INFO INSERT INTO "Nalichnost" (kolvo_kym, cena, obj_id, data_godnost, sklad_id, disabled, time_valid, kolvo_ot, stoka_id, time_trans) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) * SA: INFO ['0', '94', None, None, 3, 0, None, '0', 1, None] ... * SA: INFO INSERT INTO "DocItem" (kolichestvo, data_godnost, sk_ot_id, number, sk_kym_id, opisanie, cena, stoka_id, doc_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) * SA: INFO ['702', None, None, 3, 5, None, '668', 1, 2] * SA: INFO INSERT INTO "DocItem" (kolichestvo, data_godnost, sk_ot_id, number, sk_kym_id, opisanie, cena, stoka_id, doc_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) * SA: INFO ['422', None, None, 4, 6, None, '17', 1, 2] * SA: INFO UPDATE "Nalichnost" SET kolvo_ot=(coalesce("Nalichnost".kolvo_ot, ?) + ?) WHERE "Nalichnost".db_id = ? * SA: INFO [0, 643, 4] * SA: INFO COMMIT * SA: INFO UPDATE "Nalichnost" SET kolvo_kym=(coalesce("Nalichnost".kolvo_kym, ?) + ?) WHERE "Nalichnost".db_id = ? * SA: INFO [0, 643, None] * SA: INFO COMMIT * SA: INFO UPDATE "Nalichnost" SET kolvo_ot=(coalesce("Nalichnost".kolvo_ot, ?) + ?) WHERE "Nalichnost".db_id = ? * SA: INFO [0, 702, 5] * SA: INFO COMMIT * SA: INFO UPDATE "Nalichnost" SET kolvo_kym=(coalesce("Nalichnost".kolvo_kym, ?) + ?) WHERE "Nalichnost".db_id = ? * SA: INFO [0, 702, None] * SA: INFO COMMIT * SA: INFO UPDATE "Nalichnost" SET kolvo_ot=(coalesce("Nalichnost".kolvo_ot, ?) + ?) WHERE "Nalichnost".db_id = ? * SA: INFO [0, 9, 3] * SA: INFO COMMIT * SA: INFO COMMIT --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---