You'll have to point update_config() to the full path for dev.cfg.   
It won't automagically find it.

Cheers
CM


On 2 Jun 2007, at 21:19, SamDonaldson wrote:

>
> weird.  I have dev.cfg because turbogears came with this.  Do I have
> to run this from the top level package directory where dev.cfg is
> located?  Doesn't it automatically know where to look for dev.cfg?
> I'm running this from a directory I created called batch under my
> package.
>
> thanks,
>
> sam.
>
> On Jun 2, 5:17 am, Chris Miles <[EMAIL PROTECTED]> wrote:
>> In its simplest form, this is what I do when I write separate scripts
>> that need to share a tg model (tested with a freshly quickstarted
>> project using identity & sqlalchemy):
>>
>> ----
>> from turbogears import update_config
>> from tgtest1.model import User
>>
>> update_config(configfile='dev.cfg', modulename="tgtest1.config")
>>
>> u = User(
>>      user_name       = 'fred',
>>      email_address   = '[EMAIL PROTECTED]',
>>      display_name    = 'Fred',
>>      password        = 'password',
>> )
>> u.flush()
>> ----
>>
>> If I run that in the project directory it creates the user in the
>> sqlite db.
>>
>> I think your problem may be that 'dev.cfg' is not found.  I notice
>> that update_config() is silent if the configfile doesn't actually
>> exist.  If I change the code above to something like update_config
>> (configfile='doesnotexist.cfg', modulename="tgtest1.config") then I
>> get the error you saw.
>>
>> Cheers,
>> CM
>>
>> On 2 Jun 2007, at 06:12, SamDonaldson wrote:
>>
>>
>>
>>> So got passed the module loading problem but running into a dburi
>>> problem when I try to run some sqlalchemy in my batch:
>>
>>> ----------------------
>>> ....
>>> File "build\bdist.win32\egg\sqlalchemy\ext\assignmapper.py", line 6,
>>> in do
>>> File "build\bdist.win32\egg\sqlalchemy\ext\sessioncontext.py", line
>>> 32, in get
>>> urrent
>>> File "build\bdist.win32\egg\sqlalchemy\util.py", line 435, in  
>>> __call__
>>> File "c:\python24\lib\site-packages\TurboGears-1.0.2.2-py2.4.egg
>>> \turbogears\da
>>> base.py", line 50, in create_session
>>>   return sqlalchemy.create_session(bind_to=get_engine())
>>> File "c:\python24\lib\site-packages\TurboGears-1.0.2.2-py2.4.egg
>>> \turbogears\da
>>> base.py", line 39, in get_engine
>>>   dburi = alch_args.pop('dburi')
>>> KeyError: 'pop(): dictionary is empty'
>>> --------------------------
>>
>>> I'm assuming it doesn't have the dburi in the dictionary.  It's  
>>> set in
>>> my dev.cfg as sqlalchemy.dburi.  Could somebody help with this?
>>
>>> thanks.
>>> Sam
>>
>>> On May 28, 2:42 pm, SamDonaldson <[EMAIL PROTECTED]> wrote:
>>>> So, I'm doing the following:
>>>> import sys
>>>> sys.path.append("path_to_package_blah")
>>
>>>> import turbogears
>>>> turbogears.update_config(configfile="dev.cfg",
>>>> modulename="blah.config")
>>
>>>> I did some more debugging and found that when I run the exact same
>>>> commands above, it works in 'tg-admin shell', but does not work
>>>> when I
>>>> run 'python job.py'.  I checked the sys.modules dictionary and  
>>>> could
>>>> not find the key/value for my package in there, but I was able to
>>>> find
>>>> it in the tg-admin shell.  What's the difference here?  I basically
>>>> need to do what tg-admin shell is doing?
>>
>>>> Thanks.
>>
>>>> On May 28, 3:45 am, Chris Miles <[EMAIL PROTECTED]> wrote:
>>
>>>>> Add the full path to package blah to sys.path ?
>>
>>>>> Cheers
>>>>> CM
>>
>>>>> On 28 May 2007, at 04:42, SamDonaldson wrote:
>>
>>>>>> Hello,
>>
>>>>>> In order to run a batch job independent of turbogears, I set the
>>>>>> sys.path.append(...path) and I'm doing the following:
>>
>>>>>> import turbogears
>>>>>> turbogears.update_config(configfile="dev.cfg",
>>>>>> modulename="blah.config")
>>
>>>>>> File "c:\python24\lib\site-packages\setuptools-0.6c5-py2.4.egg
>>>>>> \pkg_resources.p
>>>>>> , line 119, in get_provider
>>>>>>   __import__(moduleOrReq)
>>>>>> ImportError:  no module name blah
>>
>>>>>> I'm getting a 'blah' package error.  My package is named 'blah'
>>>>>> and I
>>>>>> set 'blah' as my package name when setting up turbogears.  I can
>>>>>> even
>>>>>> see this in the PKG-INFO file.  What am I doing wrong here and
>>>>>> what's
>>>>>> a quick way of troubleshooting this?
>>
>>>>>> Thanks,
>>>>>> sam
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to