Re: Object Oriented Content System - the idea

nospam_at_geniegate.com
Date: 03/16/05


Date: Wed, 16 Mar 2005 05:54:48 GMT

In: <d17r72$14t$1@news4.zwoll1.ov.home.nl>, Henk Verhoeven <news1@phppeanutsREMOVE-THIS.org> wrote:
>I expected php to be smarter then that. The standard php may not have a
>JIT compiler, but that does not say it can not keep some intermediate
>form like bytecode in memory for the next request. Of course it has to
>check the files' timestamps to make sure they are not modified, but
>that's not very time consuming with a proper OS like Linux.

I'm not 100% sure, but if the fact that there is no way to store a variable to
be shared among subsequent requests is any indication I assumed PHP re-parsed
each time.

If you know a way around this, something like a "global map" that is loaded
once and available until the file changes, the web server terminates, or the
cache is rolled over, I'd really like knowing about it.

I realize this isn't proof that it doesn't do the same with byte code, I suppose
one could use the zend compiler or go with commercial products.

> > They even have stuff to populate javabeans directly from a request,
> > real handy stuff.
>I guess peanuts has that too. Actually when i looked at struts it was
>nearly undocumented and very messy code. That was when i was writing my
>second generation of framework in Java, maybe 1998 or so. Then SUN came
>with EJB and such, making everything unecessarily complex.

Ah yes, EJB... I liked the ideas I read about it, but yea, too complex
in my opinion. (I've only played with it to see how suitable it was, never
deployed in a production environment)

The book "Bitter EJB" sort of turned me away from it.
 
>Imho Beans are essentially objects with meta
>data. If you need the objects, why not have the meta data as well? Ok,

Thats the problem and the nice thing about Maps. If all you have is
getXXX and setXXX, it's tempting to just use a map, afterall no more code
to load in etc..

Then, when you need to supply defaults or in some other way cook it, you're
toast.

>kinds of "actions". Furthermore when i decompose one action into several
>children (parts) to compose a page from, the children get a reference to
>the parent action (whole)

I'm having a hard time following this. Do you have multiple Actions
pr. request? Each action potentially adding something to the View?

I understand the parent part, (actually keeping a "Context" of some sort
around is always a good idea, should you ever find yourself in the spot
of "I can't share this data with that method")

So you have:

                 Action
                                View --> Child Action 1 >- [View] -> Child Action 2
         View <--

Where both Action 1 and Action 2 are run when the top level Action is run? (and
a common View passed between them)

I think I can see some logic to this, did something like it once for a middle
tier, each Request (based on an XML document) could invoke multiple actions,
each action added some stuff to a "response" XML document.

This was MVC (I thought of it as batched-rpc) in a different way, the Actions
were more like listeners and could react to any request they wanted. Had the
advantage that you could do multiple things with 1 request. (For instance, add
multiple records)

Disadvantage: every action had to be notified for each request. (Not really a
problem if you had < 40 actions though, the "XML tree" was a custom design,
small & optimized for read-only access with perl regular expressions) The
actions were setup to run in the order you wanted them to. I suppose if you had
many more actions, you'd probably map them to XML paths to avoid notifying a
lot of actions that weren't interested.

Never thought of applying it to urlencoded data though. hmm... interesting
idea! :-)

Am I understanding you correctly? Several actions pr. view?

>am planning to make a utility for checking if a user is authorized for
>an action.

I'm glad you brought this part up, it is one nice thing about having the
"actions as methods" model. If you have multiple controllers (each one
inherits from a base controller):

class Controller {
         // .. common controller methods ..
        public function run() { return($view); }
}

Then you have something like this:

class AdminController extends Controller {
        public function run {
                $this->checkAuth(); // ALL methods need authentication.
                ...
                return(parent::run())
        }
}

It's easy to test for authorization of all the actions, convenient with
related actions. Inconvenient because you need a different "kicker script"
for different areas. (In my case nice, because I can have smaller view.xml
files see below..)

>I thought XML is quite slow becuase it has to be parsed for every
>request ;-)

I agree! thats why I really, really did not want to do it. grrr...

I kept the XML simple, using attributes because they parse faster.
Tried at first to use an .ini, but it just didn't work out on paper. (Ended
up with either a zillion .ini files or really convoluted names)

>Are those parameters dynamic? Or do they have to be set beforehand?
>Dynamic tends to keep things simpler...

Parameters can be set either way. In the XML doc, they are static but
the Actions set them dynamic. Actions are never supposed to send anything
to the client, the only way they should display anything is with a view.

Typically, they set an object or a variable as a parameter and the view takes
that map/object/data and formats it for HTML display using an includeed PHP
file. The PHP view shouldn't try to do anything besides display.

If it weren't for the parse-each-time problem, this would allow you
to embed 1 action into another action or, even a completely different
web application with a different system as you could have it's "view"
display markup for an HTML container in a larger page, basically you
have more control over when/where it is displayed.

If you were to embed it into something using the same system, you'd set the
view as a parameter to a parent view and the parent view would call it's
display() within the HTML container. (Or perhaps one day... XML container)

Jamie

-- 
http://www.geniegate.com                    Custom web programming
guhzo_42@lnubb.pbz (rot13)                User Management Solutions


Relevant Pages

  • Re: Modular PHP
    ... How can I catch an event in PHP. ... Everything is done with XML, so you will want to be familiar with XSLT ... the function itentified by the Handler attribute in the above XML, ... It's also worth noting that all the XML parsing for the request map ...
    (comp.lang.php)
  • Re: Open XML in excel with javascript?
    ... I want to display to ... I'm using simple JavaScript in my PHP file to ... above code will display the XML as raw XML in a new browser ... Make .xls extensions execute as PHP ...
    (comp.lang.javascript)
  • Re: How can I get the message-body ?
    ... > request will contain the XML as reqest-message body ... > How do I get the HTTP request message body? ... requests with arbitrary body data. ... PHP Classes - Free ready to use OOP components written in PHP ...
    (comp.lang.php)
  • Re: Open XML in excel with javascript?
    ... display the file when complete: ... Since the file is .XML, which defaults to the browser to open - the ... Rename the .php extension into .xls ... Make .xls extensions execute as PHP ...
    (comp.lang.javascript)
  • Re: Using browser XSLT transformations
    ... I have a PHP page that generates XML output. ... output through a stylesheet transformation and display this to the ...
    (comp.lang.php)