/srv/irclogs.ubuntu.com/2014/09/19/#maas.txt

=== alexpilotti_ is now known as alexpilotti
=== jfarschman is now known as MilesDenver
=== jfarschman is now known as MilesDenver
=== jfarschman is now known as MilesDenver
=== jfarschman is now known as MilesDenver
=== jfarschman is now known as MilesDenver
=== jfarschman is now known as MilesDenver
=== kickinz1|afk is now known as kickinz1
=== jfarschman is now known as MilesDenver
=== CyberJacob|Away is now known as CyberJacob
=== kickinz1 is now known as kickinz1|afk
=== kickinz1|afk is now known as kickinz1
rvbajtv1: it's in /etc/maas/templates/deployment-user-data/maas_configure_interfaces.py07:16
jtv1rvba: great, thanks.  That's the expected location.07:20
jtv1I just mis-typed it earlier.07:21
rvbaAh, okay.07:21
=== kickinz1 is now known as kickinz1|afk
=== CyberJacob is now known as CyberJacob|Away
=== kickinz1|afk is now known as kickinz1
=== jfarschman is now known as MilesDenver
=== jfarschman is now known as MilesDenver
=== jfarschman is now known as MilesDenver
=== kickinz1 is now known as kickinz1|afk
=== jtv1 is now known as jtv
=== jfarschman is now known as MilesDenver
=== kickinz1|afk is now known as kickinz1
jtvrvba: can I impose on your Django knowledge?11:29
jtvI'm trying to set a computed default value for a form field.11:29
jtvWhen I clean the field in the form, it's always present and its cleaned_data value is never None.11:30
jtvThe django docs say that setting an "initial" value is not the way to do this, but they don't say what is.11:30
jtv(Even setting a callable default on the model wouldn't do the trick, because the default needs to refer to the Node object itself)11:31
rvbajtv: I don't understand why you're saying that the field is always present and that its cleaned_data value is never None.  Is that a result of something you've done?11:32
rvbajtv: why can't you set your default value in the form's __init__?11:34
jtvCould be.  When my clean_<field> method (on the form) looks for self.cleaned_data.get(<field>) it never gets None back.11:34
jtvSet it in the form's __init__?  Do I have the instance at that point, when the form is creating a new object?11:34
rvbaNo, unless you create it yourself manually, then *update* it when save() is called.11:35
rvbaSo, you want the initial value to depend on a non-yet created object?11:35
rvbaI don't understand.11:35
jtvThis is NodeForm; all I really need is its NodeGroup.11:36
jtvIf I can get that, I can get the default value.11:36
rvbaThen presumably you want to pass the nodegroup to the form's __init__ and derive the default value from it.11:37
rvbaSame as what NodeGroupDefineForm does with 'status'.11:38
=== jfarschman is now known as MilesDenver
jtvrvba: so... overriding save() looks like the only way to set a computed default with access to the object's properties..?11:41
rvbajtv: yes, save() is where the object is created by the form.11:41
rvbajtv: but surely the data you need (the nodegroup) is part of the data sent to the form?11:42
jtvProbably, yes.  I'm more worried at this stage about how I'll know whether a value was submitted for my field.11:43
rvbajtv: if no value was submitted for the field, cleaned_data should be set to the default value.11:46
rvbacleaned_data.get(field_name) that is11:46
jtvThe default _model_ value?11:46
jtvWell stupid question I guess,11:47
jtvsince there doesn't seem to be a default form value.11:47
jtvI guess I'd have to make the model-level field default to None, but disallow nulls?11:48
rvbaYes, I assume the default model value is there when the form gets validated.11:49
rvbaI don't think you need to make the model-level field default to None.11:50
jtvWell it's a boolean field that can't be null, and I need a way to know whether a value was provided to the form...11:53
jtvI get the impression that the model is the only level where I can provide a default.11:54
jtv(Unless we count "initial" which the docs say won't do this.)11:54
* jtv eats for a bit11:54
* rvba → lunch11:56
=== jfarschman is now known as MilesDenver
jtvArrrrrgh!  My problem was in factory.make_NodeGroup accepting my new field but not passing it on!12:42
jtvThat's why my test failed: the default was always False, even if I explicitly set it to True.12:44
jtvQuestion now is: at what point in all my experiments did the test start failing for that reason?12:44
jtvUrgh.  That's enough for tonight.  Have a good weekend everyone.13:07
=== kickinz1 is now known as kickinz1|afk
=== jfarschman is now known as MilesDenver
=== allenap_ is now known as allenap
=== jefferai__ is now known as jefferai_
=== roadmr_ is now known as roadmr_afk
=== CyberJacz is now known as CyberJacob
=== roadmr_afk is now known as roadmr
=== roadmr is now known as roadmr_afk
=== roadmr_afk is now known as roadmr
=== jfarschman is now known as MilesDenver
=== jfarschman is now known as MilesDenver
=== alexpilotti_ is now known as alexpilotti
=== alexpilotti_ is now known as alexpilotti

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!