Right, but, now you need to specify yourself as the namespace every time you set a variable. That's adding a lot of bulk. Robin On 5/3/07, Syscrusher <syscrusher@4th.com> wrote:
On Thursday 03 May 2007 14:29, Robin Monks wrote:
New names for variable functions--
Here's a suggestion:
string variable(string $name, string $namespace='', string $value=NULL)
Semantics:
variable($name) returns the value of the specified variable in the current module's namespace (or the Drupal system namespace, if you prefer), or returns the default if not defined, or returns NULL if no default
variable($name, $namespace) returns the value of the specified variable in the specified namespace, or returns the default if not defined, or returns NULL if no default
variable($name, $namespace, $value) stores $value for the specified variable in the specified namespace, if $value is not null. Returns $value as-stored, both to preserve semantic consistency AND to reflect any data changes done by the variable-handling code (for instance, if it did an implied trim()). For now, probably a straight pass-through.
And we add one function that typically would be used only by deinstalls:
boolean variable_unset(string $name, string $namespace) removes the specified variable from storage permanently, returning TRUE if successful or if the variable already didn't exist, FALSE if there was some kind of database error or if the $namespace didn't exist. In other words, missing $name in valid $namespace is okay, just a no-op, but invalid $namespace is an error condition.
The behavior of variable() is consistent with similar functions I've worked with in other environments, such as REXX's GLOBALV function on mainframes. It also would allow a fairly easy wrapper for legacy compatibility.
Scott
--
------------------------------------------------------------------------------- Syscrusher (Scott Courtney) Drupal page: http://drupal.org/user/9184 syscrusher at 4th dot com Home page: http://4th.com/
-- Robin Monks @ www.civicspacelabs.org @ www.gmking.org Fax: (419) 791-8076 "Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems." ~IRC