ITK shell hooks

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

ITK shell hooks

aparajita
Administrator
Active4D fans,

I am in the midst of a major overhaul of the Active4D shells. My goals:

- Better naming conventions (no spaces in method or form names)
- Single code base can migrate easily from 6.5->6.7->6.8
- Three installs: minimal, debug, and extras, so you can include only
the features you want
- Built-in hooks in crucial places so you don't have to modify the shell

My question for today relates to the last item. In the ITK shell I have
added two hooks:

A4D_ITK_PostReceiveHook(inReceiveType: Longint; ioReceiveData: ->BLOB)

This hook is called just after ITK is asked to receive request data,
and allows you to inspect and modify the receive data. There are two
named constants for inReceiveType:

A4D ITK Receive Header = 1
A4D ITK Receive Body = 2

This hook will be called once with inReceiveType = A4D ITK Receive
Header, and once more with inReceiveType = A4D ITK Receive Body if the
request is a POST.


A4D_ITK_PostExecuteHook(
     ioResponseHeaderNames: ->Text Array;
     ioResponseHeaderValues: ->Text Array;
     ioResponse: ->BLOB)

This hook is called just after Active4D executes the request, and
allows you to inspect and modify the result headers and body.

What I want to know is if these two hooks will handle all of the
customization needs you have, or are there others areas that you have
customized that I could add a hook for?

Regards,

    Aparajita
    Victory-Heart Productions
    [hidden email]
    www.aparajitaworld.com



Reply | Threaded
Open this post in threaded view
|

Re: ITK shell hooks

Aristedes Maniatis
This would cover our needs if this data includes the IP address of the
client making the connection and any cookies. This seems like a good
place to do user authorisation checking to ensure they have the correct
rights to see page they request. Then the checking can be done on a
directory basis, rather than having to remember to put it on all the
pages within that directory.

Just a thought: would it be clearer to write two method names-

A4d_ITK_GetRequestHeader ( ->Blob )
A4d_ITK_GetRequestBody ( ->Blob )

or just:

A4d_ITK_GetRequest ( ->BlobHeader; ->BlobBody )



For comparison, WebObjects has three hooks: one on getting the request,
one before executing the page, one after executing the page. But we
only ever use the last one, as it still gives us the opportunity to
return a different page anyway.

Ari Maniatis



On Saturday, October 26, 2002, at 01:41  PM, Aparajita Fishman wrote:

> A4D_ITK_PostReceiveHook(inReceiveType: Longint; ioReceiveData: ->BLOB)
>
> This hook is called just after ITK is asked to receive request data,
> and allows you to inspect and modify the receive data. There are two
> named constants for inReceiveType:
>
> A4D ITK Receive Header = 1
> A4D ITK Receive Body = 2
>
> This hook will be called once with inReceiveType = A4D ITK Receive
> Header, and once more with inReceiveType = A4D ITK Receive Body if the
> request is a POST.



-------------------------->
ish group pty ltd
7 Darghan St Glebe 2037 Australia
phone +61 2 9660 1400   fax +61 2 9660 7400
http www.ish.com.au | email [hidden email]
PGP fingerprint 08 57 20 4B 80 69 59 E2  A9 BF 2D 48 C2 20 0C C8



Reply | Threaded
Open this post in threaded view
|

Re: ITK shell hooks

Perkins, Bradley D
In reply to this post by aparajita
At 11:41 PM -0400 10/25/02, Aparajita Fishman wrote:

>A4D_ITK_PostReceiveHook(inReceiveType: Longint; ioReceiveData: ->BLOB)
>
>This hook is called just after ITK is asked to receive request data,
>and allows you to inspect and modify the receive data. There are two
>named constants for inReceiveType:
>
>A4D ITK Receive Header = 1
>A4D ITK Receive Body = 2

Aparajita,

Will this call appear early enough in the execution cycle that if I
examine the header and decide I need to have ITK (in 4D Code) process
the request I could do so?

Recall from previous forums that I've modified one of the earlier
shells to handle both Active4D and traditional ITK-based web serving
requests. I don't have example code w/ me at this machine, but I did
document the technique in either the old mailing list or the web
forum. Can you have a quick look and let me know if the new shell
improvements will accommodate my modifications?

Thanks,
--
Brad Perkins
DOE ARM Program, TWP Project Office
Los Alamos National Laboratory


Reply | Threaded
Open this post in threaded view
|

Re: ITK shell hooks

Aristedes Maniatis
In reply to this post by aparajita
Would these be pointers, so that we could change them from the hook
method? We might want to do things such as redirect to another page, by
changing the requested URL.

Ari


On Sunday, October 27, 2002, at 12:33  PM, Aparajita Fishman wrote:

> If I change the scheme as noted above, it would become like this:
>
> A4D_ITK_RequestHook(
>     ioHeaderNames: Text Array;
>     ioHeaderValues: Text Array;
>     ioBody: BLOB)



-------------------------->
ish group pty ltd
7 Darghan St Glebe 2037 Australia
phone +61 2 9660 1400   fax +61 2 9660 7400
http www.ish.com.au | email [hidden email]
PGP fingerprint 08 57 20 4B 80 69 59 E2  A9 BF 2D 48 C2 20 0C C8


Reply | Threaded
Open this post in threaded view
|

Re: ITK shell hooks

aparajita
Administrator
In reply to this post by aparajita
>> > If I change the scheme as noted above, it would become like this:
>> >
>> > A4D_ITK_RequestHook(
>> >     ioHeaderNames: Text Array;
>> >     ioHeaderValues: Text Array;
>> >     ioBody: BLOB)

> Would these be pointers, so that we could change them from the hook
> method? We might want to do things such as redirect to another page, by
> changing the requested URL.

It will actually be easier for me to declare three process variables
and populate them with the data:

A4D_RequestHeaderNames
A4D_RequestHeaderValues
A4D_RequestBody

In the hook you can just modify them and I will read them after the
call. But to make things more efficient, I will do it like this:

A4D_ITK_RequestHeaderHook -> Boolean
A4D_ITK_RequestBodyHook -> Boolean

You will return true to indicate you have made changes to the relevant
variables, in which case I will read their contents back into my
internal storage.

Regards,

    Aparajita
    Victory-Heart Productions
    [hidden email]
    www.aparajitaworld.com


Reply | Threaded
Open this post in threaded view
|

Re: ITK shell hooks

aparajita
Administrator
In reply to this post by Perkins, Bradley D
On Saturday, October 26, 2002, at 10:56  AM, Brad Perkins wrote:

> At 11:41 PM -0400 10/25/02, Aparajita Fishman wrote:
>
>> A4D_ITK_PostReceiveHook(inReceiveType: Longint; ioReceiveData: ->BLOB)
>>
>> This hook is called just after ITK is asked to receive request data,
>> and allows you to inspect and modify the receive data.
>
> Will this call appear early enough in the execution cycle that if I
> examine the header and decide I need to have ITK (in 4D Code) process
> the request I could do so?

Unfortunately the answer is no. The hook is being called during
Active4D's processing of the request, so that is too late for you.

Regards,

    Aparajita
    Victory-Heart Productions
    [hidden email]
    www.aparajitaworld.com


Reply | Threaded
Open this post in threaded view
|

Re: ITK shell hooks

Perkins, Bradley D
At 1:40 AM -0500 10/27/02, Aparajita Fishman wrote:

>On Saturday, October 26, 2002, at 10:56  AM, Brad Perkins wrote:
>
>>At 11:41 PM -0400 10/25/02, Aparajita Fishman wrote:
>>
>>>A4D_ITK_PostReceiveHook(inReceiveType: Longint; ioReceiveData: ->BLOB)
>>>
>>>This hook is called just after ITK is asked to receive request
>>>data, and allows you to inspect and modify the receive data.
>>
>>Will this call appear early enough in the execution cycle that if I
>>examine the header and decide I need to have ITK (in 4D Code)
>>process the request I could do so?
>
>Unfortunately the answer is no. The hook is being called during
>Active4D's processing of the request, so that is too late for you.

Thanks for the clarification.
--
Brad Perkins
DOE ARM Program, TWP Project Office
Los Alamos National Laboratory

Reply | Threaded
Open this post in threaded view
|

Re: ITK shell hooks

aparajita
Administrator
In reply to this post by Aristedes Maniatis
On Saturday, October 26, 2002, at 12:05  AM, Aristedes Maniatis wrote:

> This would cover our needs if this data includes the IP address of the
> client making the connection and any cookies. This seems like a good
> place to do user authorisation checking to ensure they have the
> correct rights to see page they request. Then the checking can be done
> on a directory basis, rather than having to remember to put it on all
> the pages within that directory.

Wait a minute...are you talking about authorization based on a
directory? Isn't that exactly what Active4D's built-in security realm
support does?

Regards,

    Aparajita
    Victory-Heart Productions
    [hidden email]
    www.aparajitaworld.com


Reply | Threaded
Open this post in threaded view
|

Re: ITK shell hooks

Aristedes Maniatis
Well, yes. I've just gone and reread that section of your manual. I had
just assumed that your implementation of Realms was linked to users
defined by the operating system or in 4D. But your authentication
handler is perfect, allowing us to set sessions, cookies and query the
database. We have written this stuff by hand anyway and it wasn't
difficult, but this solution is much neater and easier to maintain.

Amazing what is in Active4D that I haven't even touched upon.


Ari Maniatis


On Monday, October 28, 2002, at 11:47  AM, Aparajita Fishman wrote:
>
> Wait a minute...are you talking about authorization based on a
> directory? Isn't that exactly what Active4D's built-in security realm
> support does?



-------------------------->
ish group pty ltd
7 Darghan St Glebe 2037 Australia
phone +61 2 9660 1400   fax +61 2 9660 7400
http www.ish.com.au | email [hidden email]
PGP fingerprint 08 57 20 4B 80 69 59 E2  A9 BF 2D 48 C2 20 0C C8


Reply | Threaded
Open this post in threaded view
|

Re: ITK shell hooks

aparajita
Administrator
On Monday, October 28, 2002, at 04:31  AM, Aristedes Maniatis wrote:

> On Monday, October 28, 2002, at 11:47  AM, Aparajita Fishman wrote:
>>
>> Wait a minute...are you talking about authorization based on a
>> directory? Isn't that exactly what Active4D's built-in security realm
>> support does?
>
> Well, yes. I've just gone and reread that section of your manual. I
> had just assumed that your implementation of Realms was linked to
> users defined by the operating system or in 4D.
> But your authentication handler is perfect, allowing us to set
> sessions, cookies and query the database. We have written this stuff
> by hand anyway and it wasn't difficult, but this solution is much
> neater and easier to maintain.
>
> Amazing what is in Active4D that I haven't even touched upon.

This is what I get for spending three months writing documentation!  ;-)

Seriously folks, there's an important lesson here: if you are thinking
of implementing a feature, take a good look at the docs to see if I
have already done it for you. There is a huge amount of stuff in
Active4D that you probably haven't looked at.

For example, I'm curious...how many people are using the new string
processing commands, specially the 'param text' command?

Regards,

    Aparajita
    Victory-Heart Productions
    [hidden email]
    www.aparajitaworld.com