X-CGP-ClamAV-Result: CLEAN X-VirusScanner: Niversoft's CGPClamav Helper v1.22.2a (ClamAV engine v0.102.2) X-Junk-Score: 0 [] X-KAS-Score: 0 [] From: "Samuel Pelletier" Received: from fortimail.cybercat.ca ([216.13.210.77] verified) by post.selbstdenker.com (CommuniGate Pro SMTP 6.3.3) with ESMTPS id 26385376 for webobjects-dev@wocommunity.org; Wed, 01 Sep 2021 23:48:11 +0200 Received-SPF: none receiver=post.selbstdenker.com; client-ip=216.13.210.77; envelope-from=samuel@samkar.com Received: from smtpclient.apple (modemcable213.203-171.107.mc.videotron.ca [107.171.203.213]) (user=samuel%samkar.com mech=PLAIN bits=0) by fortimail.cybercat.ca with ESMTP id 181LlmUO002615-181LlmUP002615 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 1 Sep 2021 17:47:48 -0400 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: [WO-DEV] ERXGenericRecord takeValueForKey Date: Wed, 1 Sep 2021 17:47:47 -0400 References: To: WebObjects & WOnder Development In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3654.120.0.1.13) X-FEAS-AUTH-USER: samuel%samkar.com Hi OC, I think the problem come from the fact ERXGenericRecord extends = EOGenericRecord and this class behave like a map and do not need getter = and setter for modelled attribute names. Getters and Setters created by = EOGenerator are not required by EOF but they are very useful to add type = checking to the code. By exploring tha NSKeyValueCoding with a decompiler, we can see that = this method is called to get the method to set a value for a key: = _storedKeyGetBindingForKey(String key) declared in the = _KeyBindingCreation interface. My guess is the EOGenericRecord = implementation of this method do some magic to enable EOGenericRecord = map like behaviour for modelled attributes. So, if you want to disable attribute setters, you may either=20 - rename the attribute and create a getter that call the real attribute = getter - implement a setter that throw an exception - add some checking in takeValueForKey and also takeStoredValueForKey = (to block both ways) Maybe extending EOCustomObject directly would also works but you will = loose all the ERXGenericRecords stuff... Regards, Samuel > Le 25 ao=C3=BBt 2021 =C3=A0 21:50, ocs@ocs.cz = a =C3=A9crit : >=20 > Hi there, >=20 > I must be missing something darn obvious; looks like I've missed EOF = 101 somehow :/ >=20 > My EO class, which extends ERXGenericRecord, does not implement = modelled property setters. Thus, I assumed takeValueForKey would always = fall through handleTakeValueForUnboundKey. Seems not. >=20 > I've overridden the methods like this: >=20 > =3D=3D=3D > class OCSEnterpriseObject extends ERXGenericRecord { > static boolean canAccessFieldsDirectly { NO } > void takeValueForKey(value,String key) { > println "???takeValueForKey $key" > //super.takeValueForKey(value, key) // precisely same behaviour as = with the thing below, no difference > = NSKeyValueCoding.DefaultImplementation.takeValueForKey(this,value,key) > } > void handleTakeValueForUnboundKey(value,String key) { > println "???handleTakeValueForUnboundKey $key" > // ... some stuff to simulate setter (eventually using = takeStoredValueForKey), not relevant, for it is never called > } > ... > } > =3D=3D=3D >=20 > It does NOT work as (I've na=C3=AFvely) presumed. >=20 > When eo.takeValueForKey(o,key) is called, I can always see = =E2=80=9C???takeValueForKey=E2=80=9D (naturally), but I *never ever* see = =E2=80=9C???handleTakeValueForUnboundKey=E2=80=9C for any key amongst = modelled attributes. Nothing other (known to me) gets called =E2=80=94 = not even takeStoredValueForKey, which I've also overridden to log =E2=80=94= , but the value is set all right in the EO. >=20 > Only if foo is a random (non-existing, non-modelled) string, I can see = =E2=80=9C???handleTakeValueForUnboundKey=E2=80=9C. >=20 > Looks like there's some trick in = NSKeyValueCoding.DefaultImplementation.takeValueForKey which recognises = modelled attributes in EOGenericRecord and fill their values directly, = without falling to handleTakeValueForUnboundKey?!? Weird. >=20 > Or I must be doing something very far wrong. >=20 > Is this documented somewhere? Far as I can say, neither = ERXGenericRecord nor EOGenericRecord nor = NSKeyValueCoding.DefaultImplementation mentions anything special; = NSKeyValueCoding.DefaultImplementation.takeValueForKey should simply = check for the accessor (either with or without the _ prefix) and if = there is none (which there indeed is not), fall to = handleTakeValueForUnboundKey. What am I missing here? >=20 > Thanks, > OC >=20 >=20 >=20 > ############################################################# > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to = > To switch to the INDEX mode, E-mail to = > Send administrative queries to = >=20