From: Justin F. <je...@ey...> - 2001-07-08 05:18:20
|
Alex: Sometimes my mind just falls apart, and I feel like I am in that state right now. In one of your last posts, you suggested to get a large/complex bit of data and store it in a class variable, and then (implied) down the load chain, this variable can be accessed. HOW? Especially, what if I want something from a module in a group when they are two instances, but do different things because of passed in options. EXAMPLE stanza / module group top 'modules' => array( 'top' => array( 'load' => array( array( 'name' => "EyeLibrary", 'package' => "lib", 'load_order' => "1", 'options' => "option1", ), array( 'name' => "EyeLibrary", 'package' => "lib", 'load_order' => "2", 'options' => "option2", ), array( 'name' => "Blank", 'package' => "lib", 'load_order' => "3" ), ), ), ---------- Now in the above stanza, EyeLibrary that has load order "1" does something as dictated by option1, and stores that data at, say, $this->what_i_need. EyeLibrary that has load order "2" does something as dictated by option2, and stores that data at, say, $this->what_i_need. NOW, how the hell do I get the data EyeLibrary[0]->what_i_need? NOW, how the hell do I get the data EyeLibrary[1]->what_i_need? Both of these pieces of data are desired in Blank, load order "3". If I instantiate a new EyeLibrary within a following module, this is no good at all, because I have in the constructor something like: function EyeLibrary($_options="ain't no options in EyeLibrary") { $this->options = $_options; some other code, maybe return true; } so all I would get was "ain't no options...", which, for the example, is EyeLibrary->what_i_need. How do I do this without going global???? You instantiate the thing in $Page->_IncludeModules() with the options from $bc_page, but how do I get to that instantiation, and distinguish between the two loads???? WITHOUT GOING GLOBAL SCOPE in the constructor??? My mind is mush right now... _jef -- Justin Farnsworth Eye Integrated Communications 321 South Evans - Suite 203 Greenville, NC 27858 | Tel: (252) 353-0722 |
From: alex b. <en...@tu...> - 2001-07-08 06:22:01
|
> Sometimes my mind just falls apart, and I feel like I am in that > state right now. In one of your last posts, you suggested to > get a large/complex bit of data and store it in a class variable, > and then (implied) down the load chain, this variable can > be accessed. > > HOW? $Page->modules['group_name'][load_order]->variable_name Thus my mention of possibly using unique names in the page declaration, so making references to modules would be more simple. that would also complicate the page module sorting functions, so I'm not sure it's worth doing that way. it may be a lot more simple to have a module communication manager which is called by a module that needs something, like a really simple Request class. _alex |
From: Justin F. <je...@ey...> - 2001-07-08 09:01:22
|
alex black wrote: > > > Sometimes my mind just falls apart, and I feel like I am in that > > state right now. In one of your last posts, you suggested to > > get a large/complex bit of data and store it in a class variable, > > and then (implied) down the load chain, this variable can > > be accessed. > > > > HOW? > > $Page->modules['group_name'][load_order]->variable_name > > Thus my mention of possibly using unique names in the page declaration, so > making references to modules would be more simple. > > that would also complicate the page module sorting functions, so I'm not > sure it's worth doing that way. it may be a lot more simple to have a module > communication manager which is called by a module that needs something, like > a really simple Request class. ================================================= Alex: Oy weh. Now I was var_dump()'ing what you have above, viz: var_dump($Page->modules['top'][0]); as I thought that was it after looking at Page.php, and all I was getting were NULL's. Of course, of course, I was in some decendant class method, and forgot to global $Page within the method...... But, Alex, you are not going to make us use this syntax, are you? No, you are figuring out something with a bit more elegance, aren't you? :) There is _still_ something rotten, at least it seems so, in your array sort in Page. This load_order thingy has, you realize, the weakness, that you can put in index.php three modules in a 'top' group with load_order(s) as: EXAMPLE--- MOD1 load_order=>69 MOD2 load_order=>22 MOD3 load_order=>11 and this _should_ map/sort to $Page->modules['top'][0] ===> MOD3 $Page->modules['top'][1] ===> MOD2 $Page->modules['top'][2] ===> MOD1 but it doesn't. No matter what you put in your load order, the sequence in $Page->modules['top'] is ALWAYS IN THE ORDER OF the appearance in index.php. Anyway, it appears your uasort() thingy is not working, and that, specifically, your sorting comparison function: create_function('$a,$b', 'return $a("load_order"] - $b["load_order"];'); must be always returning 0, instead of (-1,0,+1) accordingly. Now I am wondering, with your sorting, IF IT WERE WORKING, you have it mechanized, I think, that for my EXAMPLE above, admittedly wrong or sloppy, it would create a sparse array if the load_order was a number type and not a number_string (with quotes). I think you also need to guard against sparse arrays somehow. Well, I haven't tried to "fix" _IncludeModules($_group) and see if it does create a sparse array.... OK Alex, so in any case, you are going to figure out some kind of way to reference _which_ instance of multiple loads of the same module easily. The only thing that occurs to me quickly is something like adding a tag, as in: array( 'name' => "EyeLibrary", 'package' => "lib", 'load_order' => 2, 'tag' => "TableData", 'options' => "option1", ), and then allow reference to that particular module as: $Page->modules['top']['TableData']->method_or_property; That is knee-jerk, but gives you something to think about. _jef -- Justin Farnsworth Eye Integrated Communications 321 South Evans - Suite 203 Greenville, NC 27858 | Tel: (252) 353-0722 |
From: Odysseas T. <ody...@ya...> - 2001-07-08 09:18:16
|
The sorting works as expected. Array order and key-value association are two different things in php. uasort doesnot change the key association, i.e., you should not see a 0 indexed element if you didn't original create one with that key. Check the *sort man pages for more info. odysseas > > Oy weh. Now I was var_dump()'ing what you have > above, viz: > > var_dump($Page->modules['top'][0]); > > as I thought that was it after looking at Page.php, > and all I > was getting were NULL's. Of course, of course, I > was > in some decendant class method, and forgot to global > $Page > within the method...... > > But, Alex, you are not going to make us use this > syntax, > are you? No, you are figuring out something with a > bit more elegance, aren't you? :) > > There is _still_ something rotten, at least it seems > so, > in your array sort in Page. This load_order thingy > has, you realize, the weakness, that you can put in > index.php three modules in a 'top' group with > load_order(s) > as: > > EXAMPLE--- > > MOD1 load_order=>69 > MOD2 load_order=>22 > MOD3 load_order=>11 > > and this _should_ map/sort to > > $Page->modules['top'][0] ===> MOD3 > $Page->modules['top'][1] ===> MOD2 > $Page->modules['top'][2] ===> MOD1 > > but it doesn't. No matter what you put in your > load order, the sequence in $Page->modules['top'] > is ALWAYS IN THE ORDER OF the appearance in > index.php. > Anyway, it appears your uasort() thingy is not > working, > and that, specifically, your sorting comparison > function: > > create_function('$a,$b', 'return $a("load_order"] > - $b["load_order"];'); > > must be always returning 0, instead of (-1,0,+1) > accordingly. > > Now I am wondering, with your sorting, IF IT WERE > WORKING, > you have it mechanized, I think, that for my EXAMPLE > above, > admittedly wrong or sloppy, it would create a sparse > array > if the load_order was a number type and not a > number_string (with > quotes). > I think you also need to guard against sparse arrays > somehow. > Well, I haven't tried to "fix" > _IncludeModules($_group) > and see if it does create a sparse array.... > > OK Alex, so in any case, you are going to figure out > some > kind of way to reference _which_ instance of > multiple > loads of the same module easily. The only thing > that > occurs to me quickly is something like adding a tag, > as in: > > array( > 'name' => > "EyeLibrary", > 'package' => "lib", > 'load_order' => 2, > 'tag' => > "TableData", > 'options' => > "option1", > ), > > and then allow reference to that particular module > as: > > $Page->modules['top']['TableData']->method_or_property; > > That is knee-jerk, but gives you something to think > about. > > _jef > > > -- > Justin Farnsworth > Eye Integrated Communications > 321 South Evans - Suite 203 > Greenville, NC 27858 | Tel: (252) 353-0722 > > _______________________________________________ > binarycloud-dev mailing list > bin...@li... > http://lists.sourceforge.net/lists/listinfo/binarycloud-dev __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ |
From: Justin F. <je...@ey...> - 2001-07-08 10:53:35
|
Odysseus: What will happen if the load_order value is a number? That means, what if the value of load_order is not quoted, but just a bare integer? Down the line, will this value be "interpreted" as an indexed array at that level, vhen the load_order value is used as a "key" later, and that value is an int? I suppose at the end of the day, 1. MUST WE ALWAYS QUOTE the load_order value in the $bc_page structure to have things work??? 2. MUST WE ALWAYS insure that, within a module group, you _must_ have a strict series of load_order(s) such as, 1,2,3,4....N? The uasort user-supplied comparison function will just return 0, if two load_orders are the same, and the behaviour/ordering is undefined. At that point, if there is no error trapped, then we will not know how to reference and/or talk to that module from another module since if you had, i.e., a group load_order set of 1,2,2,3,4...N, then WHO IS THEN OCCUPYING: $Page->modules['module'][2]??? I know you will want to say, well, just make sure you have a perfect sequence. I will then say, yea, but if I have load_order(s) 11,22,69, I still want it to work "as expected", and "find" the second module to talk to occupying $Page->modules['top'][1] where I would expect it, whereas, if I read you correctly, you would expect it at $Page->modules['top']['22'] if it is a "true" associative array, finally, and not an indexed array, finally. Er, anybody else out there as confused as I am?????? _jef ---------------------------- Odysseas Tsatalos wrote: > > The sorting works as expected. > > Array order and key-value association are two > different things in php. > uasort doesnot change the key association, i.e., you > should not see a 0 indexed element if you didn't > original create one with that key. > > Check the *sort man pages for more info. > > odysseas -- Justin Farnsworth Eye Integrated Communications 321 South Evans - Suite 203 Greenville, NC 27858 | Tel: (252) 353-0722 |
From: Odysseas T. <ody...@ya...> - 2001-07-08 15:39:40
|
> > What will happen if the load_order value is > a number? That means, what if the value The value of the load_order can be either a string or a number. The only requirement is that when given to the function create_function('$a,$b', 'return $a["load_order"] - $b["load_order"];')); it behaves properly. so any of the sets of numbers below they will end up getting sequenced properly during loading time. 1,2,3 '1','2','3' 45, 78, 108 -8, 1.23, 3.56, 6.78 'a', 'b', 'c' $this->modules[$_group] will always end up being an array that looks like 0 => mod1, 1 => mod2 2 => mod3 ... where mod1, mod2 mod3 are the first/second/third module in your index.php in order of appearence. They will have been instantiated not in order of appearence but based on their load_order: smallest first, biggest last odysseas > of load_order is not quoted, but just > a bare integer? Down the line, will this > value be "interpreted" as an indexed array at > that level, vhen the load_order value is used > as a "key" later, and that value is an int? __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ |
From: Odysseas T. <ody...@ya...> - 2001-07-08 10:09:07
|
But you were right that the rest of the code isn't behaving the way it was supposed to :-) I needed to add a ksort right before the end of the IncludeModules function ksort($this->modules[$_group]); Keep in mind that the the "example" layout that index.php comes with is not following the default order but it explicitly alters it. Thanks for the bug, odysseas --- Justin Farnsworth <je...@ey...> wrote: > alex black wrote: > > > > > Sometimes my mind just falls apart, and I feel > like I am in that > > > state right now. In one of your last posts, you > suggested to > > > get a large/complex bit of data and store it in > a class variable, > > > and then (implied) down the load chain, this > variable can > > > be accessed. > > > > > > HOW? > > > > > $Page->modules['group_name'][load_order]->variable_name > > > > Thus my mention of possibly using unique names in > the page declaration, so > > making references to modules would be more simple. > > > > that would also complicate the page module sorting > functions, so I'm not > > sure it's worth doing that way. it may be a lot > more simple to have a module > > communication manager which is called by a module > that needs something, like > > a really simple Request class. > ================================================= > Alex: > > Oy weh. Now I was var_dump()'ing what you have > above, viz: > > var_dump($Page->modules['top'][0]); > > as I thought that was it after looking at Page.php, > and all I > was getting were NULL's. Of course, of course, I > was > in some decendant class method, and forgot to global > $Page > within the method...... > > But, Alex, you are not going to make us use this > syntax, > are you? No, you are figuring out something with a > bit more elegance, aren't you? :) > > There is _still_ something rotten, at least it seems > so, > in your array sort in Page. This load_order thingy > has, you realize, the weakness, that you can put in > index.php three modules in a 'top' group with > load_order(s) > as: > > EXAMPLE--- > > MOD1 load_order=>69 > MOD2 load_order=>22 > MOD3 load_order=>11 > > and this _should_ map/sort to > > $Page->modules['top'][0] ===> MOD3 > $Page->modules['top'][1] ===> MOD2 > $Page->modules['top'][2] ===> MOD1 > > but it doesn't. No matter what you put in your > load order, the sequence in $Page->modules['top'] > is ALWAYS IN THE ORDER OF the appearance in > index.php. > Anyway, it appears your uasort() thingy is not > working, > and that, specifically, your sorting comparison > function: > > create_function('$a,$b', 'return $a("load_order"] > - $b["load_order"];'); > > must be always returning 0, instead of (-1,0,+1) > accordingly. > > Now I am wondering, with your sorting, IF IT WERE > WORKING, > you have it mechanized, I think, that for my EXAMPLE > above, > admittedly wrong or sloppy, it would create a sparse > array > if the load_order was a number type and not a > number_string (with > quotes). > I think you also need to guard against sparse arrays > somehow. > Well, I haven't tried to "fix" > _IncludeModules($_group) > and see if it does create a sparse array.... > > OK Alex, so in any case, you are going to figure out > some > kind of way to reference _which_ instance of > multiple > loads of the same module easily. The only thing > that > occurs to me quickly is something like adding a tag, > as in: > > array( > 'name' => > "EyeLibrary", > 'package' => "lib", > 'load_order' => 2, > 'tag' => > "TableData", > 'options' => > "option1", > ), > > and then allow reference to that particular module > as: > > $Page->modules['top']['TableData']->method_or_property; > > That is knee-jerk, but gives you something to think > about. > > _jef > > > -- > Justin Farnsworth > Eye Integrated Communications > 321 South Evans - Suite 203 > Greenville, NC 27858 | Tel: (252) 353-0722 > > _______________________________________________ > binarycloud-dev mailing list > bin...@li... > http://lists.sourceforge.net/lists/listinfo/binarycloud-dev __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ |
From: Justin F. <je...@ey...> - 2001-07-08 11:22:02
|
Odysseas: Nope, nada, niente, pas de tout, is load_order having _ANY_ effect on the disto index.php. If I comment the layout template in index.php, thus: 'modules' => array( 'content' => array( # 'layout' => array( # 'name' => "example", # 'package' => "html.layouts", # ), then the load order still follows the order of the module appearance in index.php, instead of the appearance to load_order of 1st 3 2nd 6 3rd 1 4th 5 5th 4 6th 2 I never have understood this... If I put: echo "<pre>"; var_dump($Page->modules['content']); echo "</pre>"; in the HelloWorld.php module, I get array(6) { [0]=> object(otherworld)(1) { ["stuff"]=> string(25) "This is some sample stuff" } [1]=> object(set_lang_example)(0) { } [2]=> object(helloworld)(2) { ["options"]=> array(2) { ["example"]=> string(23) "this is an option value" ["another"]=> int(1) } ["date"]=> string(12) "Jul:Sun:2001" } [3]=> object(helloworld)(2) { ["options"]=> NULL ["date"]=> string(12) "Jul:Sun:2001" } [4]=> object(helloworld)(2) { ["options"]=> NULL ["date"]=> string(12) "Jul:Sun:2001" } [5]=> object(helloworld)(2) { ["options"]=> NULL ["date"]=> string(12) "Jul:Sun:2001" } which means it is not sorting, but following appearance order. I even added your ksort fix in Page.php where you said it should go, and it still just follows appearance order. _jef ------------------------ Odysseas Tsatalos wrote: > > But you were right that the rest of the code > isn't behaving the way it was supposed to :-) > > I needed to add a ksort right before the end of the > IncludeModules function > > ksort($this->modules[$_group]); > > Keep in mind that the the "example" layout that > index.php comes with is not following the > default order but it explicitly alters it. -- Justin Farnsworth Eye Integrated Communications 321 South Evans - Suite 203 Greenville, NC 27858 | Tel: (252) 353-0722 |
From: Odysseas T. <ody...@ya...> - 2001-07-08 15:59:21
|
The load_order defines the order of module instantiation (mnemonic: instantiation == loading) not the order of display. The order of display is the same as the order of appearence in the index.php. So after you run _IncludeModules the $Page->modules['content'] order should be (as you noticed) the same as the order of appearence. The default layout will simply iterate over that array outputing the cached output of each module and that will produce the desired result. In order to see the actual order of modules instantiation just stick a debugging stmt in the for loop (function _IncludeModules), right after the instantiation: foreach ($modules[$_group]['load'] as $pos=>$mod) { import("user.mod.$mod[package].$mod[name]"); $this->modules[$_group][$pos] = new $mod['name']($mod['options']); echo("group: $_group, module $mod[name]\n"); } You will see your debugging output right above the binarycloud image. odysseas --- Justin Farnsworth <je...@ey...> wrote: > Odysseas: > > Nope, nada, niente, pas de tout, is > load_order having _ANY_ effect on the > disto index.php. > > If I comment the layout template in index.php, thus: > > 'modules' => array( > 'content' => array( > # 'layout' => array( > # 'name' => "example", > # 'package' => > "html.layouts", > # ), > > then the load order still follows the order of the > module appearance in index.php, instead of > the appearance to load_order of > > 1st 3 > 2nd 6 > 3rd 1 > 4th 5 > 5th 4 > 6th 2 > > I never have understood this... > > If I put: > > echo "<pre>"; > var_dump($Page->modules['content']); > echo "</pre>"; > > in the HelloWorld.php module, I get > > > array(6) { > [0]=> > object(otherworld)(1) { > ["stuff"]=> > string(25) "This is some sample stuff" > } > [1]=> > object(set_lang_example)(0) { > } > [2]=> > object(helloworld)(2) { > ["options"]=> > array(2) { > ["example"]=> > string(23) "this is an option value" > ["another"]=> > int(1) > } > ["date"]=> > string(12) "Jul:Sun:2001" > } > [3]=> > object(helloworld)(2) { > ["options"]=> > NULL > ["date"]=> > string(12) "Jul:Sun:2001" > } > [4]=> > object(helloworld)(2) { > ["options"]=> > NULL > ["date"]=> > string(12) "Jul:Sun:2001" > } > [5]=> > object(helloworld)(2) { > ["options"]=> > NULL > ["date"]=> > string(12) "Jul:Sun:2001" > } > > which means it is not sorting, but following > appearance order. > I even added your ksort fix in Page.php where you > said it > should go, and it still just follows appearance > order. > > > _jef > > > ------------------------ > Odysseas Tsatalos wrote: > > > > But you were right that the rest of the code > > isn't behaving the way it was supposed to :-) > > > > I needed to add a ksort right before the end of > the > > IncludeModules function > > > > ksort($this->modules[$_group]); > > > > Keep in mind that the the "example" layout that > > index.php comes with is not following the > > default order but it explicitly alters it. > > -- > Justin Farnsworth > Eye Integrated Communications > 321 South Evans - Suite 203 > Greenville, NC 27858 | Tel: (252) 353-0722 > > _______________________________________________ > binarycloud-dev mailing list > bin...@li... > http://lists.sourceforge.net/lists/listinfo/binarycloud-dev __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ |
From: Justin F. <je...@ey...> - 2001-07-08 17:59:34
|
Odysseas: Thanks Odysseas for making this "official". I did go in and var_dump() stuff in Page to see what was really happening before and after uasort() and the added ksort(). There is still that lingering aspect of "easy" confusion between "load_order" really meaning, for me, "instantiation order", and having nothing to to with "loading order" into the output buffer. So, in any case, rendering will take place in appearance order, unless you specifically change it with a layout template. Still, WHAT I CONSIDER UNACCEPTABLE, in the current state of affairs, is the near-complete loss of generality of writing modules if you wish to communicate with other modules. If you do not put things into global scope, one must know, apriori, for any module, what the appearance order in $bc_page is for the other module to communicate with since the suggested idiom is: $Page->modules['group_name'][2]->get_lookup_table() to avoid going into global scope. General modules will have no idea, aprior, where to look for a particular lookup table, for example, unless one establishes a convention that, say, a lookuptable module is _always_ put into a group named something that is apriori agreed upon, and will be the only module in that group. In that cumbersome way, you can count on finding, say, the data dictionary in the module in the 'data_dictionary' group, at index zero, thus: $Page->modules['data_dictionary'][0]->get_data() So the conventions would have to be, for modules that wish to talk, or expose their properties/methods, would cause the conflicting requirements of 1. Loading in a unique group. 2. Being the only module in that group 3. Having to write a layout template to cause output to be rendered in a potentially spaghetti order, instead of the appearance order. 4. Potentially many module groups There are workarounds to this problem of discovering the module that you wish to talk to, if the communicant module appearance/group is not known apriori. Such workarounds that I have thought of, to at least use temporarily until some kind of better facility is built in, is to add something to $bc_page like, array( 'name' => "EyeLibrary", 'package' => "lib", 'load_order' => "100", 'options' => "appears 2", 'tag' => "MySQL_data_dictionary', ), and then go traverse the $bc_page tree until you find the tag "MySQL_data_dictionary", and having kept track of the ['group_name'] and appearance order, then one could talk like: $Page->modules['group_name_found'][$idx_found]->get_data_dictionary(); THIS IS EXPENSIVE. Now I am working/tinkering on something else in $Page, and probably wasting my time, whereby, using that-there completely_unofficial_tag as above, any module can call $Page->modules_by_tag['tag_wanted']->get_data_dictionary() without having to know, apriori, where the hell that module lives in the $Page->modules[] array. According to Alex, some kind of Manager is contemplated to reduce this intercommunication set of problems to something simple... In the mean time, I want to continue writing modules, and I am depending on intercommunication, so I may just hack something to allow me to keep on a-goin'. Or, just sin, and put things in global scope, and keep on a-goin'. _jef_the_sinner PS: I find it interesting that youse guys are into this with a kind of mindset that a module is a_kind_of_standalone_application and Jason and I went into this with a kind of mindset of a module is an itty-bitty piece of Lego_which_has_to_communicate... We are atomic physicists, and you are molecular biologists ;) --- Odysseas Tsatalos wrote: > > The load_order defines the order of module > instantiation (mnemonic: instantiation == loading) not > the order of display. > The order of display is the same as the order of > appearence in the index.php. > So after you run _IncludeModules > the > > $Page->modules['content'] > > order should be (as you noticed) the same as the order > of appearence. > The default layout will simply iterate over that > array outputing the cached output of each module > and that will produce the desired result. > > In order to see the actual order of modules > instantiation just stick a debugging stmt in the for > loop (function _IncludeModules), right after the > instantiation: > > foreach ($modules[$_group]['load'] as > $pos=>$mod) { > > import("user.mod.$mod[package].$mod[name]"); > $this->modules[$_group][$pos] = new > $mod['name']($mod['options']); > echo("group: $_group, module > $mod[name]\n"); > } > > You will see your debugging output right above the > binarycloud image. > > odysseas ------ -- Justin Farnsworth Eye Integrated Communications 321 South Evans - Suite 203 Greenville, NC 27858 | Tel: (252) 353-0722 |
From: alex b. <en...@tu...> - 2001-07-08 18:27:53
|
> Thanks Odysseas for making this "official". I did > go in and var_dump() stuff in Page to see what was really > happening before and after uasort() and the added ksort(). > There is still that lingering aspect of > "easy" confusion between "load_order" really meaning, > for me, "instantiation order", and having nothing to > to with "loading order" into the output buffer. I think "load" is not the appropriate verb to describe output caught in the outputBuffer - in any case, I suppose we could change the array ket to inst_order or something, but to be honest I think load_order is clear once the concept is explained. > So, in any case, rendering will take place in > appearance order, unless you specifically change it > with a layout template. Exactly. > Still, WHAT I CONSIDER UNACCEPTABLE, in the current > state of affairs, is the near-complete loss of generality > of writing modules if you wish to communicate with > other modules. If you do not put things into I've dealt with that elsewhere, (i.e. yesterday) in other messages. All in good time, there will be an efficient, elegant means of doing module communication. > global scope, one must know, apriori, for any > module, what the appearance order in $bc_page > is for the other module to communicate with since > the suggested idiom is: I suggest for the moment that you use Global variables as a replacement for a manager class, which I will build at some point (after more of core is completed) That is both convenient and conspicuous in your code: $GLOBALS['moo'] is easy to grep for. > According to Alex, some kind of Manager is contemplated > to reduce this intercommunication set of problems to > something simple... Correct. > In the mean time, I want to continue writing modules, > and I am depending on intercommunication, so I may just > hack something to allow me to keep on a-goin'. Or, > just sin, and put things in global scope, and keep on > a-goin'. $GLOBALS all the way. You can do that, and still write good code (each instance of the module would first check to see if a $GLOBALS['stuff'] exists, and use it instead of doing all those queries. A module communication manager is in the pipeline, but other things need to happen first. :) > PS: I find it interesting that youse guys are into this > with a kind of mindset that a module is a_kind_of_standalone_application > and Jason and I went into this with a kind of mindset of > a module is an itty-bitty piece of Lego_which_has_to_communicate... > We are atomic physicists, and you are molecular biologists ;) Ah, but the cool thing about the system is that you can build whatever you like. I actually view modules as Legos, not complete applications. I like to build sets of very simple applications, and connect them to create more complex applications. My dislike for monolithic code is part of the impetus for binarycloud. _alex |
From: alex b. <en...@tu...> - 2001-07-08 18:17:15
|
> Nope, nada, niente, pas de tout, is > load_order having _ANY_ effect on the > disto index.php. It works like a charm for me? Has done since the first crappy pseudocode version of Page that I wrote :) > then the load order still follows the order of the > module appearance in index.php, instead of > the appearance to load_order of YES! but that isn't load order. remember that _load_ (i.e. instantiation) order is _totally_different_ from output order, which is just the order that you define the modules in the page definition. it is necessary to have the two abstracted - so you can do a query that may affect another module _first_, but send output "last" > which means it is not sorting, but following appearance order. > I even added your ksort fix in Page.php where you said it > should go, and it still just follows appearance order. Look at this array: [Page] => page Object ( [title] => binarycloud page title <-- I added the title, btw :) [modules] => Array ( [content] => Array ( [2] => helloworld Object ( [options] => Array ( [example] => this is an option value [another] => 1 ) [date] => Jul:Sun:2001 ) [5] => helloworld Object ( [options] => [date] => Jul:Sun:2001 ) [0] => otherworld Object ( [stuff] => This is some sample stuff ) [4] => helloworld Object ( [options] => [date] => Jul:Sun:2001 ) [3] => helloworld Object ( [options] => [date] => Jul:Sun:2001 ) [1] => set_lang_example Object ( ) ) *** Note how the above is sorted by _output_ order, but the array kays are _load_ order. in Page, output is done by just looping through $this->modules, whereas instantiation is done by sorting on the array keys. [left] => Array ( [1] => helloworld Object ( [options] => [date] => Jul:Sun:2001 ) [0] => helloworld Object ( [options] => [date] => Jul:Sun:2001 ) ) ) Same here. _a |