Also, you call 'initialize.fillup(db)' (i.e., you pass 'db' as an argument 
to 'fillup'), but your function definition for 'fillup' does not include any 
arguments.

On Tuesday, April 19, 2011 8:56:07 AM UTC-4, 黄祥 wrote:

> please add request variable as parameter on your modules and your function, 
> because the modules can't pass global name like (response, request, db, t, 
> crud, etc) so that you must add it: 
> (not tested)
> e.g. 
> initialize = local_import('initialize')
> initialize.fillup(db, response)
>
> please let me know if you still have this problem.
>
> On Tue, Apr 19, 2011 at 3:56 PM, niknok <[email protected]> wrote:
>
>> I am trying to call this module that contains a series of import_csv_file 
>> statement like so: 
>>
>> from my model, db_history.py I call up a module to import a series of csv 
>> files: 
>>
>> initialize=local_import('initialize')
>> initialize.fillup(db)
>>
>>
>> my modules/fillup.py looks like this: 
>>
>> import os
>>
>> def fillup():
>>     try:
>>         
>> db.question.import_from_csv_file(open(os.path.join(request.folder,'private/db_question.csv'),'r'))
>>     except Exception, e:
>>         print 'oops: %s' % e #XXX
>>         raise e
>>
>>     ...
>>
>>
>> Then I get: "NameError: global name 'request' is not defined"
>>
>> What's weird is that those import statements run from the shell.  They 
>> also work fine if I put them in the model that calls it. But, I'm hoping to 
>> database initialization by CSV from a single module file.
>>
>> I'm pretty sure I'm missing something here. Anyone?
>>
>>
>>
>>
>

Reply via email to