Skip to content

Instantly share code, notes, and snippets.

@PirosB3
Created March 18, 2014 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PirosB3/9611838 to your computer and use it in GitHub Desktop.
Save PirosB3/9611838 to your computer and use it in GitHub Desktop.
[9:38pm] deens joined the chat room.
[9:39pm] You left the chat by being disconnected from the server.
[9:39pm] You reconnected to the server.
[9:39pm] You rejoined the room.
[9:40pm] ArcTanSusan left the chat room. (Quit: ArcTanSusan)
[9:42pm] deens left the chat room. (Ping timeout: 252 seconds)
[9:49pm] stephenmcd left the chat room. (Quit: Leaving.)
[9:51pm] ArcTanSusan joined the chat room.
[9:56pm] claudep left the chat room.
[10:02pm] deens joined the chat room.
[10:06pm] deens left the chat room. (Ping timeout: 240 seconds)
[10:07pm] dlogs left the chat room. (Remote host closed the connection)
[10:07pm] dlogs joined the chat room.
[10:11pm] garrypolley joined the chat room.
[10:13pm] ustunozgur left the chat room. (Remote host closed the connection)
[10:20pm] PirosB3: hi freakboy3742
[10:20pm] PirosB3: are you on?
[10:33pm] timograham joined the chat room.
[10:35pm] amizya left the chat room. (Ping timeout: 255 seconds)
[10:37pm] garrypolley left the chat room. (Remote host closed the connection)
[10:38pm] seanl joined the chat room.
[10:38pm] cyberspace- left the chat room. (Remote host closed the connection)
[10:40pm] cyberspace- joined the chat room.
[10:41pm] charettes left the chat room. (Ping timeout: 255 seconds)
[10:44pm] charettes joined the chat room.
[10:44pm] charettes was granted voice by ChanServ.
[10:46pm] stephenmcd joined the chat room.
[10:46pm] kanja left the chat room. (Quit: Leaving.)
[10:46pm] jMyles left the chat room. (Read error: Connection reset by peer)
[10:50pm] edbaffei left the chat room. (Quit: edbaffei)
[10:53pm] jMyles joined the chat room.
[10:54pm] jMyles left the chat room. (Read error: Connection reset by peer)
[10:56pm] edbaffei joined the chat room.
[11:03pm] deens joined the chat room.
[11:07pm] dlogs left the chat room. (Remote host closed the connection)
[11:07pm] dlogs joined the chat room.
[11:08pm] deens left the chat room. (Ping timeout: 264 seconds)
[11:18pm] Siecje left the chat room.
[11:19pm] django-cibot: Project Django » mysql_gis,python2.7 build #4192: STILL FAILING in 31 min: http://ci.djangoproject.com/job/Django/database=mysql_gis,python=python2.7/4192/
[11:20pm] django-cibot: Project Django » mysql_gis,python3.3 build #4192: STILL FAILING in 31 min: http://ci.djangoproject.com/job/Django/database=mysql_gis,python=python3.3/4192/
[11:21pm] Siecje_ joined the chat room.
[11:24pm] jax left the chat room. (Quit: Leaving.)
[11:27pm] Arfrever left the chat room. (Ping timeout: 265 seconds)
[11:35pm] django-cibot: Project Django » mysql,python2.7 build #4192: FAILURE in 47 min: http://ci.djangoproject.com/job/Django/database=mysql,python=python2.7/4192/
[11:37pm] django-cibot: Project Django » postgis,python2.7 build #4192: STILL FAILING in 49 min: http://ci.djangoproject.com/job/Django/database=postgis,python=python2.7/4192/
[11:56pm] django-cibot: Project Django » mysql_gis,python3.2 build #4192: STILL FAILING in 1 hr 7 min: http://ci.djangoproject.com/job/Django/database=mysql_gis,python=python3.2/4192/
[11:57pm] django-cibot: Project Django » postgis,python3.2 build #4192: STILL FAILING in 1 hr 9 min: http://ci.djangoproject.com/job/Django/database=postgis,python=python3.2/4192/
[11:58pm] django-cibot: Project Django » postgis,python3.3 build #4192: STILL FAILING in 1 hr 9 min: http://ci.djangoproject.com/job/Django/database=postgis,python=python3.3/4192/
[11:58pm] django-cibot: Project Django build #4192: STILL FAILING in 1 hr 9 min: http://ci.djangoproject.com/job/Django/4192/
[11:58pm] ambv left the chat room. (Read error: Connection reset by peer)
[11:58pm] ambv joined the chat room.
[12:07am] dlogs left the chat room. (Remote host closed the connection)
[12:07am] dlogs joined the chat room.
[12:09am] kanja joined the chat room.
[12:16am] timograham left the chat room.
[12:16am] puntonim_ left the chat room. (Quit: puntonim_)
[12:18am] EvilDMP left the chat room. (Quit: EvilDMP)
[12:30am] ArcTanSusan left the chat room. (Quit: ArcTanSusan)
[12:33am] PirosB3: freakboy3742: my duck is more or less working! I'll be posting results soon
[12:34am] freakboy3742: PirosB3: Wow… that's quick
[12:34am] freakboy3742: What sort of duck did you make?
[12:34am] PirosB3: freakboy3742: for now I have count, but I now understand the mechanisms behind it
[12:34am] PirosB3: I had never used under the hood Django
[12:34am] freakboy3742: For what data source?
[12:34am] PirosB3: mongo
[12:34am] PirosB3: without using a wrapper
[12:35am] PirosB3: can I show you? on a gist?
[12:35am] freakboy3742: For sure - love to take a look
[12:36am] PirosB3: https://gist.github.com/PirosB3/9611350
[12:36am] PirosB3: PS: it's ugly. but it's just for understanding more
[12:36am] PirosB3: please tell me if i'm going in the wrong direction
[12:37am] freakboy3742: Looks to me like you've hit the nail square on the head
[12:37am] seanl left the chat room. (Ping timeout: 255 seconds)
[12:37am] freakboy3742: That's almost exactly what I would have expected to see
[12:37am] PirosB3: I am omitting a lot of very relevant parts
[12:37am] PirosB3: really, wow
[12:37am] PirosB3: so I have LOADS of questions now
[12:37am] freakboy3742: I mean - lots of detail still required, but like you said - it's just count()
[12:37am] freakboy3742: the broad direction is dead on
[12:38am] PirosB3: I have some questions
[12:38am] PirosB3: so currently, there is no way I can add a manager, that does not come from models.Manager
[12:38am] freakboy3742: Does it need to?
[12:39am] freakboy3742: I mean - the essence of duck typing as that as long as it has the same API, you're set
[12:39am] PirosB3: very true, it does for gis
[12:39am] PirosB3: freakboy3742: unfortunately there is a strict check
[12:39am] freakboy3742: Right - So, this is where your GSOC project comes in
[12:39am] freakboy3742: Do we need to introduce a base class that anyone can subclass, and do the strict check against that base?
[12:39am] freakboy3742: Can we avoid the strict check altogether?
[12:39am] PirosB3: raise AssertionError("Should never get here. Please report a bug, including your model and model manager setup.")
[12:40am] freakboy3742: Ok - so this is a design decision that will need to be made.
[12:40am] freakboy3742: However, you don't necessarily need to have an answer right now
[12:40am] seanl joined the chat room.
[12:40am] freakboy3742: For the purposes of your GSoC application, flagging that this issue exists, and that there are some known possible solutions
[12:40am] freakboy3742: that will be sufficient
[12:40am] freakboy3742: and we can flesh out details during the SoC
[12:41am] PirosB3: ok
[12:41am] FunkyBob: how brash and reckless of you, freakboy3742
[12:41am] freakboy3742: FunkyBob: Throw caution to the wind, I say! And throw some jello, too!
[12:42am] PirosB3: does ModelBase.__new__ get called at runtime? or at import?
[12:42am] freakboy3742: Import- when the models.py is imported and constructs the class.
[12:44am] PirosB3: so, you know how I can define custom managers with objects = xxx
[12:44am] PirosB3: and then that gets added_to_class
[12:44am] PirosB3: we could do the same with Meta, similarly
[12:45am] freakboy3742: Not sure I follow the logic
[12:45am] PirosB3: sorry, i'll explain better
[12:45am] amizya joined the chat room.
[12:45am] freakboy3742: Is this with a view to preserving Django's ModelBase as the base class for your own Mongo-ised model?
[12:45am] PirosB3: yes
[12:45am] PirosB3: of course
[12:45am] PirosB3: that would not need to be touched
[12:45am] PirosB3: it doesn't need to (ish)
[12:46am] PirosB3: so currently loads of components interact with the model through _meta
[12:46am] freakboy3742: (I really need to break you of your habit of calling everything a component
[12:47am] • freakboy3742 gets out his stick.
[12:47am] PirosB3: ahah, I was just about to write it again!
[12:47am] PirosB3: what should I call them?
[12:47am] freakboy3742: Depends which bit you're talking about.
[12:47am] • FunkyBob greases up the electrodes...
[12:47am] PirosB3: QuerySet, Query, Manager
[12:47am] FunkyBob: Depends on which component you're talking about
[12:47am] PirosB3: these classes
[12:47am] freakboy3742: Lots of Django subsystems use _meta
[12:48am] PirosB3: I'll call them classes
[12:48am] freakboy3742: (or ORM classes, in the cases you spoke about)
[12:48am] PirosB3: roger that
[12:48am] PirosB3: _meta is really important, it provides a way for these ORM classes to know more about the model
[12:48am] freakboy3742: Sure - but that just means the class and instance of a model need to have a _meta attribute, right?
[12:49am] freakboy3742: Barring any specific type checks, it doesn't need to be a specific type
[12:49am] PirosB3: so if we create a "public" way for people to create their own implementations
[12:49am] PirosB3: I was thinking, yes and no
[12:49am] freakboy3742: Ok - sure - I accept the premise, with a caveat:
[12:49am] freakboy3742: (and to be clear, the answer to this might be a subject for GSoC exploration too)
[12:50am] freakboy3742: Is there any reusable logic in Meta/ModelBase that *any* data model could use
[12:50am] FunkyBob: any? or most?
[12:50am] PirosB3: mmmm
[12:50am] freakboy3742: If the answer is yes, then sure, we should abstract that out and make a public API for creating your own subclasses.
[12:50am] PirosB3: soso
[12:50am] PirosB3: it is still tied a bit
[12:50am] freakboy3742: If not, then why not just treat it as a duck, and break any type-specific checks.
[12:51am] ambv left the chat room. (Quit: sys.exit(0) # computer went to sleep)
[12:51am] PirosB3: wait, sorry I didn't get the question entirely
[12:51am] PirosB3: Meta is 99% abstractable
[12:51am] PirosB3: _meta
[12:52am] PirosB3: BaseModel, I am not entirely sure
[12:52am] PirosB3: most of the fields in Meta can be used for anything
[12:53am] PirosB3: obviously, whatever is plugged in needs to be CRUD
[12:53am] PirosB3: but that's up to the developer
[12:53am] freakboy3742: Sure - but "get_all_related_fields" is going to depend pretty heavily on what's on the model, and the type of model it is, right?
[12:53am] andrewgodwin left the chat room. (Ping timeout: 264 seconds)
[12:53am] syphar left the chat room. (Ping timeout: 264 seconds)
[12:55am] PirosB3: get_all_related_objects?
[12:56am] syphar joined the chat room.
[12:56am] garrypolley joined the chat room.
[12:56am] PirosB3: freakboy3742: sure, but we can provide a way for the developer to override this
[12:57am] PirosB3: currently meta is made to work perfectly with BaseModel
[12:57am] freakboy3742: Right - so that's what I was trying to establish - is there *actually* common base logic, or is it "base logic, but then you have to override everything"
[12:57am] freakboy3742: Essentially, I'm not beholden to OO as a design motif.
[12:58am] freakboy3742: Having a common base class isn't an absolute requirement here
[12:58am] freakboy3742: Having a replacement that is functionally equivalent is what matters.
[12:58am] PirosB3: sure
[12:58am] freakboy3742: If having a base class makes this easier, then great; but don't start by assuming that a base class is required.
[12:58am] PirosB3: my idea behind the base class, was mainly for other developers
[12:58am] edbaffei left the chat room. (Quit: edbaffei)
[12:59am] freakboy3742: Well, in this case *you* are the "other developer". You're building the mongo wrapper. Would having a base class make your life easier? Then create one.
[12:59am] PirosB3: ahah
[12:59am] PirosB3: that makes perfect sense
[12:59am] PirosB3: very very true
[01:00am] PirosB3: so we should not have a base class, not needed
[01:00am] PirosB3: but we should have all the functions required by the other ORM classes documented
[01:00am] PirosB3: so this would mean
[01:01am] andrewgodwin joined the chat room.
[01:01am] andrewgodwin was granted voice by ChanServ.
[01:01am] PirosB3: 1) define some public functions, try to couple as much as we can
[01:01am] PirosB3: instead of having
[01:01am] PirosB3: def get_related_many_to_many_objects and get_all_related_many_to_many_objects
[01:02am] PirosB3: def get_related_many_to_many_objects(many=False) is necessary
[01:02am] PirosB3: 2 functions in 1, simpler life
[01:02am] freakboy3742: That's the idea - the API we have has… evolved
[01:02am] freakboy3742: so before we formalise it, lets clean it up
[01:02am] PirosB3: exactly
[01:02am] PirosB3: so, this would mean
[01:03am] PirosB3: 1) define an API
[01:03am] PirosB3: 2) refactor meta, to comply to that API
[01:03am] tonebot left the chat room. (Remote host closed the connection)
[01:03am] PirosB3: freakboy3742: would you see developers overriding Options, or creating a new class?
[01:04am] tonebot joined the chat room.
[01:04am] PirosB3: for example, in meta there is a lot of caching
[01:04am] freakboy3742: Again - depends how much is truly reusable.
[01:04am] PirosB3: we need to ensure, other developers have an excellent way of accessing those caching functions
[01:04am] freakboy3742: Exactly
[01:05am] PirosB3: so, after defining the API, we also need to define common, reusable functionality
[01:05am] freakboy3742: So - if we can structure this in such as way that all the end user needs to write is (say) get_all_fields, and all the others are auto cached as a result of a subclass
[01:05am] rozwell left the chat room. (Ping timeout: 240 seconds)
[01:05am] freakboy3742: then I'd call that a win, and a definite argument for having the base class.
[01:05am] PirosB3: mmm
[01:05am] PirosB3: what if we provide decorators
[01:06am] PirosB3: easy and unobtrusive
[01:06am] freakboy3742: Also an option.
[01:06am] PirosB3: but would they have the control they need?
[01:06am] freakboy3742: Don't know. Haven't given it enough thought.
[01:06am] freakboy3742: So - putting focus back on immediate problems
[01:06am] freakboy3742: you don't need to solve all these problems for your GSoC application.
[01:07am] dlogs left the chat room. (Remote host closed the connection)
[01:07am] PirosB3: really?
[01:07am] freakboy3742: Oh, no.
[01:07am] dlogs joined the chat room.
[01:07am] PirosB3: isn't this required as cleaning up meta?
[01:07am] jMyles joined the chat room.
[01:07am] freakboy3742: This is a big piece of work. You don't need a 100% finished design before you submit your application
[01:07am] PirosB3: freakboy3742: what would you suggest me to do
[01:08am] freakboy3742: So - your application needs to demonstrate that you have 12 weeks worth of work to do, that you understand the broad scope of the problem, and that you have a plan for getting to the end point that is believable.
[01:08am] freakboy3742: You don't (necessarily) need to have a finished design.
[01:09am] freakboy3742: But you *do* need to have a high level idea of what sort of decisions your going to have to make, and the impact those decisions are going to have on your overall schedule.
[01:09am] PirosB3: ok
[01:09am] freakboy3742: Over the course of the bonding period, and then the 12 weeks of the GSoC, we'll flesh out the fine details.
[01:09am] freakboy3742: Plus - once you're in the weeds, I guarantee all sorts of little things will pop up
[01:09am] PirosB3: in what areas do you think I am currently lacking?
[01:10am] freakboy3742: Honestly - about the only thing you're lacking is an actual on-paper draft application
[01:10am] garrypolley left the chat room. (Remote host closed the connection)
[01:10am] freakboy3742: The level of though that's gone into stuff so far is excellent - easily the best I've seen for this round of GSoC.
[01:10am] PirosB3: wow! amazing
[01:10am] PirosB3: but there is still a lot of work to do
[01:11am] freakboy3742: Oh - for sure
[01:11am] PirosB3: if I get a proposal for tomorrow, draft
[01:11am] garrypolley joined the chat room.
[01:11am] PirosB3: would you mind reviewing it
[01:11am] PirosB3: I'll post it on the ML
[01:11am] PirosB3: so everyone can review it
[01:11am] freakboy3742: Absolutely.
[01:11am] PirosB3: also, should I refactor the Duck?
[01:12am] syphar left the chat room. (Ping timeout: 240 seconds)
[01:12am] andrewgodwin left the chat room. (Ping timeout: 255 seconds)
[01:12am] freakboy3742: I wouldn't worry too much about that for the moment. It's worth referencing in your application as a proof that you know how to write code, and you got a quick and dirty implementation of 1% of the solution working.
[01:12am] PirosB3: also freakboy3742 I have some questions regarding other things that came along
[01:13am] PirosB3: we need to define an aim
[01:13am] freakboy3742: Ok - I need to dash soonish - my work day is starting, and work people are starting want my attention
[01:13am] PirosB3: why are we doing this? what are we enabling other developers to do?
[01:13am] PirosB3: oh sorry, leave when you want
[01:13am] freakboy3742: Non-Django models in Admin.
[01:13am] freakboy3742: that's the top sheet for me.
[01:13am] PirosB3: so that mean
[01:14am] freakboy3742: Mongo DB model displayed and used in Django's admin.
[01:14am] andrewgodwin joined the chat room.
[01:14am] andrewgodwin was granted voice by ChanServ.
[01:14am] PirosB3: Non-Django models is made up of 2 things
[01:14am] freakboy3742: With a view to it being possible to integrate other data stores
[01:14am] PirosB3: (up till now)
[01:14am] PirosB3: 1) Meta
[01:14am] PirosB3: 2) Persistence
[01:14am] PirosB3: how are we going to deal with the latter=?
[01:14am] freakboy3742: Not sure I follow
[01:15am] freakboy3742: Are you talking about how you save data back to your data store?
[01:15am] garrypolley left the chat room. (Ping timeout: 252 seconds)
[01:15am] PirosB3: we are giving the developers the tools to use Non-Django models
[01:15am] PirosB3: exactly
[01:15am] PirosB3: it makes sense to closely look at that
[01:15am] freakboy3742: Right - that's all just part of the API. Essentially, save(), maybe update() as well
[01:16am] syphar joined the chat room.
[01:16am] freakboy3742: Put it this way - what's the minimum you need to get an admin CRUD view of a Mongo model.
[01:16am] PirosB3: but not for complex query
[01:16am] PirosB3: django admin can do complex queries
[01:16am] freakboy3742: Sure - but only if you let it.
[01:16am] freakboy3742: Basic "List of all objects" stuff just needs .all()
[01:16am] PirosB3: yes, sure
[01:16am] freakboy3742: I'm entirely comfortable saying "Admin, with caveats"
[01:16am] freakboy3742: as long as we know what those caveats *are*
[01:16am] PirosB3: but shouldnt implementation be flexible
[01:17am] freakboy3742: For sure - but we dont' need to solve all the problems.
[01:17am] PirosB3: ok, what if we also add a way for developers to extend that?
[01:17am] freakboy3742: If we get a proof of concept admin for the end of GSoC, I'd be over the moon.
[01:17am] PirosB3: developers already do it, like meta
[01:17am] brodie left the chat room. (Quit: leaving)
[01:17am] PirosB3: but an "official" way
[01:18am] freakboy3742: I haven't seen any examples of MongoDB in Django admin, other than using non-rel
[01:18am] freakboy3742: which is effectively a fork of Django
[01:18am] PirosB3: so in this way, we can have: Meta + Persistence
[01:18am] PirosB3: really??
[01:18am] PirosB3: wow, I thought they had overrided Query and Compiler
[01:18am] PirosB3: that's what I was doing
[01:18am] PirosB3: I don't know if it's correct
[01:19am] freakboy3742: Put it this way - the approach they've taken isn't going to get into Django's core.
[01:20am] freakboy3742: (at least, not as I've seen it, and/or had explained to me)
[01:20am] freakboy3742: How your project differs is that we're documenting the internals so that it's a stable API
[01:20am] freakboy3742: so end-users can do whatever they want
[01:20am] PirosB3: ok
[01:20am] freakboy3742: I've really got to go now - I look forward to seeing your proposal on the ML
[01:21am] PirosB3: ok last thing
[01:21am] PirosB3: should I document this last bit regarding Persistence
[01:21am] PirosB3: ?
[01:21am] PirosB3: in the proposal?
[01:21am] PirosB3: sorry if your running late
[01:21am] freakboy3742: I think yes, but as far as the proof of concept is concerned, I'm happy if this needs to go at the end.
[01:21am] PirosB3: ok file
[01:22am] PirosB3: fine
[01:22am] PirosB3: thanks
[01:22am] freakboy3742: If you feel that you're only going to get as far as the R in CRUD for this project, that's fine.
[01:22am] PirosB3: have a nice day
[01:22am] freakboy3742: you too!
[01:22am] PirosB3: i'm going to bed actually
[01:22am] PirosB3: hear you tomorrow, looking forward to discuss again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment