IRC log of #zope3-dev for Monday, 2006-07-17

*** SteveA has quit IRC00:01
*** d2m has joined #zope3-dev00:17
*** jhauser has quit IRC00:25
*** rocky has quit IRC00:59
*** SmokeyD has joined #zope3-dev01:02
SmokeyDhi all, maybe a very stupid question, and if so, I'm sorry, but where can I find info abount the getattr and setattr methods? I am trying to figure out when they are exactly called01:03
SmokeyDthey seem to be called also on contained objects when listing of their container object is created01:04
SmokeyDis that true?01:04
philiKONgetattr / setattr are python builtins01:05
SmokeyD__getattr__ of course then, but why __setattr__01:05
SmokeyDok that's why01:05
SmokeyDI couldn't find info in zope01:05
SmokeyD:)01:05
philiKONah, you mean __getattr__01:05
philiKONyeah, read about the python object api01:05
SmokeyDno01:05
SmokeyD__setattr__01:05
philiKONyeah, well, that too01:06
SmokeyDit is called on an object when it is listed in it's container01:06
philiKONyour original question was lacking the underscores01:06
SmokeyDok, sorry01:06
SmokeyDdidn't know that there were builtins with those names in python01:06
SmokeyDjust started python together with zope01:06
SmokeyD:)01:06
philiKON:)01:06
philiKONso did i once...01:06
SmokeyDwell a little bit before, but not serious01:07
SmokeyD:)01:07
philiKONi recommend reading about the __geattr__ protocol01:07
philiKONand while you're at it, the __getitem__ protocol as well01:07
SmokeyDbut where can I find info. Tried looking up __getattr__ in your book01:07
SmokeyDbut can't find it01:07
philiKONwell, my book assumes knowledge of python01:07
SmokeyDok01:07
SmokeyDso it is still a python builtin01:07
SmokeyDalso with the underscores01:08
philiKONe.g. see http://python.active-venture.com/ref/attribute-access.html01:08
*** reco has joined #zope3-dev01:08
SmokeyDf __setattr__() wants to assign to an instance attribute, it  should not simply execute 'self.name = value' -- this would cause a recursive call to itself.01:09
*** reco has joined #zope3-dev01:09
SmokeyDhehehe01:09
SmokeyDfound that out the hard way01:09
SmokeyD:)01:09
philiKONbasically, when you do x.y01:09
philiKONthen x.__getattr__('y') will be called01:09
philiKONwhen you x.y = z01:10
philiKONthen x.__setattr('y', z) will be called01:10
philiKONmakes sense?01:10
SmokeyDyup it does01:10
philiKONsame with getitem protocol01:10
philiKONx[y] is equivalent to x.__getitem__(y)01:11
philiKONand x[y] = z is equivalent to x.__setitem__(y, z)01:11
SmokeyDok01:11
SmokeyDthanks01:11
SmokeyDthe question is still, why is it called on a python object when it is listed01:11
SmokeyDwhich attribute is set?01:11
philiKONlisted?01:12
SmokeyDfor each object in a listing I see a __setattr__ called twice with __name__=None for each object in the list01:12
SmokeyDwith list I mean the @@contents.html view of a container object01:12
philiKONuh huh01:12
philiKONthat's weird01:13
*** rocky has joined #zope3-dev01:13
SmokeyDYeah, I thought so01:13
philiKONare you sure, it's not a __getattr__ call?01:13
SmokeyDnope, I overrode the __setattr__ in a zope class01:13
SmokeyDand put a print statement on top of the method01:13
philiKONic01:14
philiKONweird01:14
philiKONtry to backtrace it with pdb01:14
philiKONinstead of the print statement, insert his line:01:14
SmokeyDdoes it have anything to do with annotations or somethin?01:14
philiKONimport pdb; pdb.set_trace()01:14
philiKONthen, execute the code again01:14
philiKONit will drop into pdb01:14
philiKONwhen in pdb, type01:14
SmokeyDpdb is the python debugger?01:14
philiKONbt01:14
philiKONyes01:14
SmokeyDbt as in backtrace?01:14
philiKONindeed01:15
philiKONthen it will list where __setattr__ is being called from01:15
SmokeyDok thanks01:15
SmokeyDlet's see01:15
SmokeyDzope/lib/python/ZODB/Connection.py(787)_setstate()01:16
SmokeyD-> obj._p_serial = serial01:16
SmokeyDserialization of the instance, something like that?01:17
*** srichter has joined #zope3-dev01:17
SmokeyDwhen it is retrieved from the ZODB it get's an attribute set?01:17
philiKONseems so01:17
*** ChanServ sets mode: +o srichter01:18
philiKONweird01:18
SmokeyDzope/lib/python/ZODB/serialize.py(511)load_persistent()01:18
SmokeyD-> obj._p_changed = None01:18
philiKONtype this in pdb:01:18
SmokeyDsomething to do with persistency I guess01:18
philiKONp name01:18
SmokeyD_p_serial01:19
philiKONi see01:20
philiKONthat's ok, though01:20
philiKONthose are set while waking the object from zodb, i presume01:20
philiKONtype 'c'01:20
philiKONfor continue01:20
philiKONuntil you get to the point where name is __parent__ or whatever it was01:20
philiKONanyways, i gotta go to bed...01:21
SmokeyDok01:21
SmokeyDthanks for your help01:21
SmokeyDthanks!01:21
philiKONnp01:21
SmokeyDsleep well philiKON01:34
philiKONg'night01:34
*** batlogg has quit IRC01:36
*** vlado has joined #zope3-dev01:39
*** flox is now known as flox|away01:42
*** SmokeyD has quit IRC01:52
*** srichter has quit IRC01:54
*** xenru has joined #zope3-dev01:57
*** philiKON has quit IRC02:11
*** alecm has quit IRC02:44
*** rocky is now known as rocky|away02:46
*** yota has quit IRC03:02
*** tarek has quit IRC03:24
*** benji has joined #zope3-dev04:41
*** stub has joined #zope3-dev04:52
*** vlado has quit IRC05:55
*** trevorp-office has joined #zope3-dev07:47
*** jhauser has joined #zope3-dev08:14
*** eins has joined #zope3-dev08:17
einshi08:17
*** oferw has joined #zope3-dev08:46
*** jukart has joined #zope3-dev09:06
*** batlogg has joined #zope3-dev09:09
*** jukart has left #zope3-dev09:12
*** Aiste has quit IRC09:15
*** flox|away has quit IRC09:30
*** SteveA has joined #zope3-dev09:40
*** yota has joined #zope3-dev09:41
*** hdima has joined #zope3-dev09:45
*** vlado has joined #zope3-dev09:51
*** dobee has joined #zope3-dev09:54
*** philiKON has joined #zope3-dev09:59
*** Theuni has joined #zope3-dev10:01
*** oferw has quit IRC10:12
*** dobee has quit IRC10:13
*** dobee has joined #zope3-dev10:23
*** dobee has joined #zope3-dev10:25
*** philiKON has quit IRC10:54
*** flox has joined #zope3-dev11:05
*** flox is now known as flox|away11:05
*** philiKON has joined #zope3-dev11:21
*** flox|away has quit IRC11:27
*** vlado has quit IRC11:54
*** zagy has joined #zope3-dev12:06
*** vlado has joined #zope3-dev12:08
*** J1m has joined #zope3-dev12:14
*** mkerrin has joined #zope3-dev12:14
*** ignas has joined #zope3-dev13:00
*** ignas_ has joined #zope3-dev13:02
*** ignas_ has quit IRC13:05
*** J1m has quit IRC13:23
*** dunny has quit IRC13:26
*** smokeyd has joined #zope3-dev13:27
*** srichter has joined #zope3-dev13:27
smokeydphiliKON: You gave me a link to an article about creating addforms (I think it was you at least) I can't happen to find the page anymore (I was at home then at my work now:) Do remeber which one it was?13:27
smokeydgood afternoon btw13:27
smokeyd:)13:27
*** Aiste has joined #zope3-dev13:30
grahamsmokeyd: mgedmin suggested http://mg.pov.lt/blog/formlib-adding.html13:32
*** philiKON has quit IRC13:33
*** jinty has joined #zope3-dev13:33
*** ChanServ sets mode: +o srichter13:33
*** volvox has joined #zope3-dev13:36
*** vlado has quit IRC13:37
*** dobee has quit IRC13:38
smokeydgraham: that was it indeed13:46
smokeydthanks13:46
smokeydare there any logs of this channel I could search to find this kind of thin?13:47
smokeydand another question about python, am I not looking properly or are there in Python only # comments and docstrings?13:47
smokeydno block comments?13:47
smokeydto comment out a block of code?13:48
grahamhttp://zope3.pov.lt/irclogs/13:48
smokeydthanks graham13:49
grahamI'm pretty sure there're no block comments13:49
jhauserthere is a dirty trick for block comments13:51
jhauserenclose the block into13:51
jhauser""" block code"""13:51
SteveAewww13:51
SteveAthat's gross13:51
jhauserI said dirty13:51
*** nathany has joined #zope3-dev13:52
SteveAI just use vim tricks13:52
SteveAto indent blocks13:52
SteveAeach line starting with a #13:52
jhauserright better use a sane editor, which let's you comment blocks of code13:52
SteveAuse a sane editor.  or use vim.13:53
jhauserI would include vim into sane editors13:53
smokeyd:D yup you're right13:54
smokeydI should start using vim13:54
*** regebro has joined #zope3-dev13:54
smokeydbut I have never used it really and don't know if I have the time for the learning curve at the moment13:54
smokeydi'm used to pico/nano13:54
smokeyd works ok, but doesn't have all the nifty shortcuts and stuff13:54
smokeydbut let'13:55
smokeyds not start discussing editors :)13:55
*** benji has quit IRC13:55
*** rocky has joined #zope3-dev13:55
SteveAhttp://tnerual.eriogerg.free.fr/vimqrc.html13:55
SteveAhttp://www.tuxfiles.org/linuxhelp/vimcheat.html13:56
SteveAinvaluable reference13:56
smokeydthanks SteveA, that helps13:56
smokeydI guess I'll just start with it now13:56
smokeyd:)13:56
*** SteveA has quit IRC13:57
*** regebro has quit IRC14:09
*** dobee has joined #zope3-dev14:14
*** SteveA has joined #zope3-dev14:16
*** MacYET has joined #zope3-dev14:25
*** srichter has quit IRC14:29
*** J1m has joined #zope3-dev15:09
*** zagy_ has joined #zope3-dev15:16
*** zagy has quit IRC15:21
*** russf has joined #zope3-dev15:25
*** russf has quit IRC15:27
*** russf has joined #zope3-dev15:27
*** SteveA has quit IRC15:37
*** ofer has joined #zope3-dev15:40
*** rocky has quit IRC15:41
*** philiKON has joined #zope3-dev15:45
*** zbir has quit IRC15:48
MacYETphiliKON: !15:49
MacYEThow about zope 3.2.2?15:49
*** volvox has quit IRC15:49
*** SteveA has joined #zope3-dev15:50
*** mgedmin has joined #zope3-dev15:52
*** volvox has joined #zope3-dev15:56
*** benji has joined #zope3-dev15:58
*** batlogg has quit IRC15:59
*** jukart has joined #zope3-dev16:00
*** alga has joined #zope3-dev16:00
*** batlogg has joined #zope3-dev16:01
*** zagy_ has quit IRC16:01
*** zbir has joined #zope3-dev16:02
philiKONMacYET, busy with exams16:02
philiKON:(16:02
smokeydhey, ppl. I can't get something to work with my own addform defined in formlib16:03
smokeydI let the user fill in some attributes which are defined in a schema16:04
smokeydand want to generate the objectname of the object (inherits from contained) from these data16:04
smokeydbut when I instantiate the class at the end of the create function of the form, and pass a value for the object name to it16:05
smokeydand call self.__name__=value in the __init__ of the object, nothing happens16:05
smokeydthe name is still set to some default from zope instead of the one I passed to the __init__ of the object16:05
mgedminsmokeyd: in the add form code set self.context.contentName  (self.context of an adding form is an IAdding object)16:10
mgedminif you want to trace the relevant code, then look at zope/formlib/form.py, class AddFormBase, methods handle_add, createAndAdd, add16:11
*** flox has joined #zope3-dev16:11
mgedminthe adding object itself is zope.app.container.browser.adding.Adding16:12
*** flox is now known as flox|away16:12
smokeydok, thanks16:15
smokeydI was already looking in the soucecode for the standard addform16:15
smokeydto see what that one does16:15
*** flox|away is now known as flox16:16
*** gumpa has joined #zope3-dev16:16
*** efge has joined #zope3-dev16:25
*** jinty has quit IRC16:26
*** whit has joined #zope3-dev16:30
*** ofer has quit IRC16:38
*** alga has quit IRC16:44
*** vlado has joined #zope3-dev16:45
*** oferw has joined #zope3-dev16:49
*** zagy has joined #zope3-dev16:55
*** eins has quit IRC16:59
*** gumpa has left #zope3-dev17:02
*** volvox has quit IRC17:04
*** volvox has joined #zope3-dev17:05
*** volvox has quit IRC17:27
*** volvox has joined #zope3-dev17:28
*** dokai has quit IRC17:33
*** dokai has joined #zope3-dev17:33
smokeydthe default values for an edit form, are they determined by the setUpEditWidgets function of the form class from the self.context variable?17:35
*** alecm has joined #zope3-dev17:35
smokeydI want the widgets to display other default values than the ones from the zope object itself17:36
smokeydand wonder if I can do that by modifying the self.context from an editform before calling setUpWidgets17:36
mgedminan edit form is supposed to show the values that are stored in the object17:37
mgedminI do not understand what you want17:37
smokeydI want to get them from a database17:38
smokeyd:)17:38
smokeydinstead of from the zope object attributes themself17:38
smokeydmysql17:38
smokeydI already store them there with the addForm17:39
mgedminyou could use something like sqlobject to make the object store its attributes in mysql17:39
mgedminor you could use a form that is not an edit form17:39
mgedminand pass the initial values to setUpWidgets17:39
smokeydthat is exactly what I am doing. I am making a zope object that does parts opf its storage to mysql17:40
*** Theuni has left #zope3-dev17:40
smokeydbut in order to use the add and edit forms from formlib I have to be able to get the default values of the edit form from the database17:40
smokeydwell, I was not doing the last part17:40
smokeydmaybe I should indeed not use an editform but a normal form17:40
*** flox has quit IRC17:41
*** flox_ has joined #zope3-dev17:41
*** flox_ is now known as flox17:42
*** flox_ has joined #zope3-dev17:43
*** niemeyer has joined #zope3-dev17:43
*** flox has quit IRC17:43
*** flox_ is now known as flox17:44
*** flox has quit IRC17:49
*** flox has joined #zope3-dev17:51
*** alga has joined #zope3-dev18:07
*** dobee has quit IRC18:08
smokeydmgedmin: just in case you're interseted. What I'm going to do is set the default value for all fields in the form_fields list18:13
smokeydthat is I think the easiest18:13
mgedminthat is one possibility18:13
smokeydFirst read all the fields from the schema, and then modify their default values18:14
*** volvox has quit IRC18:17
mgedminone or two of the three setup functions defined in zope.formlib (setUpWidgets, setUpEditWidgets, setUpDataWidgets) takes a data (or initial) argument that is a dict with initial values18:20
mgedmin(or maybe one of those takes a data argument, while another takes an initial argument, and the third one doesn't take any arguments to that effect)18:21
*** volvox has joined #zope3-dev18:21
*** batlogg has quit IRC18:23
*** jinty has joined #zope3-dev18:24
*** batlogg has joined #zope3-dev18:25
*** hdima has quit IRC18:30
*** b_52CEntos has quit IRC18:41
*** batlogg has quit IRC18:43
*** b_52CEntos has joined #zope3-dev18:47
*** d21 has joined #zope3-dev18:51
*** gumpa has joined #zope3-dev18:54
*** gumpa has left #zope3-dev18:55
*** d2m has quit IRC18:56
*** gumpa has joined #zope3-dev18:56
*** vlado has quit IRC18:57
*** vlado_ has joined #zope3-dev18:57
*** jukart has quit IRC18:58
*** SteveA has quit IRC18:58
*** d21 is now known as d2m18:59
*** SteveA has joined #zope3-dev19:08
smokeydHey all, I'm still fighting with the defaults of form_fields. What arguments can be passed to the __init__ of the FormFields class in formlibs.form?19:08
smokeydCan I pass default values for the fields to it?19:08
smokeydAnd if yes, how?19:08
volvoxaren't default values defined in your schema interface?19:09
volvoxI use that and FieldProperty(MyInterface['field_name']) in my content objects19:10
smokeyd:) Nope, in mysql database19:10
volvoxit gets the default value from the schema19:10
*** reco has quit IRC19:10
smokeydI'm using mysqlobject19:10
smokeydtogether with schema's and formlib to be able to retrieve and store some attributes in a mysql database backend19:10
smokeydI'm making a custom form that modifies the default values for the fields listed in the schema by getting them from a database19:11
volvoxI _think_ you could setup default values in setupWidgets()19:11
smokeydbut the problem is that the object returned by form.Fields function is not a list, so I can't use list comprehension to assign the default values.19:12
smokeydok19:12
smokeydis that also possible? Than I will look there19:12
smokeydthanks volvox19:12
volvoxkeep in mind I haven't grokked formlib yet19:12
smokeyd:)19:15
smokeydMe neither :) thanks for the tip though. I'm looking into setUpWidgets19:15
*** reco has joined #zope3-dev19:16
*** srichter has joined #zope3-dev19:21
*** ChanServ sets mode: +o srichter19:21
*** gumpa has quit IRC19:24
*** gump1 has joined #zope3-dev19:24
*** dobee has joined #zope3-dev19:33
smokeydi've got it volvox19:36
smokeydform_fields=form.Fields(IWorkpackage).omit('__name__','__parent__')19:36
smokeydfor field in form_fields:19:36
smokeyd            form_fields[field.__name__].field.default=eval("projectwp.get(self.id).%s"%(field.field.__name__)19:36
volvoxit's written eval, but spelled "evil"19:37
smokeydor at least more or less this (didn't test it yet, but it should work) :)19:37
volvoxgetattr(projectwp.get(self.id),field.__name__)19:37
smokeydok, yes that's better, you're right19:37
smokeydthanks19:38
*** dobee has quit IRC19:39
*** gumpa has joined #zope3-dev19:40
*** gump1 has quit IRC19:40
*** whit has quit IRC19:42
*** efge has quit IRC19:48
*** efge has joined #zope3-dev19:48
*** dobee has joined #zope3-dev19:48
smokeydWhich function in EditFormBase handles the actual updating of the data when the editform has been submitted?19:51
smokeydI am looking in ths sourcecode but can't find it19:51
volvoxsmokeyd: you do that with the @form.action decorator19:52
volvoxfor instance:19:52
*** zagy has quit IRC19:52
volvox@form.action(name="edit", label="Really do that!")19:53
volvoxdef handle_edit_action(self, action, data):19:53
volvoxand from there you call form.applyChanges19:53
volvoxit also adds the submit button for you19:53
*** RaFromBRC has joined #zope3-dev19:54
smokeydok, cool. Thanks.19:55
volvoxsmokeyd: look for @action(_("Apply") in formlib.py19:56
*** MJ has joined #zope3-dev20:11
*** stub has quit IRC20:13
*** nathany has quit IRC20:20
*** flox has quit IRC20:21
*** smokeyd has left #zope3-dev20:21
*** volvox has quit IRC20:22
*** srichter has quit IRC20:23
*** alga has quit IRC20:23
J1mphiliKON: ayt?20:32
*** philiKON has quit IRC20:39
*** srichter has joined #zope3-dev20:42
*** ChanServ sets mode: +o srichter20:42
*** zbir has quit IRC20:47
*** efge has quit IRC20:55
*** oferw has quit IRC20:58
*** jinty has quit IRC21:02
*** benji has quit IRC21:07
*** andrew_m has joined #zope3-dev21:10
*** MacYET has quit IRC21:14
*** mkerrin has quit IRC21:17
*** MacYET has joined #zope3-dev21:20
*** batlogg has joined #zope3-dev21:47
*** gumpa has quit IRC21:54
*** gump1 has joined #zope3-dev21:54
*** zbir has joined #zope3-dev21:57
*** gump1 is now known as gumpa21:57
*** ignas has quit IRC21:58
*** nathany has joined #zope3-dev22:00
*** mkerrin has joined #zope3-dev22:02
*** mkerrin has quit IRC22:16
*** flox has joined #zope3-dev22:24
*** flox is now known as flox|away22:24
*** MacYET has quit IRC22:30
*** jukart has joined #zope3-dev22:35
*** dunny has joined #zope3-dev22:36
*** MacYET has joined #zope3-dev22:36
*** J1m has quit IRC22:38
*** whit has joined #zope3-dev22:38
*** povbot has joined #zope3-dev22:43
*** jukart has quit IRC22:45
*** gumpa has quit IRC22:45
*** gumpa has joined #zope3-dev22:45
*** mgedmin has quit IRC22:48
*** RaFromBRC has quit IRC22:53
*** PyNick has joined #zope3-dev22:54
PyNickHi - is it possible to add/configure PAU via ZCML?22:55
*** MacYET has quit IRC22:59
PyNick...zope.app.authentication22:59
*** MiUlEr has joined #zope3-dev23:07
*** MiUlEr has quit IRC23:10
*** ignas has joined #zope3-dev23:14
*** dobee has quit IRC23:19
*** J1m has quit IRC23:26
*** J1m has joined #zope3-dev23:28
*** benji has quit IRC23:30
*** benji has joined #zope3-dev23:30
*** benji has joined #zope3-dev23:31
*** mgedmin has joined #zope3-dev23:34
*** srichter has quit IRC23:38
*** senra has joined #zope3-dev23:47
*** rocky has joined #zope3-dev23:48
*** nathany has quit IRC23:59

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