Thanks so much Marius! The reason for sending out port, hostname and
ssl configuration is that there are several pylons running on
different machines. All of them need to register to a database so that
latter other client can query the database and then make the
connection.

I tried to use config[__file__], but an KeyError exception will be
thrown with location:
    Paste-1.7.5.1-py2.6.egg/paste/registry.py", line 146, in __getitem__
    return self._current_obj()[key]

My code is:
        config_file_path = pylons.config[__file__]
        base_dir = os.path.dirname(config_file_path)

Any clue?
Thanks a lot!
Pan

On Fri, Jan 7, 2011 at 12:18 AM, Marius Gedminas <[email protected]> wrote:
> On Thu, Jan 06, 2011 at 11:26:55PM -0800, pan pan wrote:
>> I need to send out information of port and ssl information through
>> pylons controller.
>
> Why?  To generate a fully-qualified URL?  Use something like
>
>  url('/', _qualified=True)
>
>> These information can easily be found in
>> [server:main] section in the config file. However, it seems that by
>> default a pylons controller can only access [app:main] section. Is
>> there any way that I can get around it?
>
> There's good reason why you can't easily access it.  What if I start
> your application using a different server section with
>
>  paster serve your.ini --server-name=somethingelse
>
> ?  What if I use some other WSGI server -- say, Apache + mod_wsgi --
> instead of paste and therefore configure the port/ssl elsewhere?
>
> If, despite all those warnings, you still want access to the
> [server:main] section, you can do that by parsing the config file again.
> The filename is in config[__file__].  There are also some tricks that
> Paste does with a custom ConfigParser subclass to support nicer
> interpolation; hopefully you won't need that.
>
> Marius Gedminas
> --
> Voodoo Programming:  Things programmers do that they know shouldn't work but
> they try anyway, and which sometimes actually work, such as recompiling
> everything.
> -- Karl Lehenbauer
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAk0mzEQACgkQkVdEXeem1496dACeP4Qz9khrugwiMWF08wJr1Okb
> BrgAn0VdG89dCMneoinQFxtyye9xFSVc
> =hJms
> -----END PGP SIGNATURE-----
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to