get_appsettings() equivalent under Pyramid 1.2?

131 views
Skip to first unread message

Greg Slodkowicz

unread,
Jan 9, 2012, 10:52:07 AM1/9/12
to pylons-discuss
Hi all,
I would like to make a script to populate the database in my app,
similar to the one in this tutorial:
https://github.com/Pylons/pyramid/blob/master/docs/tutorials/wiki2/src/models/tutorial/scripts/populate.py
It seems that the pyramid.paster.get_appsettings() method is not
available in the version of Pyramid I'm using (1.2 -- I guess it would
be a good idea in general to migrate to 1.3 but right now I'm under
really tight time constraints). Is there an easy way to parse the
config under 1.2?

Best regards,
Greg

Jason

unread,
Jan 9, 2012, 3:17:23 PM1/9/12
to pylons-...@googlegroups.com

Michael Merickel

unread,
Jan 9, 2012, 3:21:27 PM1/9/12
to pylons-...@googlegroups.com
The pyramid.paster.get_appsettings(inipath) called as

get_appsettings('development.ini#myapp')

is implemented as follows:


from paste.deploy import appconfig
config_name, section = inipath.split('#', 1)
here_dir = os.getcwd()
return appconfig(config_name, name=section, relative_to=here_dir)

On Mon, Jan 9, 2012 at 2:17 PM, Jason <ja...@deadtreepages.com> wrote:

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pylons-discuss/-/_IZ_JUbo-EcJ.

To post to this group, send email to pylons-...@googlegroups.com.
To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.

Greg Slodkowicz

unread,
Jan 11, 2012, 1:26:59 PM1/11/12
to pylons-...@googlegroups.com
On Mon, Jan 9, 2012 at 9:21 PM, Michael Merickel <mmer...@gmail.com> wrote:
> The pyramid.paster.get_appsettings(inipath) called as
>
> get_appsettings('development.ini#myapp')
> is implemented as follows:
>
> from paste.deploy import appconfig
> config_name, section = inipath.split('#', 1)
> here_dir = os.getcwd()
> return appconfig(config_name, name=section, relative_to=here_dir)

Great, I had to to tune some things (appconfig() wanted
'config:development.ini#main' instead of 'development.ini#myapp') but
it worked in the end. Many thanks to both of you!

-Greg

Reply all
Reply to author
Forward
0 new messages