Re: [fw-general] [Zend][Controller][Action] unsetParam() and some suggestions

2007-06-09 Thread Shekar C Reddy

Matthew,

I notice, doing setParam( $key, null ) does not unset the parameter even
with RC2 - does not even set it to null :(

  - $this->_setParam(  $key, null );
  - $this->_request->setParam( $key, null );
  - $this->getRequest()->setParam( $key, null );


None of the above works!

Thanks,




On 3/22/07, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:


-- Shekar C Reddy <[EMAIL PROTECTED]> wrote
(on Wednesday, 21 March 2007, 09:34 PM -0400):
> 1. Perhaps, the setParam() method could be enhanced to unset/blow-off
the key
> if the value passed is null... We don't want any keys with null values
> lingering around - that would increase complexity as we have to deal
with null
> values! I know getParam() returns default null if the key does not exist
but
> when I invoke getAllParams() to traverse the array, I may end up with
some keys
> that have null values :(  Or maybe, with a third/default $unset argument
if the
> value passed is null, like so:
>
> Signature: _setParam( $key, $value, $unset = false )
> Usage: _setParam( $key, null, true )
>
> [if $value = null && $unset = true, blow off the key]

Good plan. I'll implement this soon.


> 2. Understandable. I did not request to eliminate the
> getRequest/getResponse methods - they are there to serve as an API to
> external objects. What I was referring to was invoking of these
> methods inside Zend_Controller_Action class script to access the
> protected request/response vars that are declared/defined right inside
> the same class. That would degrade performance (you may try
> load-testing the application). These vars could, instead, be accessed
> directly inside Zend_Controller_Action script:
>
> Eg: $this->_request->setParam( ... )

The point of accessors is to normalize access to properties. Using the
properties directly within methods such as render(), _forward(), etc.
could cause issues later for those who *do* override the
getRequest()/getResponse() accessors -- basically, we'd be breaking
*other* people's apps.

As a performance optimization, typically what I do is, if needing the
property more than once, I grab it like this:

   $request = $this->getRequest();

which will cut down on the number of times it's retrieved by the
accessor. This is the only concession I'll make in this regard.


>
> On 3/21/07, Matthew Weier O'Phinney <[EMAIL PROTECTED] > wrote:
>
> -- Shekar C Reddy < [EMAIL PROTECTED]> wrote
> (on Wednesday, 21 March 2007, 06:00 AM -0400):
> > 1. There is no method to unset a param in action controller or its
> request
> > class. We need a unsetParam() method in action/request.
>
> You can always pass a null to setParam():
>
>$this->setParam('someKey', null);
>
> The controller parameters are not really intended to be a general
> purpose storage mechanism; they're primarily for pushing values and
> objects from the front controller down through the controller chain
> (router, dispatcher, action controllers). I personally feel that
> if you're needing something like that, use a Zend_Config object in
> read/write mode and push it in either the registry or as a
controller
> param.
>
> > 2. I see usage of getRequest() and getResponse() methods inside
the
> > action class although these vars are sitting right inside the
class
> > itself (protected $_request, $_response) that can be accessed
directly
> > instead of invoking a method to access them. Accessing them
directly
> > inside the action class should improve performance.
>
> This is true. However, the accessors are there for cases where the
> developer may want to wrap some logic around retrieving these
objects --
> perhaps grabbing them from a registry, for instance. That said, when
I
> know that there's no such logic in classes I'm using, I access them
> directly from the class properties.
>
> --
> Matthew Weier O'Phinney
> PHP Developer| [EMAIL PROTECTED]
> Zend - The PHP Company   | http://www.zend.com/
>
>

--
Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/



Re: [fw-general] [Zend][Controller][Action] unsetParam() and some suggestions

2007-03-22 Thread Shekar C Reddy

The point of accessors is to normalize access to properties. Using the
properties directly within methods such as render(), _forward(), etc.
could cause issues later for those who *do* override the
getRequest()/getResponse() accessors -- basically, we'd be breaking
*other* people's apps.

Ok. I did not comprehend what you were saying earlier and it's clear now.


As a performance optimization, typically what I do is, if needing the
property more than once, I grab it like this:

  $request = $this->getRequest();

which will cut down on the number of times it's retrieved by the
accessor.


Yes, I use that technique, too.

Thanks!





On 3/22/07, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:


-- Shekar C Reddy <[EMAIL PROTECTED]> wrote
(on Wednesday, 21 March 2007, 09:34 PM -0400):
> 1. Perhaps, the setParam() method could be enhanced to unset/blow-off
the key
> if the value passed is null... We don't want any keys with null values
> lingering around - that would increase complexity as we have to deal
with null
> values! I know getParam() returns default null if the key does not exist
but
> when I invoke getAllParams() to traverse the array, I may end up with
some keys
> that have null values :(  Or maybe, with a third/default $unset argument
if the
> value passed is null, like so:
>
> Signature: _setParam( $key, $value, $unset = false )
> Usage: _setParam( $key, null, true )
>
> [if $value = null && $unset = true, blow off the key]

Good plan. I'll implement this soon.


> 2. Understandable. I did not request to eliminate the
> getRequest/getResponse methods - they are there to serve as an API to
> external objects. What I was referring to was invoking of these
> methods inside Zend_Controller_Action class script to access the
> protected request/response vars that are declared/defined right inside
> the same class. That would degrade performance (you may try
> load-testing the application). These vars could, instead, be accessed
> directly inside Zend_Controller_Action script:
>
> Eg: $this->_request->setParam( ... )

The point of accessors is to normalize access to properties. Using the
properties directly within methods such as render(), _forward(), etc.
could cause issues later for those who *do* override the
getRequest()/getResponse() accessors -- basically, we'd be breaking
*other* people's apps.

As a performance optimization, typically what I do is, if needing the
property more than once, I grab it like this:

   $request = $this->getRequest();

which will cut down on the number of times it's retrieved by the
accessor. This is the only concession I'll make in this regard.


>
> On 3/21/07, Matthew Weier O'Phinney <[EMAIL PROTECTED] > wrote:
>
> -- Shekar C Reddy < [EMAIL PROTECTED]> wrote
> (on Wednesday, 21 March 2007, 06:00 AM -0400):
> > 1. There is no method to unset a param in action controller or its
> request
> > class. We need a unsetParam() method in action/request.
>
> You can always pass a null to setParam():
>
>$this->setParam('someKey', null);
>
> The controller parameters are not really intended to be a general
> purpose storage mechanism; they're primarily for pushing values and
> objects from the front controller down through the controller chain
> (router, dispatcher, action controllers). I personally feel that
> if you're needing something like that, use a Zend_Config object in
> read/write mode and push it in either the registry or as a
controller
> param.
>
> > 2. I see usage of getRequest() and getResponse() methods inside
the
> > action class although these vars are sitting right inside the
class
> > itself (protected $_request, $_response) that can be accessed
directly
> > instead of invoking a method to access them. Accessing them
directly
> > inside the action class should improve performance.
>
> This is true. However, the accessors are there for cases where the
> developer may want to wrap some logic around retrieving these
objects --
> perhaps grabbing them from a registry, for instance. That said, when
I
> know that there's no such logic in classes I'm using, I access them
> directly from the class properties.
>
> --
> Matthew Weier O'Phinney
> PHP Developer| [EMAIL PROTECTED]
> Zend - The PHP Company   | http://www.zend.com/
>
>

--
Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/



Re: [fw-general] [Zend][Controller][Action] unsetParam() and some suggestions

2007-03-22 Thread Matthew Weier O'Phinney
-- Shekar C Reddy <[EMAIL PROTECTED]> wrote
(on Wednesday, 21 March 2007, 09:34 PM -0400):
> 1. Perhaps, the setParam() method could be enhanced to unset/blow-off the key
> if the value passed is null... We don't want any keys with null values
> lingering around - that would increase complexity as we have to deal with null
> values! I know getParam() returns default null if the key does not exist but
> when I invoke getAllParams() to traverse the array, I may end up with some 
> keys
> that have null values :(  Or maybe, with a third/default $unset argument if 
> the
> value passed is null, like so:
>  
> Signature: _setParam( $key, $value, $unset = false )
> Usage: _setParam( $key, null, true )
>  
> [if $value = null && $unset = true, blow off the key]

Good plan. I'll implement this soon.


> 2. Understandable. I did not request to eliminate the
> getRequest/getResponse methods - they are there to serve as an API to
> external objects. What I was referring to was invoking of these
> methods inside Zend_Controller_Action class script to access the
> protected request/response vars that are declared/defined right inside
> the same class. That would degrade performance (you may try
> load-testing the application). These vars could, instead, be accessed
> directly inside Zend_Controller_Action script:
>  
> Eg: $this->_request->setParam( ... )

The point of accessors is to normalize access to properties. Using the
properties directly within methods such as render(), _forward(), etc.
could cause issues later for those who *do* override the
getRequest()/getResponse() accessors -- basically, we'd be breaking
*other* people's apps.

As a performance optimization, typically what I do is, if needing the
property more than once, I grab it like this:

$request = $this->getRequest();

which will cut down on the number of times it's retrieved by the
accessor. This is the only concession I'll make in this regard.


>  
> On 3/21/07, Matthew Weier O'Phinney <[EMAIL PROTECTED] > wrote:
> 
> -- Shekar C Reddy < [EMAIL PROTECTED]> wrote
> (on Wednesday, 21 March 2007, 06:00 AM -0400):
> > 1. There is no method to unset a param in action controller or its
> request
> > class. We need a unsetParam() method in action/request.
> 
> You can always pass a null to setParam():
> 
>$this->setParam('someKey', null);
> 
> The controller parameters are not really intended to be a general
> purpose storage mechanism; they're primarily for pushing values and
> objects from the front controller down through the controller chain
> (router, dispatcher, action controllers). I personally feel that
> if you're needing something like that, use a Zend_Config object in
> read/write mode and push it in either the registry or as a controller
> param.
> 
> > 2. I see usage of getRequest() and getResponse() methods inside the
> > action class although these vars are sitting right inside the class
> > itself (protected $_request, $_response) that can be accessed directly
> > instead of invoking a method to access them. Accessing them directly
> > inside the action class should improve performance.
> 
> This is true. However, the accessors are there for cases where the
> developer may want to wrap some logic around retrieving these objects --
> perhaps grabbing them from a registry, for instance. That said, when I
> know that there's no such logic in classes I'm using, I access them
> directly from the class properties.
> 
> --
> Matthew Weier O'Phinney
> PHP Developer| [EMAIL PROTECTED]
> Zend - The PHP Company   | http://www.zend.com/
> 
> 

-- 
Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/


Re: [fw-general] [Zend][Controller][Action] unsetParam() and some suggestions

2007-03-21 Thread Shekar C Reddy

Matthew,

1. Perhaps, the setParam() method could be enhanced to unset/blow-off the
key if the value passed is *null*... We don't want any keys with null values
lingering around - that would increase complexity as we have to deal with
null values! I know getParam() returns default null if the key does not
exist but when I invoke getAllParams() to traverse the array, I may end up
with some keys that have null values :(  Or maybe, with a third/default
$unset argument if the value passed is null, like so:

Signature: _setParam( $key, $value, $unset = false )
Usage: _setParam( $key, null, true )

[if $value = null && $unset = true, blow off the key]

2. Understandable. I did not request to eliminate the getRequest/getResponse
methods - they are there to serve as an API to *external *objects. What I
was referring to was invoking of these methods inside *Zend_Controller_Action
*class script to access the protected request/response vars that are
declared/defined right inside the same class. That would degrade performance
(you may try load-testing the application). These vars could, instead, be
accessed directly inside Zend_Controller_Action script:

Eg: $this->_request->setParam( ... )

Regards,




On 3/21/07, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:


-- Shekar C Reddy <[EMAIL PROTECTED]> wrote
(on Wednesday, 21 March 2007, 06:00 AM -0400):
> 1. There is no method to unset a param in action controller or its
request
> class. We need a unsetParam() method in action/request.

You can always pass a null to setParam():

   $this->setParam('someKey', null);

The controller parameters are not really intended to be a general
purpose storage mechanism; they're primarily for pushing values and
objects from the front controller down through the controller chain
(router, dispatcher, action controllers). I personally feel that
if you're needing something like that, use a Zend_Config object in
read/write mode and push it in either the registry or as a controller
param.

> 2. I see usage of getRequest() and getResponse() methods inside the
> action class although these vars are sitting right inside the class
> itself (protected $_request, $_response) that can be accessed directly
> instead of invoking a method to access them. Accessing them directly
> inside the action class should improve performance.

This is true. However, the accessors are there for cases where the
developer may want to wrap some logic around retrieving these objects --
perhaps grabbing them from a registry, for instance. That said, when I
know that there's no such logic in classes I'm using, I access them
directly from the class properties.

--
Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/



Re: [fw-general] [Zend][Controller][Action] unsetParam() and some suggestions

2007-03-21 Thread Matthew Weier O'Phinney
-- Shekar C Reddy <[EMAIL PROTECTED]> wrote
(on Wednesday, 21 March 2007, 06:00 AM -0400):
> 1. There is no method to unset a param in action controller or its request
> class. We need a unsetParam() method in action/request.

You can always pass a null to setParam():

$this->setParam('someKey', null);

The controller parameters are not really intended to be a general
purpose storage mechanism; they're primarily for pushing values and
objects from the front controller down through the controller chain
(router, dispatcher, action controllers). I personally feel that
if you're needing something like that, use a Zend_Config object in
read/write mode and push it in either the registry or as a controller
param.

> 2. I see usage of getRequest() and getResponse() methods inside the
> action class although these vars are sitting right inside the class
> itself (protected $_request, $_response) that can be accessed directly
> instead of invoking a method to access them. Accessing them directly
> inside the action class should improve performance.

This is true. However, the accessors are there for cases where the
developer may want to wrap some logic around retrieving these objects --
perhaps grabbing them from a registry, for instance. That said, when I
know that there's no such logic in classes I'm using, I access them
directly from the class properties.

-- 
Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/


[fw-general] [Zend][Controller][Action] unsetParam() and some suggestions

2007-03-21 Thread Shekar C Reddy

1. There is no method to unset a param in action controller or its request
class. We need a unsetParam() method in action/request.

2. I see usage of getRequest() and getResponse() methods inside the action
class although these vars are sitting right inside the class itself
(protected $_request, $_response) that can be accessed directly instead of
invoking a method to access them. Accessing them directly inside the action
class should improve performance.

http://framework.zend.com/issues/browse/ZF-1097

Regards,