[web2py] Re: language selector in layout.html

2013-04-09 Thread Adham Hassan
You can use the admin page as a example of how to create a language select. 
I copied the following code with some modifications:

web2py/applications/admin/views/layout.html

span{{=T('Languages')}}/span
{{if hasattr(T,'get_possible_languages_info'):}}
select name=language onchange=var date = new Date();cookieDate=date.
setTime(date.getTime()+(100*24*60*60*1000));document.cookie='language='+this
.options[this.selectedIndex].id+'; expires='+cookieDate+'; path=/';window.
location.reload()
{{for langinfo in sorted([(code,info[1]) for code,info in 
T.get_possible_languages_info().iteritems() if code != 'default']):}}
option {{=T.accepted_language==langinfo[0] and 'selected' or ''}} 
{{='id='+langinfo[0]}} {{=langinfo[1]}}/option
{{pass}}
/select
/span
{{else:}}
/span
{{pass}}

web2py/applications/admin/models/0.py

# set the language
if 'language' in request.cookies and not (request.cookies['language'] is 
None):
T.force(request.cookies['language'].value)

On Thursday, July 5, 2012 4:01:55 AM UTC-7, Fernando J wrote:

 How is set a language selector in layout.html in order to any user may 
 select any language during his session?

 Thanks in advance

 Fernando J.


-- 

--- 
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/groups/opt_out.




[web2py] Re: Windows Service fails with 2 ports on rocket server

2013-04-06 Thread Adham Hassan
Thanks! I can see the issue you're talking about, and decided to add a 
little more to it. The command line starts gluon\widget.py, so I've copied 
some of the code from it that works and added it to winservice.py to fix 
the issue. Specifically:

self.server = main.HttpServer(
ip=options.ip,
port=options.port,
...

To:

if not options.interfaces:
(ip, port) = (options.ip, int(options.port))
else:
first_if = options.interfaces[0]
(ip, port) = first_if[0], first_if[1]
self.server = main.HttpServer(
ip=ip,
port=port,
interfaces=options.interfaces,
...

Thanks again.

On Friday, April 5, 2013 2:20:02 PM UTC-7, Niphlod wrote:

 I's say using nssm.exe will spare you some headaches.

 It seems that there are a few errors in winservice.py

 You can try to patch it.
 self.server = main.HttpServer(
 ip=options.ip,
 port=options.port,
 password=options.password,
 pid_filename=options.pid_filename,
 log_filename=options.log_filename,
 profiler_filename=options.profiler_filename,
 ssl_certificate=options.ssl_certificate,
 ssl_private_key=options.ssl_private_key,
 min_threads=options.minthreads,
 max_threads=options.maxthreads,
 server_name=options.server_name,
 request_queue_size=options.request_queue_size,
 timeout=options.timeout,
 shutdown_timeout=options.shutdown_timeout,
 path=options.folder,
 *interfaces=options.interfaces*
 )
 additions in *bold*

 and include
 ip = '127.0.0.1'
 port = 8000


 in the config file. In theory, when *interfaces* is passed it should 
 override whatever ip or port you pass




-- 

--- 
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/groups/opt_out.




[web2py] Windows Service fails with 2 ports on rocket server

2013-04-05 Thread Adham Hassan
I've found an issue where the Windows Service isn't working the same as the 
command line. I have an options file like this:

import socket
import os

interfaces = [('0.0.0.0',80),('0.0.0.0',443,'server.key','server.crt')]
password = 'testing123'
pid_filename = 'httpserver.pid'
log_filename = 'httpserver.log'
profiler_filename = None
ssl_certificate = 'server.crt'
ssl_private_key = 'server.key'
minthreads = None
maxthreads = None
server_name = socket.gethostname()
request_queue_size = 5
timeout = 30
shutdown_timeout = 5
folder = os.getcwd()
extcron = None
nocron = None

The following command line works, and I can browse by http port 80 and 
https port 443 with no problems:

python web2py.py -L options.py

However, after installing it as a windows service and trying to start it, 
it fails and my Event Viewer says:

Traceback (most recent call last):
  File C:\web2py\gluon\winservice.py, line 51, in SvcDoRun
self.start()
  File C:\web2py\gluon\winservice.py, line 122, in start
ip=options.ip,
AttributeError: 'module' object has no attribute 'ip'

If I add an IP address, it will then say:

Traceback (most recent call last):
  File C:\web2py\gluon\winservice.py, line 51, in SvcDoRun
self.start()
  File C:\web2py\gluon\winservice.py, line 123, in start
port=options.port,
AttributeError: 'module' object has no attribute 'port'

If I add a port, then it will override my 2 ports in instances, and only 
work on 1 port again. To get ssl to work I have to do go to the address 
https://servername:80

Is there any way to fix the windows service to act like the command line?

-- 

--- 
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/groups/opt_out.