Anthony, I added the line to a modeland it still doesn't work. Any other 
thoughts?

Also, why is it not recommended for production?




On Friday, January 3, 2014 8:26:13 AM UTC-8, Anthony wrote:
>
> It's the same with any Python module -- they only get loaded once on first 
> import. web2py does include a feature to automatically re-load upon change, 
> though not recommended for production. In a model file (before any imports):
>
> from gluon.custom_import import track_changes; track_changes(True)
>
>
> See 
> http://web2py.com/books/default/chapter/29/04/the-core#Accessing-the-API-from-Python-modules
> .
>
> Anthony
>
> On Friday, January 3, 2014 11:14:36 AM UTC-5, Brando wrote:
>>
>> I have the following code to insert a dictionary into my sqlite db from a 
>> module. 
>>
>> #!/usr/bin/env python
>> # -*- coding: utf-8 -*-
>>
>> from gluon import current
>> from gluon.dal import DAL, Field
>> from gluon.sqlhtml import SQLFORM
>> from gluon.validators import IS_NOT_EMPTY, IS_EMAIL, IS_LENGTH
>>
>> class Parse(object):
>>
>> def __init__(self):
>> self.db = current.db
>> # self.db = 
>> DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
>> # self.db = DAL("sqlite://mydb.sqlite")
>> self.session = current.session
>> self.request = current.request
>> self.response = current.response
>> self.cache = current.cache
>> self.maketable()
>> self.settings()
>> # self.set_validators()
>> self.addtodb()
>>
>> def settings(self):
>>
>> self.settings = {
>> 'filepath': 'tom', #File path.
>> 'filename': 'dick', #Name of the file being processed.
>> 'hostname': 'harry', #What is the hostname?
>> }
>>
>>
>> def maketable(self):
>> self.testrecord = self.db.define_table("testrecord",
>> Field("filepath"),
>> Field("filename"),
>> Field("hostname")
>>  )
>>
>> def addtodb(self):
>> self.db.testrecord.insert(**self.settings)
>> self.testrecord = self.db().select(self.db.testrecord.ALL)
>> return self.testrecord
>>
>>
>> If I change either tom, dick or harry; save the file, and reload my 
>> browser; I still get tom, dick and harry being returned to the screen. 
>>  HOWEVER, if I stop the web2py server, quit web2py (osx), and restart 
>> web2py I will get my new values when I reload the url.  
>>
>> Any ideas what is going on here?
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to