Re: OSCPool/EO stack management/relaunch (was: Should ERXEC get sharedEC automagically?)

2018-08-23 Thread ocs@ocs
Chuck,

I guess I have solved the mystery :) Looks like all what's needed is

- to set up freely the OSCPool with any number of coordinators
- at the init time, to use "isolation=serializable/locking=pessimistic" in my 
models
- and switch off the SEC (by setting it to null in my ERXEC)
- when all the init work is done, I simply call

EODatabaseContext.forceConnectionWithModel(model,[URL:"jdbc:FrontBase://$dbhost/$dbname/user=$user/isolation=read_committed/locking=optimistic"],ec)

and that's that, it seems it works all right, for subsequently all 
(session-based) ECs seem to work properly with the (OSC-based) SEC, and the 
connexion indeed is read-committed/optimistic, as need be.

There's just one small thing I am not sure of: forceConnectionWithModel 
re-connects “all compatible models in the model group” too. Alas the 
documentation does not say what a “compatible” model is — what does that mean? 
How does the EOF determine which models are compatible?

Thanks and all the best,
OC

> On 22 Aug 2018, at 2:06 PM, ocs@ocs  wrote:
> 
> Chuck,
> 
> hmmm... coudn't I somehow switch off temporarily the OSCPool, so that the 
> initialisation code happens precisely as if there was no pool at all, and 
> only then, when done, the pool starts behaving as normally? Actually I could 
> benefit — if it is possible — from that, not only due to the SEC, but for 
> other reasons as well (it would help if I could run the initialisation code 
> against the DB in the “isolation=serializable/locking=pessimistic” mode, 
> switching to “isolation=read_committed/locking=optimistic” for the normal 
> processing).
> 
> The init code just reads some objects from the db (including 
> INFORMATION_SCHEMA, which is the reason for the DB mode), checks them, 
> potentially updates them, and that's that — if at this moment the application 
> quits and immediately runs again without the init code, it would work just as 
> well. But for the objects in the shared EC, there's no EO which the init code 
> would create/fetch and a later session-based code would use anyhow.
> 
> I might switch off the SEC for the initialisation completely: I would run the 
> init code using an EC with its SEC explicitly set to null, then somehow trash 
> the init EO stack completely and start afresh with a new one (or ones with 
> OSCPool) and normal session-based processing.
> 
> Can this, i.e.,
> 
> - to begin without OSCPool and connecting to DB in the 
> “isolation=serializable/locking=pessimistic” mode;
> - do some stuff (without SEC), save changes;
> - completely trash the EO stack;
> - create a new one with OSCPool connecting to DB in the 
> “isolation=read_committed/locking=optimistic” mode with SEC, and run happily 
> ever after
> 
> be done in some cleaner way than, well, restarting the application — which 
> with some trickery exploiting Auto Recover in JavaMonitor might even prove 
> possible, but would be super-ugly and I would rather do without?
> 
> Thanks,
> OC
> 
>> On 22 Aug 2018, at 5:11 AM, Chuck Hill > > wrote:
>> 
>> That is a good question.  I’ve not used the combination.   There must be 
>> some code that uses the default instead of getting the SEC from the 
>> EOEditingContext.  There is a lot of code in Wonder (and some in WO) that 
>> assumes the defaultWhatever is the only one that will ever exist.  You would 
>> have to step into the code to see where this is happening, or enable the 
>> logging of stack traces of fetches.  It should be a simple fix once you find 
>> the spot.
>>  
>> Chuck
>>  
>> From: "ocs@ocs" mailto:o...@ocs.cz>>
>> Date: Tuesday, August 21, 2018 at 1:02 PM
>> To: Chuck Hill mailto:ch...@gevityinc.com>>
>> Cc: "webobjects-dev@lists.apple.com " 
>> mailto:webobjects-dev@lists.apple.com>>
>> Subject: Re: Should ERXEC get sharedEC automagically?
>>  
>> Indeed! If I switch off the OSCPool, it starts to work properly.
>>  
>> Thanks just again! 
>>  
>> Nevertheless, I still must be missing something of grave importance, for 
>> with OCSPool (I use ), I would presume the SEC for the pool being currently 
>> used by the ERXEC would load the shared objects?
>>  
>> It does not: the global one does automatically load the shared objects, but 
>> the SEC-based one of ERXEC remains empty.
>>  
>> Note: the code in question does not run in a session context; it is 
>> performed at launch, before the first session is created. Might that be 
>> important perhaps?
>>  
>> All the best,
>> OC
>>  
>> 
>> 
>> On 21 Aug 2018, at 9:42 PM, Chuck Hill > > wrote:
>>  
>> Are you using the ERXObjectStoreCoordinatorPool?  It keeps one SEC per pool, 
>> not one shared globally.  
>> EOSharedEditingContext.defaultSharedEditingContext() is the global one.
>>  
>> Chuck
>>  
>> From: "ocs@ocs" mailto:o...@ocs.cz>>
>> Date: Tuesday, August 21, 2018 at 12:23 PM
>> To: Chuck Hill mailto:ch...@gevityinc.com>>
>> Cc: 

Re: in which EO behalf a ValueFactory works?

2018-08-23 Thread Samuel Pelletier
Hi OC,

The ValueFactory methods are not well suited for you need. You want to create a 
child relationship serialized in the parent object, not a simple storage for 
basic container.

I suggest you try something like this with the model attribute for the 
serialized content named attributeBlob with a NSData type:

- Implement a method public NSData _attributeBlob() that will returns the 
serialized attribute.

- Implement a method public void _setAttributeBlob(NSData data) that will 
unserialize your blob to an instance variable with the back link to it's parent.

- Add a getter for the real attribute object like public MyCustomObject 
attribute()

- In the attribute object add a call to willChange() on the parent EO in method 
that mutate the object.

EOF will uses the method with an '_' during fetch and save if they exists 
(StoredValueForKey: protocol) so you can uses theses for your encoding 
decoding. The call to willChange() will add the object in the EOEditingContext 
changed objects.

I've done something similar without the backlink part in the past.

Regards,

Samuel


> Le 22 août 2018 à 13:31, ocs@ocs  a écrit :
> 
> Hi there,
> 
> quite unrelated to the other things, I would need to exploit the 
> ValueFactory/ValueConversion support of EOF to store my own complex values in 
> BLOBs.
> 
> There's a catch though: for a ValueFactory-generated object, I would need to 
> know which EO it belongs to (so that, iff the object's own internal state 
> changes, it can change the EO contents appropriately).
> 
> Is there any way to do that?
> 
> If important, here's the rationale: so far, I have used two distinct 
> attributes, conceptually like this:
> 
> ===
> class DBSomething extends ERXCustomObject {
>   NSData attributeBlob() { storedValueForKey("attributeBlob") } // modelled. 
> Never used directly, but for the cases below
>   MyCustomObject attribute() { new 
> MyCustomObject(attributeBlob,this,"attributeBlob") }
> }
> class MyCustomObject {
>   MyCustomObject(NSData contents, ERXEnterpriseObject owner, String key) {
> ... ...
> NSData blobRepresentation() { ... ... }
> void didChange() { owner.takeStoredValueForKey(blobRepresentation(), key) 
> }
> }
> ===
> 
> but it seems to me it would be cleaner if I could defer creation of 
> MyCustomObject to the ValueFactory, storing the changes to the 
> ValueConversion, and get rid of the ugly dichotomy of foo and fooBlob, 
> removing fooBlob completely and seeing only foo (of type MyCustomObject) at 
> the code level.
> 
> Thanks and all the best,
> OC
> 
> ___
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
> 
> This email sent to sam...@samkar.com

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Weird D2W rule selection

2018-08-23 Thread Fabian Peters
Hi Markus,

Have you checked whether the "region" key is present in the context of the 
ERMDInspectPageRepetition – or whichever component is used to render the 
display property lines?

Fabian

> Am 22.08.2018 um 15:11 schrieb Markus Ruggiero :
> 
> I just had a debugging session with a customer. He complained that 
> "CreateProduct" page conf did not list the correct displayPropertyKeys. And 
> indeed they are wrong. But why?
> 
> Rule I want to work (list of properties truncated to anonymize the customer):
> 
> 100 : (pageConfiguration = 'CreateProduct' and region = 'europe') => 
> displayPropertyKeys = ("productCode",  ) 
> [com.webobjects.directtoweb.Assignment](list of properties I want)
> 
> Rule that actually fires
> 
> 100 : pageConfiguration = 'CreateProduct' => displayPropertyKeys = 
> ("productCode", ) [com.webobjects.directtoweb.Assignment]   (fallback 
> rule with different list of properties
> 
> That can be when region is not properly defined, BUT it is.
> 
> Opening D2W debug output in the resulting browser shows at the very top when 
> hovering over the "?" the list from the second, less qualified rule
> When entering "displayPropertyKeys into the little debug textfield I do get 
> the expected list of properties (the one for 'europe').
> 
> When manually asking for the displayPropertyKeys the first rule fires (which 
> is what I expect) but the D2W template resolves via the second rule. Even 
> reducing the priority of that rule to e.g. 80 does not give prio to the more 
> qualified first rule. D2WTraceRuleFiringEnabled shows what is displayed in 
> the app.
> 
> Other pageConfigurations like EditProduct have similar rules but there the 
> rule with "region" is firing - as it should.
> 
> I inject the region code into d2wContext in the PageWrapper.awake() with the 
> fillowing code lines:
> 
> public void awake() {
> super.awake();
> D2WContext ctx = d2wContext();
> if (ctx != null) {
> Application application = (Application)Application.application();
> ctx.takeValueForKey( application.region().code(), "region" );
> }
> }
> 
> public D2WContext d2wContext() {
> if (context().page() instanceof D2WPage) {
> D2WPage d2wPage = (D2WPage) context().page();
> return d2wPage.d2wContext();
> }
> return null;
> }
> 
> Any idea why this happens? Could this be a timing issue?
> 
> ---markus---
> ___
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/lists.fabian%40e-lumo.com
> 
> This email sent to lists.fab...@e-lumo.com

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com