[web2py] truly global/single instance variable

2014-07-26 Thread lucas
hello one and all,

i need a little advice.  i have a rather large table that i use to lookup 
hard unchangeable values.  essentially is a big list of smaller lists.

i know that each user has his/hers own session and that this lookup list is 
probably opened and stored multiple times, one for each user.

in the interest of efficiency and lower memory usage, how can i create a 
single variable that loads a single instance of this list of lists that all 
users and all sessions use?

thanx in advance and have a great day.  lucas 

-- 
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.


[web2py] Re: truly global/single instance variable

2014-07-26 Thread Leonel Câmara
An easy way would be to store it in cache.ram. However, I would have to 
profile this to see if you have much of a performance gain versus simply 
defining the list in your models. It would definitely save memory but 
memory isn't the only concern.

-- 
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.


[web2py] Re: truly global/single instance variable

2014-07-26 Thread Anthony
Maybe put it in a module and import it.

On Saturday, July 26, 2014 2:59:55 AM UTC-4, lucas wrote:
>
> hello one and all,
>
> i need a little advice.  i have a rather large table that i use to lookup 
> hard unchangeable values.  essentially is a big list of smaller lists.
>
> i know that each user has his/hers own session and that this lookup list 
> is probably opened and stored multiple times, one for each user.
>
> in the interest of efficiency and lower memory usage, how can i create a 
> single variable that loads a single instance of this list of lists that all 
> users and all sessions use?
>
> thanx in advance and have a great day.  lucas 
>

-- 
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.


[web2py] Re: truly global/single instance variable

2014-07-26 Thread lucas
i have it in a module and under that module i have the variable setup as a 
global variable.  wherein, if the variable is empty upon using it, i load 
the list of lists from a text file.  if it is not empty, then i just use 
it.  so in that case, is there just the single instance in memory, no 
matter the number of users or sessions?  thanx, lucas

-- 
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.


Re: [web2py] Re: truly global/single instance variable

2014-07-26 Thread Jonathan Lundell
On 26 Jul 2014, at 7:13 AM, lucas  wrote:
> i have it in a module and under that module i have the variable setup as a 
> global variable.  wherein, if the variable is empty upon using it, i load the 
> list of lists from a text file.  if it is not empty, then i just use it.  so 
> in that case, is there just the single instance in memory, no matter the 
> number of users or sessions?  thanx, lucas

One instance per process (the best you can do, since processes don't share 
memory spaces) (well, not as a rule). You could also do your initialization 
unconditionally directly in the module (not in a function, or in a function 
called from the the modules top level); it'll happen on the first import. 

If you trigger initialization from a global variable (in the module), keep in 
mind the possibility of a race causing multiple initializations on parallel 
threads. Probably rare enough that you don't care, as long as there's no 
possibility of exposing some inconsistent state during initialization, but 
worth thinking about. I'm pretty sure that Python protects you against that if 
you do your initialization at import time.


Side note: when you're thinking about this kind of thing, you want to think in 
terms of requests, rather than users or sessions. Requests are the basic unit 
of execution for web2py. Sessions are just persistent objects that can be 
shared across a set of requests (using cookies), and users are just another 
persistent database entity.

-- 
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.


[web2py] Re: truly global/single instance variable

2014-07-26 Thread Anthony
Rather than have your module code read a text file, you might also consider 
putting the data directly into the module itself (unless you need the text 
file to keep the data in a format more friendly to human editing):

MY_LIST = [
['item 1', 'item 2', 'etc.'],
...
]

Anthony

On Saturday, July 26, 2014 10:13:00 AM UTC-4, lucas wrote:
>
> i have it in a module and under that module i have the variable setup as a 
> global variable.  wherein, if the variable is empty upon using it, i load 
> the list of lists from a text file.  if it is not empty, then i just use 
> it.  so in that case, is there just the single instance in memory, no 
> matter the number of users or sessions?  thanx, lucas
>

-- 
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.


[web2py] Re: Can not import copy_reg

2014-07-26 Thread Richard
While setting up a new server I am wondering why previous versions of my 
app worked fine.
What functionality triggers the custom_import? A temporarily solution might 
miss this functionality and I'll build this back when the hosting is in 
place again.

On Friday, July 25, 2014 1:32:28 PM UTC+2, Richard wrote:
>
> nginx will need a VPS so i'll stick to CGI for prototyping and buy some 
> time for a new hosting service. 
> In the book an option for "Some web hosting services do not support 
> mod_wsgi. In this case, we must use Apache as a proxy and forward all 
> incoming requests to the web2py built-in web server (running for example on 
> localhost:8000)."
>
> I'll try this first.
>
> On Thursday, July 24, 2014 9:15:12 PM UTC+2, Richard wrote:
>>
>> I am hosted at JustHost, who has the option on installing Nginx. I'll try 
>> that for a better infrastructure.
>>
>>
>> On Thursday, July 24, 2014 9:21:24 AM UTC+2, Massimo Di Pierro wrote:
>>>
>>> I agree with you that Apache is not a good solution any more. Nginx for 
>>> example is a much better solution. Nevertheless some people may not have a 
>>> choice.
>>>
>>> On Wednesday, 23 July 2014 14:45:45 UTC-5, Niphlod wrote:

 I seem to be the only "advocate" for ditching apache always and before 
 anything else (especially before going into production, where a 
 not-so-well-tuned apache (most-likely you're using everybody's else 
 defaults) still suffers a Slowloris attack). 
 Those kind of headaches are non-existent with other solutions (often 
 more performant without particular tuning). 
 Check with a simple google search for "mod_wsgi recompile" to see how 
 many people have been in your situation (mismatch between what mod_wsgi 
 has 
 been originally compiled vs the current running python version) and their 
 solutions for various distributions. It's a pretty well documented "issue" 
 with a large number of cases.

 On Wednesday, July 23, 2014 1:07:38 PM UTC+2, Richard wrote:
>
> The issue does not occur on my local development machine. 
> I did an upgrade on the remote host where the issue occurs using the 
> web2py update feature. Then I upgraded from Python 2.6 to 2.7.8. All apps 
> works fine but not the one where I add features to auth.
>
> How should resolve this in a manner that I have a solid basis for 
> production? We are in a pre-production phase.
>
> On Wednesday, July 23, 2014 12:30:11 PM UTC+2, Niphlod wrote:
>>
>> I'd vote for the usual issue with apache and mod_wsgi not compiled 
>> against the latest interpreter
>>
>> On Wednesday, July 23, 2014 11:40:14 AM UTC+2, Richard wrote:
>>>
>>> Massimo,
>>>
>>> importing copy_reg from the console works fine :)
>>>
>>> Richard
>>>
>>> On Wednesday, July 23, 2014 11:20:06 AM UTC+2, Massimo Di Pierro 
>>> wrote:

 I understand but can you open a web2py shell. from the console type:


 $ cd web2py
 $ python web2py.py -S welcome -P
 >>> import copy_reg




 On Wednesday, 23 July 2014 04:03:48 UTC-5, Richard wrote:
>
> When I add the import copy_reg in db.py I get the error:
>
>  No module named copy_reg
>
> In the python/Python-2.7.8/Lib directory are 3 copy_reg files:
> - copy_reg.py
> - copy_reg.pyc
> - copy_reg.pyo
>
> Maybe of any relevance: I run a shared Apache server with the 
> following first line in cgihandler.py :  
> #!/home4/mamplcom/python/Python-2.7.8/python
>
>
>
> On Tuesday, July 22, 2014 1:21:36 PM UTC+2, Massimo Di Pierro 
> wrote:
>>
>> Copy reg is a python module. Can you import it from the normal 
>> python shell?
>>
>> On Tuesday, 22 July 2014 06:05:06 UTC-5, Richard wrote:
>>>
>>> Hi,
>>>
>>> I have an issue with adjusting the auth tables resulting in a 
>>> custom import and an error that copy_reg can not be imported.
>>>
>>> The error trace is:
>>>
>>> Traceback (most recent call last):
>>>   File "/home4/mamplcom/public_html/cgi-bin/gluon/restricted.py", 
>>> line 220, in restricted
>>> exec ccode in environment
>>>   File 
>>> "/home4/mamplcom/public_html/cgi-bin/applications/im/models/db.py" 
>>> , line 
>>> 74, in 
>>> auth.define_tables(username=False, signature=False)
>>>   File "/home4/mamplcom/public_html/cgi-bin/gluon/tools.py", line 
>>> 1784, in define_tables
>>> format='%(first_name)s %(last_name)s (%(id)s)'))
>>>   File "/home4/mamplcom/public_html/cgi-bin/gluon/dal.py", line 
>>> 822

[web2py] Re: Bootstrap is really killing web2py

2014-07-26 Thread 'sasogeek' via web2py-users
So... I'm not really sure what this whole conversation is about, as to 
whether it's an issue of web2py coming with bs2 by default or some 
difficulty in implementing bs3. I use bs3 just fine in my web2py apps and 
really haven't had any issues..

On Friday, 18 July 2014 19:17:34 UTC, Moustafa Mahmoud wrote:
>
> I have been using web2py for 3 years know, and I was really impressed by 
> it, I defended it in every discussion, even implemented all my projects 
> using it and even convinced my Graduation Project Team to use it in our GP. 
> However, as my skill increased and I began looking more into customizing my 
> applications, I have hit a brick wall discovering how tightly bound web2py 
> is to bootstrap2, I wanted to use bootstrap 3 but was faced with tons of 
> problems. If I want to move to another front end framework then I 
> discovered that it would be easier to use another framework because of the 
> time and effort I would need to invest in modifying all parts of web2py 
> that are tightly bound  to bootstrap.
> This will result in making web2py a headache to me rather than my best 
> friend. I am writing this message because I am really sad that an amazing 
> framework like web2py is forcing me to consider an alternative because I do 
> really feel it is constraining me at this point.
> Any help or ideas about that ?
>

-- 
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.


[web2py] pre-populating the form in custom form

2014-07-26 Thread Luis Garcia
Hi!

I am working with web2py and I am trying to pre-populate a form. In normal 
circumstances I do form.vars.field = value. But now, I am working with a 
custom form, and I realized that this does not work anymore.
It is there any way to pre-populate a customized form directly from the 
server? or I have to use javascript?

Thank you.

-- 
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.


[web2py] Help! Invalid request when the url has special characters in it. e.g. -> abcd%2Bfdf.jpg

2014-07-26 Thread kenny c
I am currently working on generating a jpg file and the filename contains 
special characters in it.

when the link to image file is "www.somedomain.com/abcd%2Bfdf.jpg" It gives 
"invalid request" error. 

I am currently using "request.args" to read the filename.

I tried to understand routes.py but I didn't know how it should be 
configured. Thank you.

-- 
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.


[web2py] Re: Classic Error with Rocket - can't launch web2py any more

2014-07-26 Thread Dansant vzw
I finally tried it and received the following message:

web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2014
Version 2.9.5-stable+timestamp.2014.03.16.02.35.39
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
PostgreSQL(pg8000), IMAP(imaplib)
please visit:
http://127.0.0.1:500/
starting browser...

(process:5361): GConf-WARNING **: Client failed to connect to the D-BUS 
daemon:
Did not receive a reply. Possible causes include: the remote application 
did not send a reply, the message bus security policy blocked the reply, 
the reply timeout expired, or the network connection was broken.

(process:5361): GConf-WARNING **: Client failed to connect to the D-BUS 
daemon:
Did not receive a reply. Possible causes include: the remote application 
did not send a reply, the message bus security policy blocked the reply, 
the reply timeout expired, or the network connection was broken.

(process:5361): GConf-WARNING **: Client failed to connect to the D-BUS 
daemon:
Did not receive a reply. Possible causes include: the remote application 
did not send a reply, the message bus security policy blocked the reply, 
the reply timeout expired, or the network connection was broken.
QGtkStyle was unable to detect the current GTK+ theme.
Qt: Session management error: Authentication Rejected, reason : None of the 
authentication protocols specified are supported and host-based 
authentication failed
konqueror(5361)/kdeui (kdelibs): Session bus not found 
To circumvent this problem try the following command (with Linux and bash) 
export $(dbus-launch) 
KCrash: Application 'x-www-browser' crashing...
KCrash: Attempting to start /usr/lib/kde4/libexec/drkonqi from kdeinit
sock_file=/root/.kde/socket-debian/kdeinit4__0
Warning: connect() failed: : Bestand of map bestaat niet
KCrash: Attempting to start /usr/lib/kde4/libexec/drkonqi directly

(process:5364): GConf-WARNING **: Client failed to connect to the D-BUS 
daemon:
Did not receive a reply. Possible causes include: the remote application 
did not send a reply, the message bus security policy blocked the reply, 
the reply timeout expired, or the network connection was broken.

(process:5364): GConf-WARNING **: Client failed to connect to the D-BUS 
daemon: 


Did not receive a reply. Possible causes include: the remote application 
did not send a reply, the message bus security policy blocked the reply, 
the reply timeout expired, or the network connection was 
broken. 

 





(process:5364): GConf-WARNING **: Client failed to connect to the D-BUS 
daemon: 


Did not receive a reply. Possible causes include: the remote application 
did not send a reply, the message bus security policy blocked the reply, 
the reply timeout expired, or the network connection was broken.
QGtkStyle was unable to detect the current GTK+ theme.
drkonqi(5364)/kdeui (kdelibs): Session bus not found 
To circumvent this problem try the following command (with Linux and bash) 
export $(dbus-launch) 

Op maandag 21 april 2014 23:53:41 UTC+2 schreef samuel bonill:
>
> try:
>
> python web2py.py -i 127.0.0.1 -p 500
>
>
>
> El lunes, 21 de abril de 2014 10:03:24 UTC-5, Dansant vzw escribió:
>>
>> I'am again trying (after several earlier and succesfull atempts) to learn 
>> some web2py. In the past I just got the framework up and running without 
>> any problem at all. 
>>
>> Unless I tryed it recently again and got the following error, which seems 
>> to be a classic:
>>
>> ERROR:Rocket.Errors.Port8000:Socket 127.0.0.1:8000 in use by other 
>> process and it won't share.
>> WARNING:Rocket.Errors.Port8000:Listener started when not ready.
>>
>> I'am working on a Debian Linux machine (Wheezy) and have the Python IDLE 
>> 2.6, 2.7 and 3.2 installed on my machine.
>>
>> I also recently did some experiments with wordpress running on my 
>> desktop, but I uninstalled everything (incl. Apache).
>>
>> And it is still not running properly. The only thing I can think off is 
>> the fact that I installed a virus protection clamav. But even when I 
>> uninstalled that one, it didn't work. 
>>
>> It is even not working when I'am trying to use it offline (shutting down 
>> my home wifi for a while)
>>
>>

-- 
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 t

[web2py] Re: google ndb

2014-07-26 Thread Alan Williams
Thank you for the quick response Massimo.  I appreciate it.

On Thursday, July 24, 2014 5:33:52 AM UTC-6, Massimo Di Pierro wrote:
>
> Yes it does. For example:
>
> db = DAL('google:datastore')# for google app engine datastore 
> 
> 
> db = DAL('google:datastore+ndb') # for google app engine datastore with 
> ndb 
>   
> this is the only change required to use ndb.
>
> On Wednesday, 23 July 2014 13:26:40 UTC-5, Alan Williams wrote:
>>
>> I have read through a few post and I have still not yet been able to 
>> determine if web2py supports ndb.  The Google/NoSQL support in the DAL is 
>> for the GQL, which Google states has been replaces by ndb:
>>
>>
>>- *"DB Datastore:* DB Datastore framework has been replaced with the 
>>NDB Datastore framework, which features automatic caching, and support 
>> for 
>>sophisticated queries and atomic transactions." 
>>
>>
>> Can someone please shed some light 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] invalid request error when the url address contains special characters.

2014-07-26 Thread kenny c
I have a website link that has special characters in it, e.g) 
www.asdfasdf.com/5%pic.jpg If I try to open this link, I get "invalid 
request" error.
The reason that the link ends with jpg extension is that I am creating a 
jpg file with a Python library. 

Any help would be great. I tried to play with "routes.py" but I don't know 
what to define there.

Thank you in advance.

-- 
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.


[web2py] Re: Is it possible to step through scheduler task code in debugger?

2014-07-26 Thread Stephen Weiss
FWIW I did finally get it working, to an extent.

I'm working on a Windows 7 machine to do this.

In one command tool window, I'm running my web2py application.
In another command tool window, I'm running the scheduler for my web2py 
application.

In the model that contains the scheduled task that gets called I placed the 
following two lines along with the import of rpdb2 elsewhere.

   logger.debug('AWAITING DEBUGGER CONNECTION TO CONTINUE')
   rpdb2.start_embedded_debugger("whatever")

Note that I comment these lines out when not needing the debugger.

I submit a job to the scheduled_task table.

When I see the 'AWAITING DEBUGGER CONNECTION TO CONTINUE' message in the 
scheduler command tool window, I go to yet another command tool and start 
winpdb and go through the attach.

This connects me to the proper process and I can step through it.

*NOTE: *You should change the timeout to the queue task call to something 
like 600 seconds so that web2py doesn't think the process took too long to 
run and reaps it while you're debugging.


-- 
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.


[web2py] How to remove the symbol. What is the cause of its appearance?

2014-07-26 Thread Капылов Данил
When displaying text in some text at the end appears. and some do not. In 
this text there is no character. How to fix it was not? 


{{if len(row.body)>400:}}
{{=(row.body[:401] + '. . .')}}

{{else:}}
{{=row.body}}
{{pass}}





-- 
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.


[web2py] LoginRadius - user cannot be logged in

2014-07-26 Thread Hakan Moray
Hi;

I am using "LoginRadiusAccount" and I have configured "loginradius.key" 
properly (facebook login).

But it seems that user cannot be logged in the web2py application although 
facebook login succeeds from LoginRadius side.

Is there something else should be done in order to login the user to web2py 
app ? Is user first should be added to db ? 

Thanks in advance.

Hakan.
 

-- 
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.


Re: [web2py] invalid request error when the url address contains special characters.

2014-07-26 Thread Jonathan Lundell
On 26 Jul 2014, at 1:27 AM, kenny c  wrote:
> I have a website link that has special characters in it, e.g) 
> www.asdfasdf.com/5%pic.jpg If I try to open this link, I get "invalid 
> request" error.
> The reason that the link ends with jpg extension is that I am creating a jpg 
> file with a Python library. 
> 
> Any help would be great. I tried to play with "routes.py" but I don't know 
> what to define there.
> 

You need to %-escape the %: .../5%25pic.jpg

-- 
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.


[web2py] How to prevent interactive shell from 303 error with redirect in model file.

2014-07-26 Thread Mark Li
I am currently redirecting my "index" page to another page (the "splash" 
page). The index page is the default function in my routes.py. The idea, is 
that if a user visits the "index" page, they will get redirected to the 
"splash" page, which works fine. At it's core, my redirect code looks like 
this (inside a models file):


if request.function=="index":
redirect(URL('splash'))


However, upon using the interactive shell:
python web2py.py -M -S appname

I get a 303 error and can't start the interactive shell, because the index 
function is requested at the start of the interactive shell (causing a 
redirect). I still want the index page to redirect to the splash page, but 
the interactive shell does not work with the redirect code. Not quite sure 
what the best way to go about this is. I have several background scripts 
that run using the interactive shell; I would still like these to work, 
while maintaining the redirect code for users visiting the front-end of the 
site.

-- 
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.


[web2py] Re: How to prevent interactive shell from 303 error with redirect in model file.

2014-07-26 Thread Anthony
Try:

cmd_opts = request.global_settings.cmd_options
if request.function=="index" and not (cmd_opts and (cmd_opts.shell or 
cmd_opts.scheduler)):
redirect(URL('splash'))

We should probably provide a more convenient method to check whether we 
have an http request vs. a shell or scheduler run (maybe a flag such as 
request.is_http_request). Feel free to submit a Google Code issue about 
this.

Anthony

On Saturday, July 26, 2014 9:38:54 PM UTC-4, Mark Li wrote:
>
> I am currently redirecting my "index" page to another page (the "splash" 
> page). The index page is the default function in my routes.py. The idea, is 
> that if a user visits the "index" page, they will get redirected to the 
> "splash" page, which works fine. At it's core, my redirect code looks like 
> this (inside a models file):
>
>
> if request.function=="index":
> redirect(URL('splash'))
>
>
> However, upon using the interactive shell:
> python web2py.py -M -S appname
>
> I get a 303 error and can't start the interactive shell, because the index 
> function is requested at the start of the interactive shell (causing a 
> redirect). I still want the index page to redirect to the splash page, but 
> the interactive shell does not work with the redirect code. Not quite sure 
> what the best way to go about this is. I have several background scripts 
> that run using the interactive shell; I would still like these to work, 
> while maintaining the redirect code for users visiting the front-end of the 
> site.
>

-- 
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.