Let me attach the new code or are you able to see the git hub. If so I will 
push to that.

Thank you,
Jeff Riley

> On Jul 11, 2016, at 7:29 AM, Marlysson Silva <marlyss...@gmail.com> wrote:
> 
> I think that I know where are missing pytz.. you put library in controller 
> define_timezone() ..
> 
> Em segunda-feira, 11 de julho de 2016 09:19:21 UTC-3, Jeff Riley escreveu:
>> 
>> Hello Marlysson.  I am getting the following error.  I have removed the 
>> module pytx_timezone, and I have verified that I have pip installed pytz.  
>> Not sure what else to dheck.
>> 
>> <type 'exceptions.ImportError'> No module named pytz
>> 
>> 
>> 
>>> On Sunday, July 10, 2016 at 4:39:30 PM UTC-5, Marlysson Silva wrote:
>>> You try to make this:
>>> 
>>> 1. Add library in the front-end to get user timezone ( this code need to be 
>>> in the first page that user access ), to get timezone first.
>>> 
>>> - https://bitbucket.org/pellepim/jstimezonedetect/src
>>> {{if timezone_is_unknown: }}
>>> <script>
>>>   $(function() {
>>>     var tz_name = jstz.determine();
>>>     $.get("{{=URL('default', 'define_timezone')}}", tz_name);
>>>   });
>>> </script>
>>> 
>>> 
>>> 2. Add  the controller responsible by determine timezone:
>>> 
>>> def define_timezone():
>>>     """Call ajax to determine user timezone"""
>>> 
>>>     tz_name = request.vars.name
>>> 
>>>     from pytz import all_timezones_set
>>> 
>>>     if tz_name in all_timezones_set:
>>>         session.user_timezone = tz_name
>>> 
>>> 
>>> 3. And in the your model you put:
>>> 
>>> from pytz import timezone
>>> 
>>> timezone_user = session.user_timezone or timezone('UTC')
>>> timezone_is_unknown = session.user_timezone is None
>>> 
>>> 
>>> 4. Use in the your model related with timezone:
>>> 
>>> IS_DATETIME(format=("%m-%d-%Y %H:%H), timezone = 
>>> pytz.timezone(timezone_user) )
>>> 
>>> There are other form, that is insert everything in UTC datetime and create 
>>> a function responsible to convert this timezone in UTC datetime inserted in 
>>> database. Just delayed a lot of kkkk, but yet I will create a 
>>> web2py_timezone_starter with app ready to receive apps that are handled by 
>>> timezones.
>>> 
>>> I'm creating this application to demonstrate this, if you want look..
>>> 
>>> http://marlysson.pythonanywhere.com/timezone
>>> 
>>> At app, the Hour "your PC" is datetime.now()  simulating datetime of user, 
>>> just that it's datetime of the pythonanywhere.
>>> 
>>> Em quinta-feira, 7 de julho de 2016 16:19:10 UTC-3, Jeff Riley escreveu:
>>>> 
>>>> Hello all.  Me again.  I have run into an interesting issue.  I have 
>>>> installed and followed niphlod's w2p_timezone_plugin.  In order to make it 
>>>> work on my local PC I need to setup my db.py as follows.
>>>> 
>>>> import pytz
>>>> user_timezone = session.plugin_timezone_tx or 'UTC'
>>>> 
>>>> 
>>>> db.define_table('events',
>>>>                 Field('event_time', 'datetime', default = request.now, 
>>>> update = request.now,
>>>>                     requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), 
>>>> timezone=pytz.timezone(user_timezone))),
>>>> 
>>>> 
>>>> But to get it to work on pythonanywhere.com I have to setup my db.py as 
>>>> follows.  Any ideas why?
>>>> 
>>>> 
>>>> import pytz
>>>> 
>>>> db.define_table('events',
>>>>                 Field('event_time', 'datetime', default = request.now, 
>>>> update = request.now,
>>>>                     requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), 
>>>> timezone=pytz.timezone("US/Central"))),
> 
> -- 
> 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 a topic in the Google 
> Groups "web2py-users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/web2py/wL2y7s-FJWU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to