Re: is there a good way to stash a global var, that doesn't use g/app_globals

2008-04-29 Thread Wichert Akkerman

Previously Contact 42 wrote:
 what's wrong with a normal python module.


Thread safety.

Wichert.

-- 
Wichert Akkerman [EMAIL PROTECTED]It is simple to make things.
http://www.wiggy.net/   It is hard to make things simple.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: is there a good way to stash a global var, that doesn't use g/app_globals

2008-04-29 Thread Contact 42

Wichert Akkerman wrote:
 Previously Contact 42 wrote:
   
 what's wrong with a normal python module.
 


 Thread safety.

 Wichert
true, but for config stuff that never changes i.e constants, I don't see 
a problem.

Huy

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: is there a good way to stash a global var, that doesn't use g/app_globals

2008-04-29 Thread Jonathan Vanasco

because i won't know the name of appconfig.py

i'm creating a subclassable framework for distribution

DerivedApp/
DerivedApp/model

BaseApp/
BaseApp/lib/helpers

I'm trying to get the BaseApp/lib/helpers to access Globals, so that
it can access objects in DerivedApp/model (which might have overrides)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: is there a good way to stash a global var, that doesn't use g/app_globals

2008-04-29 Thread Alberto Valverde

Jonathan Vanasco wrote:
 I need to run an import like such:

 model = getattr(__import__(g.APPNAME, {}, {}, ['']), 'model')

 the problem is that I get a bunch of errors like this:
 TypeError: No object (name: G) has been registered for this thread

 because of the import order

 can anyone suggest a good way to handle stashing the APPNAME for an
 import of this type?
   

Use g but make sure it is accessed in this way after load_environment is
called.

Alberto

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: is there a good way to stash a global var, that doesn't use g/app_globals

2008-04-29 Thread Ian Bicking

Jonathan Vanasco wrote:
 because i won't know the name of appconfig.py
 
 i'm creating a subclassable framework for distribution
 
 DerivedApp/
 DerivedApp/model
 
 BaseApp/
 BaseApp/lib/helpers
 
 I'm trying to get the BaseApp/lib/helpers to access Globals, so that
 it can access objects in DerivedApp/model (which might have overrides)

You'll need to use a function to get the variable from g.  The only way 
to import things like that is if you use another proxy (the pylons.g and 
pylons.request objects are proxies), and that's really not worth it.

Or, you might be able to do something with subclassing, e.g., have your 
model subclass by DerivedApp.

In the case of helpers, of course, it's pretty easy: just have 
lib.helpers in DerivedApp do from baseapp.lib.helpers import *.  No need 
to get too fancy there.  That is, you might generally find things to be 
easier if you simply phrase BaseApp as a library and not anything more 
fancy.  You could make the library itself mostly a class, and have the 
class instantiated by DerivedApp with whatever customizations it needs.

-- 
Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: is there a good way to stash a global var, that doesn't use g/app_globals

2008-04-29 Thread Jonathan Vanasco

my DerivedApp/model is a subclass of BaseApp/model , etc etc

i've got helpers working as you suggested too

the issue i was hitting, is that in the BaseApp/helpers i'm trying to
create a function that interacts with DerivedApp/Model

i got around it by just passing in model, this will work for now...
i'll need to spend some time working this out before i make BaseApp a
public project
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
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
-~--~~~~--~~--~--~---