Namespace issues
| From: | Kristian Koehntopp | Date: | Thu, 16 May 2002 08:56:45 +0000 |
| Subject: | Namespace issues | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-6125@lists.php.net to get a copy of this message | ||
At the moment, I am testing XML/Transformer.php by implementing a few
classes that make use of it. As a typical problem I tried to duplicate the
functionality described in
http://docs.roxen.com/roxen/2.2/creator/text/foldlist.tag
This system of tags implements a foldable <dl/> called foldlist
<fl/>. A <fl/> is is written
<fl>
<ft>Head 1</ft>
<fd>Data 1</fd>
<ft>Head 2</ft>
<fd>Data 2</fd>
</fl>
and is rendered
[+] Head1
[+] Head2
The [+] are clickable and expand to
[-] Head 1
Data 1
[+] Head 2
In writing such code, I encountered several problems which need
a PEAR global solution, since they are namespace issues that
will arise again in all classes that have similar requirements. The
issues are
1. Use of the URL namespace of the webserver
2. Use of the GPC namespace
3. Use of sessions (enabling them)
4. Use of sessions and GLOBALS namespace
Please read on:
1. Image namespace issues/URL namespace issues
The foldlist requires the use of two URLs for images, the
folded and unfolded arrows, denoted [+] and [-] in my ASCII
representation.
At the moment, I store them as /internal-pear/foldlist/folded.gif
and /internal-pear/foldlist/unfolded.gif.
That is, as a PEAR global rule,
"For the admin/application developer:
PEAR reserves the right to use the /internal-pear branch in
your webservers URL namespace tree. Your application must
not use URLs starting with /internal-pear for its own
purposes.
For PEAR developers:
Any PEAR class that needs URLs may use names below the
/internal-pear/<classname>/ branch in a webservers URL
namespace tree."
What are your opinions on this?
2. GET/POST/COOKIE (GPC) namespace issues
The foldlist requires self-submitting URLs with GET
parameters to activate state changes from folded to unfolded
and back. These parameters names must not clash with
application used variable names.
At the moment, I use internal_pear_foldlist[].
That is, as a PEAR global rule,
"For the admin/application developer:
PEAR reserves the right to use GPC variable names
starting with internal_pear on any page. Your application
must not use GPC variables starting with internal_pear.
For PEAR developers:
Any PEAR class that needs GPC parameters may use names
starting with internal_pear_<classname> in the GPC
namespace.
Again, your opinions on this?
3. Session storage and session use
The foldlist needs to store state, and I want to use sessions
to do so. I do not want to interfere with session management
of the application, and I want to thread lightly on the need
to include class code on every page, which would be necessary
when an object becomes part of the session.
What is the current way of the PHP session handler regarding
the storage of objects in a session? That is,
a) what happens when an object is part of the session and
the class include for that object has not been loaded
on all pages? Does the object keep its class and methods
on the following pages?
b) when does the class of an object has to be included for
such objects are part of the session, i.e. what happens
when a class include is being loaded after the session_start()
call? When does a class have to be included when the
session is auto started in php.ini? Does one have to
include the class code in auto_prepend_file in such
cases?
On a PEAR global scale:
When a PEAR class needs sessions, what kind of code is
required to check that sessions are not already started, and
if not, to start the session? Should PEAR classes start
sessions themselves or should the session management
configuration be left to the PEAR class user
(administrator/developer) and only be noted as a requirement?
Should PEAR classes store their objects as part of the session
or should they store a classless hash as part of the session and
use that hash instead of their object-internal data, in order
to keep the size of the session small and in order to save code
includes which must be part of each and every page?
What is, in your opinion, the correct way to handle this?
4. Namespace in Sessions and in GLOBALS
How do we handle namespace issues in sessions? When a PEAR
class wants to use variables that have to become of the session,
or of the global namespace, what names do we reserve here?
Again, I propose internal_pear_<classname> for use by PEAR.
What are your opinions on this?
Kristian
--
http://www.amazon.de/exec/obidos/wishlist/18E5SVQ5HJZXG