|
osdir.com mailing list archive |
|
Subject: Re: Using an inner class for custom Manager in magic removal branch - msg#00215List: python.django.devel[current sample with defined classes and used objects] >The above feels a little clumsy to me. Here's my proposed alternative: [sample with inner class] Uhm - in what way is nowadays defining classes and using them "clumsy"? Thought that's what OO is all about. The beast is named "removing the magic" for a good reason, so why throw in another "magic" (one that turns a scoped class definition into a - differently named! - attribute)? And why should we do a full round again on the discussion about wether we want managers the way we already decided in the previous round to have them? Actually this discussion sounds clumsy ;-) Sorry, but I am -1 on this change. Several reasons: - multiple managers make it possible to have different ways to access your data. Don't just think "multiple managers to the same storage" as it is now, think "multiple managers to different - maybe even technically different - storages". One thing I can see done with multiple managers would be a way to define managers that link to specific databases and so have a model definition where you have one manager attaching to your PostgreSQL database and another attaching to your RDF storage. - managers that are decoupled from the model class could be reused in multiple models. For example I have a model with four quite similar tables - even though they carry different payload, they do carry similar basic structure for identification. They could definitely share the same manager definition that would just do basic selecting (like limiting to objects from the current site). - constructed managers become possible due to the fact that instantiation is explicit - you could have your manager class accepting parameters in its __init__ and so parameterized a shared manager definition (or used multiple but differently parameterized instances of the same manager class). Oh, and I strongly dislike the handling of an attribute named 'objects' you propose. That's backwards into the discussion we already had. This "you have to rename your attribute objects_ because we clobber your namespace and won't allow you to reclaim it" felt like a hack to me then and feels like a hack to me now. I am definitely -1 (it's more like -2, if that would exist) on changing that to your proposal. The current idea of explicitely instantiating and naming managers is much cleaner. Actually in simple cases you won't have to instantiate managers at all - there will be a default manager created behind the scenes, IIRC. It's just needed in those cases where you _do_ need explicit managers. And one really typical scenario would be a situaiton where someone has a basic relation in all his tables that should be filtered - like for example ManyToMany relations to the Sites table. In that case you set up one manager class that adds that filter and just use that manager class in your models. This scenario would be much clumsier with having to define a inner class - you would have to subclass the shared manager class in every inner class of the model. And sorry, but stub inner classes that magically instantiate attributes with a different name just look clumsier to me than simple attribute assignements where you use the exact same named attribute as you assigned ... bye, Georg
Thread at a glance:
Previous Message by Date: (click to view message preview)Re: developers neededJeroen Ruigrok van der Werven wrote: > Nikki, > > On 1/15/06, nikki <bombolalala-/E1597aS9LQAvxtiuMwx3w@xxxxxxxxxxxxxxxx> wrote: > > I kinda laughed that naively I stepped on a sore spot about choice of > > DB's but honestly it only reflect info I came accross , not an attempt > > to insult anyone - sorry John -I'm still not sure of the implication of > > my question. I know Rails supposedly works well with them all and even > > .net can work with mySql. Again thanks Adrian for taking the time I > > know in this community you are the Man - I appreciate your time > > You will find most people here are quite database agnostic, but if you > ask any DBA (database administrator) worth his/her value they will not > even consider MySQL. If you need features on an enterprise level, i.e. > compete with Oracle or Microsoft SQL Server, you will come to > PostgreSQL, not MySQL. > At one point, I am not sure they still do this, MySQL even altered > column types if it thought it would speed up the database, which is > all nice and dandy, but a death sin for any serious DBA. > > But that's digressing from what you asked. > > Depending on what you need for your installation you might even get > away from SQLite. I find this document is fairly good reading about > considerations what to use and when: > http://www.sqlite.org/whentouse.html. > > -- > Jeroen Ruigrok van der Werven Ok your take is appreciated since it is somewhat different then the common mis?understanding. The common lore on MySQL is that its good enof for Google, Yahoo, Amazon so its a contender. SQLite I'm told does not support concurrent users very well. Also I came accross this DB comparison chart as of 3/05: http://www.geocities.com/mailsoftware42/db/ which may interest you Next Message by Date: click to view message previewRe: developers neededHi Nikki, On 1/16/06, nikki <bombolalala@xxxxxxxxx> wrote: > Ok your take is appreciated since it is somewhat different then the > common mis?understanding. The common lore on MySQL is that its good > enof for Google, Yahoo, Amazon so its a contender. > SQLite I'm told does not support concurrent users very well. Haven't noticed much problems with that using Trac and SQLite. :) > Also I came accross this DB comparison chart as of 3/05: > http://www.geocities.com/mailsoftware42/db/ > which may interest you Interesting and outdated, even in March 2005. Slony-I had been announced in July 2004 as a replication software for PostgreSQL. So that chart, compiled last year, doesn't even mention that. In the end: try them all, see their features and take whatever works for you. I care about licenses so I stick to the BSDL (or similar) when I can. -- Jeroen Ruigrok van der Werven Previous Message by Thread: click to view message previewRe: Using an inner class for custom Manager in magic removal branchOn 1/14/06, Simon Willison <swillison-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx> wrote: > Basically, you define your own inner class called "Manager" if you want > to add custom methods to Person.objects (or modify the behaviour of > existing methods). If you don't define this inner class the default > Manager will be used. I can see pros and cons to this, and I think the overriding question should be how many use cases there are where you need a single manager class to serve multiple models that don't inherit from each other. I'm inclined to think there aren't enough to justify the separate manager class, and so it'd be simpler and more logical to define the manger as an inner class of the model, so I'd give it a tentative +1 barring any compelling use cases for the current system. > The current system in magic-removal enables multiple managers (you can > assign as many as you like to different properties). I don't see the > advantage in allowing this - why not just add wrapper methods to your > custom Manager inner class, or even have it use multiple inheritance to > mix in methods from multiple classes? This one I'm not so sure about; I can certainly see the advantages of multiple managers, but it'd also be awfully messy to have to define and keep track of a whole string of inner manager classes on a model. > Also up for debate is the way we handle the edge case where a model > needs to have a field called "objects". Currently we encourage people > to create their own Manager with a different name. I'm not keen on this > as it breaks user expectations - instead I think people should be > encouraged to do the following (and treat "objects" as a reserved > word): +1. -- "May the forces of evil become confused on the way to your house." -- George Carlin Next Message by Thread: click to view message previewRe: Using an inner class for custom Manager in magic removal branch> Sorry, but I am -1 on this change. Several reasons: One more point I would like to add: - Flat is better than nested Ok, so Tim Peters isn't infallible, but I think this is pretty good advice. my 2 cents MWM
Web Hosting Reviews from OSDir.com Sister Site iBizWebHosting.com
|
|