[TransWarp] a peak.naming question

darryl developer at csrules.dyndns.org
Thu Jul 3 17:48:08 EDT 2003


trolling through the mailing list archives I came accross some sample code:

----cut and pasted from mailing list archive----
   DBConn = binding.bindTo("config:MyContacts.Database/")

(Note that the trailing '/' is important for "config:" URLs; it tells the
"config:" context that you want to get the *value* of the property, rather
than a context object for the property namespace rooted at that property
name.  This is actually a simple example of a "composite name"; if the
object found at 'config:MyContacts.Database' is a naming context, then
anything after the '/' would be looked up in *that* context.  This allows
you to bridge across multiple naming services, such that you could have a
configuration property that specified another naming service, in which you
looked up another naming service, and so on...)

Next, add this to a file called 'myApp.ini':

[MyContacts]
Database = naming.LinkRef("pgsql://roche:mypasswd@localhost/Contacts")

And then either set the PEAK_CONFIG environment variable to "myApp.ini",
*or* add this:

PEAK_CONFIG = "myApp.ini"

Near the top of your script, before you make use of any PEAK API calls.

This will cause PEAK to read "myApp.ini" after "peak.ini", to set up or
change configuration properties.  The example above will create a property
called 'MyContacts.Database' upon demand.  The value of that property will
be a symbolic link to the database address.  See:

 >>> from peak.api import *
 >>> PEAK_CONFIG='myApp.ini'
 >>> naming.lookup('config:MyContacts.Database/')
<peak.storage.SQL.PGSQLConnection object at 0x013CBB50>

----end of cut and paste----

now if i follow those steps i get:


>>> from peak.api import *
>>> PEAK_CONFIG='sampleApp.ini'
>>> naming.lookup('config:MyDb.Database/')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: lookup() takes exactly 2 arguments (1 given)
>>>


Any hints ?

-darryl





More information about the PEAK mailing list