Skip to content

Instantly share code, notes, and snippets.

@PirosB3
Created March 17, 2014 00:56
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/9592137 to your computer and use it in GitHub Desktop.
Save PirosB3/9592137 to your computer and use it in GitHub Desktop.
[11:20pm] jarshwah joined the chat room.
[11:23pm] timograham: PirosB3: I see it a bit differently I guess. For each class, give me the list of student IDs. Since one class doesn't have any students, we have the None value that corresponds to it. I can't find if the behavior is explicitly tested, but changing it would be backwards incompatible.
[11:24pm] PirosB3: thanks for explaining timograham
[11:24pm] PirosB3: in this particular example, the list is flattened
[11:25pm] PirosB3: if a class doesn't have any students, shouldn't it return an empty list?
[11:26pm] timograham: I suppose you could argue that
[11:27pm] PirosB3: with a None being possible with values_list, it makes developer's lives more difficult, as they need to check when iterating over the list. But I perfectly understand the backwards compatibility issues
[11:29pm] timograham: Yes I see, would be helpful if you could add that to the ticket. We can see what others say (Anssi is likely to have some insight) and whether or not changing it will break tests.
[11:30pm] PirosB3: sure. thansk
[11:32pm] PirosB3: timograham: also, a question regarding GSoC. I am really struggling with regards to the meta task. I am looking at tickets, tracking information, but I am not quite sure I am getting to a point that will help me formulate a proposal. Are there some specific parts I should be looking at? and are there features that the community would like to see? thanks
[11:34pm] garrypolley left the chat room. (Ping timeout: 246 seconds)
[11:35pm] timograham: PirosB3: I don't think there are any secrets here. Anything we have would be linked from the wiki page.
[11:35pm] PirosB3: oh no!
[11:46pm] PirosB3: timograham: I was thinking, are we sure it's not backwards compatible? it would be that way if we were introducing the possibility of having None in the results
[11:46pm] freakboy3742: PirosB3: We were going to hook up on Friday to discuss GSoC, but I didn't see you around
[11:47pm] freakboy3742: do you still have questions?
[11:47pm] PirosB3: in this case, we are only cleaning removing falsy values
[11:48pm] PirosB3: hi freakboy3742, I was online on thursday I think
[11:48pm] freakboy3742: Yeah - that was when you pinged me, and I said wine+cheese != good answers
[11:48pm] PirosB3: I was actually asking around regarding meta, and I was lucky to have loads of people answer, so for this reason I did not bug you
[11:48pm] freakboy3742: Righto - as long as you've made progress
[11:48pm] PirosB3: sorry I mean friday
[11:49pm] PirosB3: freakboy3742: I have made some progress, but still I am very concerned
[11:49pm] PirosB3: I want to come up with a robust idea
[11:49pm] freakboy3742: Anything I can help with?
[11:49pm] PirosB3: sure, I'll get my doc
[11:50pm] PirosB3: so I have started identifying "groups" of components
[11:50pm] freakboy3742: When you say "component" what exactly do you mean in that context?
[11:50pm] PirosB3: aha right, I name everything a component
[11:51pm] PirosB3: let's say behavours
[11:51pm] freakboy3742: Ok
[11:51pm] PirosB3: so for example
[11:51pm] PirosB3: there are some components that relate to the model's fields
[11:52pm] PirosB3: others deal with relations (many to many)
[11:52pm] PirosB3: there are also components within these components
[11:52pm] PirosB3: such as common caching patterns
[11:52pm] PirosB3: so step 1 would be to actually create an abstraction of what Object is currently
[11:53pm] freakboy3742: Are you talking an actual software abstraction, or a conceptual/documentation abstraction?
[11:53pm] PirosB3: both, with software comes documentation
[11:53pm] PirosB3: also, I have found some interesting tickets
[11:54pm] PirosB3: that relate to some parts that could be added in meta
[11:54pm] PirosB3: more than one popular ticket was regarding having other non-django metadata
[11:55pm] freakboy3742: hang 5 - just got a phone call.
[11:55pm] PirosB3: 'class Meta' got invalid attribute(s) <-- many results on Google
[11:55pm] PirosB3: sure no worries! I will continue writing
[11:56pm] PirosB3: This ticket actually finished like this, and I do not know what this means: https://code.djangoproject.com/ticket/5793
[11:57pm] PirosB3: there are also other tickets, that I did not understand perfectly, if you could share your knowledge that would be amazing. https://code.djangoproject.com/ticket/21682
[11:58pm] PirosB3: finally, there is this blog post that was very interesting. I was thinking, could we take advantage from this document to understand what the community would want more? http://mhall119.com/2011/02/fun-with-django-meta-classes-and-dynamic-models/
[11:59pm] PirosB3: also, final idea. I was thinking of sending a poll out on the mailing list. It would be short and it would ask what they would actually want from Meta..
[12:00am] freakboy3742: PirosB3: Ok - back for a bit; might get another call in a moment.
[12:00am] PirosB3: nw
[12:00am] freakboy3742: #5793 is about allowing end users to put their own attributes on Meta.
[12:00am] ticketbot: https://code.djangoproject.com/ticket/5793
[12:00am] freakboy3742: It's not a huge use case, but it does come up occasionally.
[12:01am] freakboy3742: As an example - Django's swappable user model would have been able to make use of it, if it existed.
[12:01am] PirosB3: yes, you say it wouldn't be something interesting to have
[12:01am] PirosB3: oh yes, that does make sense
[12:01am] freakboy3742: REQUIRED_FIELDS and USERNAME_FIELD are probably better suited as Meta attributes
[12:01am] PirosB3: what are your thoughts about this? do you think it would be a good idea
[12:02am] freakboy3742: Yes - as I said on the ticket, it's something that might be useful under certain circumstances.
[12:02am] PirosB3: we could have custom meta classes, where you have required attributes
[12:02am] freakboy3742: The biggest hurdle is the thing that ubernostrum originally used to knock the ticket down - that the api of Meta is undocumented and internal
[12:02am] freakboy3742: but… if we're fixing *that*, then all things are back on the table
[12:02am] PirosB3: exactly
[12:02am] freakboy3742: Ok - as for #21682
[12:02am] ticketbot: https://code.djangoproject.com/ticket/21682
[12:03am] PirosB3: what do you think about all the things I said previously? do they make sense?
[12:03am] PirosB3: if they do, how can we keep backwards compatibility?
[12:04am] freakboy3742: I haven't read the blog post you reference, so I'd need to dig into that
[12:05am] freakboy3742: As for a poll/vox pops - I'm not so convinced that will yield anything especially useful
[12:05am] freakboy3742: It might, but just because people want it, doesn't mean it's a good idea
[12:06am] PirosB3: also, I have all these thoughts but not what a solid idea for a good api would look like
[12:06am] freakboy3742: Also, Django design tends to be focussed on things where there is a clear and pressing need, rather than "looking for trouble"
[12:06am] PirosB3: mmm
[12:06am] freakboy3742: If you're looking for a pressing need, the USERNAME_FIELD etc bits would be a good example.
[12:07am] dlogs left the chat room. (Remote host closed the connection)
[12:07am] dlogs joined the chat room.
[12:07am] freakboy3742: if you can find a way to make *that* work in a clean fashion, you'll probably have other use cases under control
[12:07am] PirosB3: but how would I handle backwards compatibility
[12:08am] PirosB3: surely there will be lots of issues
[12:08am] freakboy3742: Well, if you're adding a new feature, there's no backwards compatibility to consider.
[12:08am] PirosB3: ok
[12:09am] freakboy3742: But as for everything else - if it works now, it needs to work after you've stopped fiddling
[12:09am] PirosB3: I understand how meta is used under the hood, obviously not everything
[12:09am] freakboy3742: unless you can come up with a compelling reason why the API is fundamentally flawed as designed.
[12:09am] freakboy3742: The thing is - meta is officially internal API, so it's not covered by backwards compatibility
[12:10am] freakboy3742: *but* it's as close to "unofficially official" as you can get
[12:10am] PirosB3: but how can I understand what people want
[12:10am] freakboy3742: Mostly, what people want is for the API that is there to be documented and official.
[12:10am] freakboy3742: However, we've been hesitant to do this because the API is messy
[12:11am] freakboy3742: so - the Meta project is really about turning the ad-hoc API that is actually there
[12:11am] freakboy3742: into something that we won't be ashamed to look at when we publish a formal API
[12:11am] freakboy3742: If that means making a couple of strategic changes, then that's fine
[12:12am] freakboy3742: preferably in a backwards compatible way, but if we can't avoid changes, then we make them in the least impactful way possible.
[12:12am] PirosB3: I understand
[12:12am] freakboy3742: it might also mean slowly deprecating certain entry points
[12:12am] PirosB3: what is the most common use for people using Meta now?
[12:13am] PirosB3: unofficially
[12:13am] freakboy3742: Implicit usage through modelforms and admin
[12:13am] freakboy3742: hang 5 -= phone again
[12:13am] PirosB3: ok
[12:14am] dfunckt left the chat room.
[12:14am] timograham left the chat room.
[12:18am] Zifre joined the chat room.
[12:19am] freakboy3742: PirosB3: Back again
[12:19am] PirosB3:
[12:19am] freakboy3742: Yeah - so most of the usage is implicit. Modelforms and admin are what use Meta the most
[12:19am] freakboy3742: so *those* need to keep working as expected.
[12:20am] PirosB3: most of the things I see people are using
[12:20am] freakboy3742: Others use it too; mostly for things like get_field and get_related_fields et al
[12:20am] PirosB3: are documented
[12:20am] freakboy3742: the "obvious" apis for a meta object to have
[12:20am] freakboy3742: Really? Where?
[12:20am] PirosB3: others such as get_field are still used, but less
[12:20am] freakboy3742: Meta isn't documented at all AFAIK
[12:20am] PirosB3: what I mean by documented, is that there is a clear use of it in the documentation
[12:21am] freakboy3742: That surprises me - can you point me at an examle?
[12:21am] PirosB3: what I mean is this https://docs.djangoproject.com/en/1.5/topics/forms/modelforms/#modelform
[12:21am] freakboy3742: Ah - right
[12:21am] PirosB3: class Meta is then initialized
[12:22am] freakboy3742: Right - that's the public definition of what fields you can put on Meta
[12:22am] PirosB3: and _meta is made
[12:22am] freakboy3742: the API on a _meta object isn't documented, though
[12:22am] PirosB3: ok now I understand
[12:22am] freakboy3742: so "you need to put model=Article on your Meta object" is documented, but "this gives you _meta.get_field()" isn't.
[12:23am] PirosB3: yep! now I am understanding more of what you are actually looking for
[12:23am] PirosB3: but will the field be still called _meta?
[12:23am] PirosB3: even though it will become public?
[12:23am] freakboy3742: I think that's inevitable
[12:23am] freakboy3742: Unless you can propose a transition plan, I think that name is going to stick
[12:23am] freakboy3742: And honestly, I don't think it matters that much.
[12:24am] freakboy3742: Even if it is public API, it's not something you should be poking around with unless you know what yore doing.
[12:24am] freakboy3742: So - the other piece that might be worth adding to a proposal
[12:24am] PirosB3: sure, so it will be only used by people that know what they are doing
[12:24am] freakboy3742: It's all well and good to document an API
[12:24am] freakboy3742: but it's ideal to have a proof of concept
[12:24am] freakboy3742: i.e., prove that your API is actually complete and correct.
[12:25am] freakboy3742: One interesting way to do this - write an alternate implementation.
[12:25am] freakboy3742: Here's the thought: The reason _meta exists is so that ModelForms can build a form for an arbitrary Djangoi model.
[12:25am] PirosB3: yep
[12:25am] freakboy3742: But provided the data is the same, there's no reason it needs to be a Django model
[12:25am] freakboy3742: it could be a MongoDB model, or an Email, or an LDAP system
[12:26am] PirosB3: aha! sure
[12:26am] freakboy3742: so - write a wrapper for an alternate data store that is "meta compliant"
[12:26am] PirosB3: now I understand that comment I had
[12:26am] freakboy3742: and prove that you can build a model form for that data store
[12:26am] freakboy3742: or drop that data object into Admin.
[12:27am] PirosB3: so basically by modifying meta, I will be able to make my Mongo store interact with forms and admin in the same way
[12:27am] PirosB3: as it does with db.models.Model
[12:27am] freakboy3742: That's the idea, yes.
[12:27am] PirosB3: so this is making a private api public
[12:27am] freakboy3742: There might be some other bits and pieces (eg., explicit is instance checks) that need to be broken as well, but that's the theory.
[12:27am] PirosB3: still this means there is stuff that should not be exposed
[12:27am] freakboy3742: Like what?
[12:28am] PirosB3: what I am thinking
[12:28am] PirosB3: is an api in front of the already existing meta
[12:28am] freakboy3742: No - I don't think another abstraction layer is needed.
[12:29am] freakboy3742: We just need to be clear about what is public, and what isn't.
[12:29am] PirosB3: yes, that is what I mean by there is stuff that should not be exposed
[12:29am] PirosB3: and how can I find that out?
[12:29am] freakboy3742: Well, this is python, so it's exposed whether you like it or not
[12:29am] freakboy3742: it's just down to what we formally guarantee won't change.
[12:30am] PirosB3: very true, it's only up to the documentation
[12:30am] freakboy3742: And finding out what shouldn't be exposed is the subject of the project
[12:30am] PirosB3: ahah
[12:30am] freakboy3742: as in - we need you to formalise the "this is the minimum working set"
[12:30am] PirosB3: freakboy3742: are you Rusell?
[12:30am] freakboy3742: Russell, but yes
[12:30am] PirosB3: oops! aaah that explains everything
[12:31am] garrypolley joined the chat room.
[12:31am] PirosB3: so you are the one I am supposed to pitch
[12:31am] freakboy3742: I'm the most likely to mentor the project, yes
[12:31am] PirosB3: great
[12:32am] PirosB3: now I understand more about some of the comments that were made on the ML
[12:32am] PirosB3: about the duck
[12:32am] freakboy3742: Quack
[12:32am] PirosB3: ahah
[12:32am] PirosB3: so I am thinking of handling this in the following way
[12:33am] PirosB3: 1) look at other implementations: django-mongodb and anything similar to that
[12:33am] edbaffei left the chat room. (Quit: edbaffei)
[12:33am] freakboy3742: Don't get *too* distracted by the mongo thing
[12:33am] PirosB3: I am sure they are modifying meta to provide forms and admin support
[12:33am] freakboy3742: It's just an idea
[12:33am] freakboy3742: Honestly, a wrapper around an email inbox would be just as viable.
[12:34am] freakboy3742: If you don't already know mongo, don't think that this project won't get picked up unless it supports mongo
[12:34am] freakboy3742: The mongo bit won't ever be committed to trunk - it's an entirely external proof of concept
[12:34am] PirosB3: no not at all, but it will in any case make me understand more about what people are using meta for
[12:34am] freakboy3742: and possibly a project where you may end up being the maintainer.
[12:34am] freakboy3742: That's the idea.
[12:34am] PirosB3: ok
[12:35am] PirosB3: this will also decouple admin
[12:35am] PirosB3: won't it?
[12:35am] PirosB3: because it will not be entirely tied to Django, in terms of resources
[12:35am] PirosB3: for CRUD.
[12:35am] freakboy3742: Well, ish.
[12:36am] freakboy3742: Its still going to need Django for URLs and views etc
[12:36am] freakboy3742: but yes, it decouples it from Django's Database layer.
[12:36am] PirosB3: oh yes, I mean ORM wise
[12:36am] PirosB3: yes
[12:36am] freakboy3742: It might be a little harder than that, because you need to suppose some basic query types too
[12:37am] freakboy3742: (e.g., MyModel.objects.get(pk=3)
[12:37am] PirosB3: freakboy3742: that does not use meta
[12:37am] PirosB3: it only uses meta to get attributes, but then
[12:37am] freakboy3742: No - but it is part of the bigger picture here.
[12:37am] freakboy3742: Meta by itself is an important part, but it's the start of the project.
[12:37am] PirosB3: when you say to create an email store
[12:38am] PirosB3: how will I handle that part?
[12:38am] freakboy3742: Well, Python APIs for reading mbox files are pretty good.
[12:38am] PirosB3: if I want to plug my mailing model into the admin
[12:38am] freakboy3742: so, treat that as a "model" problem
[12:38am] freakboy3742: Folder, Message, Attachment, etc.
[12:39am] freakboy3742: It definitely doesn't have a foreign key
[12:39am] freakboy3742: but there's an analogous concept
[12:39am] PirosB3: I mean with regards to actually Django wanting to execute a query
[12:39am] freakboy3742: So you call the python mail APIs to retrieve messages with a specific ID
[12:39am] freakboy3742: or folders with a specific name
[12:39am] freakboy3742: etc
[12:39am] PirosB3: Mail.objects.all()
[12:39am] PirosB3: but the query is executed externally to model, of is it not?
[12:40am] PirosB3: or
[12:40am] PirosB3: of course it is
[12:40am] freakboy3742: Well, the Mail object needs to have an objects attribute that has an all() method on it that retrieves all objects.
[12:40am] freakboy3742: None of that *needs* to be the Django ORM
[12:40am] freakboy3742: other than the fact that the Django ORM is the only implementation of all the parts required.
[12:40am] freakboy3742: So - saying "Document Meta" is a little underselling it
[12:41am] freakboy3742: it's really "Document everything you need in order to provide an alternative data backend for ModelForms and/or admin"
[12:41am] freakboy3742: Meta is an important part of this
[12:41am] freakboy3742: and it's a part that would be worthwhile whether you get the rest of the project working
[12:41am] PirosB3: it is indeed
[12:42am] freakboy3742: because it's the one "semi-official" part that we keep meaning to document, but never have the motivation to do so.
[12:43am] PirosB3: this is great, so I should start by trying to build a small propotype
[12:44am] PirosB3: using mail as an example
[12:44am] PirosB3: and have it read by admin
[12:44am] freakboy3742: That's the diea.
[12:44am] freakboy3742: s/diea/idea/
[12:44am] PirosB3: once that is working, I should have enough knowledge to propose an api
[12:44am] freakboy3742: although pick a "data store" you're comfortable with
[12:44am] freakboy3742: and think you might want to handle long term.
[12:45am] freakboy3742: (since this is your opportunity to set yourself up as a guru for some area)
[12:45am] PirosB3: long term with regarding to maintaining?
[12:45am] freakboy3742: Yeah
[12:45am] PirosB3: oh thats great!
[12:45am] vbabiy left the chat room. (Quit: Textual IRC Client: www.textualapp.com)
[12:45am] tape-recorder left the chat room. (Remote host closed the connection)
[12:45am] freakboy3742: Like I said - your testbed won't be integrated into Django core itself
[12:46am] freakboy3742: but *you* can keep maintaining it, and contributing to the API documentation inside Django
[12:46am] PirosB3: it's more than fine. I would love to have something open source
[12:46am] freakboy3742: and you'll end up as the external API expert.
[12:46am] PirosB3: I have always used open source, but I have never contributed too much. it's a shame. now is the time to change this
[12:46am] PirosB3:
[12:47am] freakboy3742: That's the spirit
[12:47am] PirosB3: when you mean testbed, you mean the entire SoC project?
[12:47am] freakboy3742: Well, there's really three pieces here.
[12:47am] PirosB3: I identified 2
[12:47am] freakboy3742: There's any tweaks and changes needed to Meta to make it a "formal worthy" API
[12:47am] freakboy3742: There's the documentation of that formal API
[12:47am] freakboy3742: and there's the external proof of concept.
[12:47am] freakboy3742: first two are Djngo contributions; third is an external project.
[12:48am] PirosB3: yep perfect inline with my idea
[12:48am] PirosB3: freakboy3742: will you be online tomorrow
[12:48am] PirosB3: ?
[12:48am] freakboy3742: Should be - I'm in UTC+8, and I'm in my office from around 7AM most days
[12:48am] freakboy3742: so - that's about 2 hours ago
[12:48am] bynaryshef joined the chat room.
[12:48am] PirosB3: ….
[12:49am] freakboy3742: It's monday here.
[12:49am] PirosB3: it's nearly 1am here
[12:49am] PirosB3: it's crazy if you think of it
[12:49am] freakboy3742: Oh, I got over timezone craziness some time ago
[12:49am] PirosB3: ahah
[12:49am] freakboy3742: So, if you're in the UK, the other option is "first thing in the morning your time"
[12:50am] freakboy3742: I'm in my office until about 4 PM or so
[12:50am] tonebot left the chat room. (Remote host closed the connection)
[12:50am] freakboy3742: so first thing in the morning your time also works.
[12:50am] PirosB3: oh okay
[12:50am] tonebot joined the chat room.
[12:50am] PirosB3: so you stay till 4pm
[12:50am] freakboy3742: My time, yes
[12:50am] PirosB3: that makes it -8 I think
[12:51am] freakboy3742: Has london started daylight saving yet?
[12:51am] freakboy3742: -8 during your winter, -7 during summer time.
[12:51am] PirosB3: nope, 30th
[12:51am] freakboy3742: Right - so -8 for the moment.
[12:51am] PirosB3: yes
[12:51am] freakboy3742: 7-8 am your time then.
[12:52am] PirosB3: freakboy3742: can I reach you by email by any chance? if I have progress that I want to share, where shall I send this?
[12:52am] PirosB3: by ML?
[12:52am] freakboy3742: The mailing list is the best bet
[12:52am] freakboy3742: I'm watching all the GSoC threads, and keeping a particular eye out for Meta-related ones
[12:52am] PirosB3: perfect
[12:52am] freakboy3742: but it's good to have this stuff out in the open, so others can comment.
[12:53am] garrypolley left the chat room. (Remote host closed the connection)
[12:53am] PirosB3: of course, the reason I am asking everyone what they would do, is to make sure it's something inline with the community
[12:53am] freakboy3742: Always a good idea
[12:54am] PirosB3: great. thank you so much for your help. I have so much more understanding of the task.
[12:54am] PirosB3: This will will be tough, 3 exams + SoC
[12:54am] freakboy3742: No worries- best of luck with your GSoC application!
[12:54am] PirosB3: I better get on it!
[12:54am] PirosB3: hear you soon
[12:55am] PirosB3: %s/will/week/g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment