-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Oleg Broytmann wrote: > On Mon, Feb 02, 2009 at 09:39:06PM -0500, Stef Telford wrote: >> Oleg Broytmann wrote: >>> On Mon, Feb 02, 2009 at 03:07:49PM -0500, Stef Telford wrote: >>>> alias's will stay 'fixed' at webserver/framework launch .. no >>>> ? >>> Alias counter is increased on every instantiation of Alias(). >> Stupid question here .. but .. why ? (sorry, I know that this >> could be a large answer but..) > > Because SQLObject needs to generate unique alias names and a global > counter is the simplest way to do it. Think about joining a table > with itself - you need two different names for the table. >
Thanks for your time once again Oleg. but. Sorry, perhaps I am being stupid here (always a possability) but, how many self joins are we expecting in a query ? I mean to say, isn't saying 'selfName = self.__class__.__name__ + "_%d" % int(random())' good enough ? I don't know about how mySQL planner would deal with a self join on a self join .. but I can guess (eg; NOT well) so .. surely we only need to worry about -1- self join per table in any query ? and since queries are always 'stand alone' we don't have to worry about leakage to other areas/queries, why not merely chose a random number and append ? Sorry, I guess I am not grasping the fine details here.. my apologies :) >> Also, whilst I am here, a couple more stupid questions, is there >> any flag in the SQLObject which tells me if the object was >> 'created' from the database or instantiated from the >> database/cache ? I ask only because it would be -awfully- handy >> to have .. I did look at _creating but, that's not the right item >> (obviously) > > There is no and I really fail to see a difference. Why do you want > to distinguish them? > Really ? Well, in my application, there is a lot of 'house keeping' that needs to be done after a new row is created in the database, and it seems crazy to call _setattr_ if the row has been grabbed from the cache (as any call to setattr would/should invalidate the object in the cache and force a reload from the database). Think of 'completeName' .. which is simply self.firstName + " " + self.lastName. I can think of a 'good reason' to only call -that- after the initial object has been created (I know that this should be a model function which jst returns the firstName + " " + lastName but, go with me here, I am trying to keep my example simple). If there is a 'newRowInDB' flag, then I can say something like; > def _init(self, id, connection=None, selectResults=None): ''' > Overload this method if you need to do anything special ''' > SQLObject._init(self, id, connection, selectResults) if > self.newRowInDB: self.completeName = self.firstName + " " + > self.lastName memcache.put("%s_%s" % (self.__class__.__name__, > self.id)) If we -dont- have that newRowInDB flag, then any cache hit will call the _setattr_ on completeName, which will thus (potentially) invalidate the object in the cache and cause another get for SQLObject .. which will cause _setattr_ to be called... round and round we go. I think even having a flag set on self somewhere inside the _SO_finishCreate would do the trick, but, I am assuming that this is the only place that creates new objects in the db. >> Lastly (I promise) I am thinking of over-riding the >> _SO_finishCreate in the SQLObject subclass so that all database >> inserts go to the master rather than any slave. I would also have >> to override _SO_setValue and set (of course) .. any other methods >> in SQLObject that would have to be subclassed ? > > No, these seem to be enough. > Danke. Regards Stef > Oleg. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD4DBQFJiJzsANG7uQ+9D9URAtgcAJjHdYSZ4UV4fHp9UwBFqQ4A8JJ1AJ9yKfAN gT7kfXEpCT/vivcHB6u+9A== =zN9m -----END PGP SIGNATURE----- ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss