[web2py] Re: web2py 1.97.1 is OUT

2011-06-27 Thread apple
Just add this to the top of the test function
print(request.vars)
print(request.vars.table)

request.vars prints the storage object as expected. However any
reference to request.vars.table or request.vars["table"] causes
failure.

On Jun 27, 12:22 am, Massimo Di Pierro 
wrote:
> I cannot reproduce this. I just tried this and it works:
>
> def index():
>     load = LOAD(f='test.load',ajax=False,vars=dict(table='customer'))
>     return locals()
>
> def test():
>     return 'hello world'
>
> Would you send me a minimalist app so I can reproduce it. It is not a
> good idea to call an action "list" because that is a python keyword,
> but that should not causing your problem.
>
> On Jun 26, 6:14 pm, apple  wrote:
>
>
>
>
>
>
>
> > no difference. with ajax=True it works. with ajax=False it throws a
> > restricted error.
>
> > On Jun 26, 11:50 pm, Massimo Di Pierro 
> > wrote:
>
> > > How about you specify the controller?
>
> > > {{=LOAD('default','list.load', ajax=False,
> > > vars=dict(table='customer'))}}
>
> > > On Jun 26, 5:18 pm, apple  wrote:
>
> > > > yes. works fine if I just type it in the url box.
>
> > > > On Jun 26, 9:57 pm, Massimo Di Pierro 
> > > > wrote:
>
> > > > > Can you call the list.load action directly? Do you get a ticket?
>
> > > > > On Jun 26, 3:01 pm, apple  wrote:
>
> > > > > > {{=LOAD(f='list.load', ajax=True, vars=dict(table='customer'))}}
>
> > > > > > Works fine but if I change to ajax=False then it gives a restricted
> > > > > > error.
>
> > > > > > On Jun 26, 7:29 pm, Massimo Di Pierro 
> > > > > > wrote:
>
> > > > > > > Not many changes but lots of small bug fixes that make things work
> > > > > > > better.
> > > > > > > generic fields are now disabled by default for old app and only
> > > > > > > enabled on localhost for new apps.
> > > > > > > This is a security improvement that was discussed extensively 
> > > > > > > here,
> > > > > > > was release in 1.96.x but was still not working as it should have.
>
> > > > > > > Please upgrade and report any bug.
>
> > > > > > > massimo


[web2py] Re: Remote Interfacing with Web2Py

2011-06-27 Thread Arnon Marcus
Hi Massimo, 10x for replying so fast!
BTW, I agree with Jason, you ARE awesome! :)
Web2Py is a god-sent...

However, I did't understand some of the options you suggested.
Mainly I need a more accurate definition of them term "your code".
My classifications is three-fold:
1. The web2py-application
2. A service running on the server along-side web2py
3. The service running locally that interacts with any of the above
remotely

What do you mean by "your code" in each of the 4 examples?
To which of the above codes does each of your examples apply?
Shouldn't there be an import of the DAL stuff in option 2?

What I tried to do now, was:
\web2py.py -S  -M -N -R .py
That tried to invoke a instance of the web2py app locally, which would
require all the pre-requisite modules used in that app to be installed
locally (such as the database python plugin, etc...)
Is there a way to do that, that would interface with the currently
running process, or launch a local one but would not require all the
dependent stuff?

What I want to do is have a bridging local process/service that it's
writing would be open and flexible to use any of the web2py/app
objects/classes/methods running on the server, without having to
decorate all the app's code and having to write glue-code for each
function in the client side.
Is that possible?

On Jun 26, 11:08 pm, Jason Brower  wrote:
> Massimo is right and I support him.  No exec unless ABSOLUTELY needed,
> and I mean it. :P
> Running the web2py as a service does a good job.
>  From what you say, you could do as massimo says and create a service to
> handle that special communication.
> Basically, I am just seconding Massimo cause he is awesome.
> ---
> Jason
>
> On 06/26/2011 08:32 PM, Massimo Di Pierro wrote:
>
>
>
>
>
>
>
> > Please do not use exec_environment. Can you tell us more what kind of
> > interface you need? What is the purpose?
>
> > There are various way to interface and which one you use depend on the
> > purpose:
>
> > 1)
> > web2py.py -S app -M -N -R yourcode.py
>
> > 2)
> >  From your code
> > db = DAL(...,path='/path/to/db',auto_import=True)
>
> > 3)
> > expose a service, access the service (XML-RPC)
>
> > 4)
> > queue tasks in db, access db and process tasks
>
> > On Jun 26, 12:08 pm, Arnon Marcus  wrote:
> >> Hi everybody,
>
> >> I'm searching for a way to interface into a web2py application, that
> >> does not use any of the built-in function-decorators.
> >> I want to write a service that would run locally, and interact with
> >> the web2py server, located on our company server, and serve as a
> >> common bridge for multiple local applications running on a user's
> >> machine.
> >> On the back-end sides of the service I got things covered.
> >> On it's front-side, the side that would talk to the web2py
> >> application, I was hoping to use something more flexible and open then
> >> xml-rpc or any of the rpc's...
> >> I was thinking on the lines of running an RPyC server along-side the
> >> web2py server, that would serve as a hub into the running process of
> >> the web2py application.
> >> I was also looking at Pyro, but the opinions about it where not great,
> >> compared to RPyC.
> >> I tried using the shell.py functionality, with no success.
> >> I couldn't even interface with the welcome application on a fresh code
> >> of web2py, via the web2py shell... It seems that something is broken
> >> there...
> >> I'm running from a command line, on the web2py folder:
> >>    "python web2py.py -S welcome -M -N"
> >> The console/shell appears (the ">>>" stuff...)
> >> Then I do:
> >>    "from gluon.shell import exec_environment"
> >> Then I tried:
> >>    "cas = exec_environment('applications/welcome/models/db.py')"
> >> and
> >>    "other = exec_environment('applications/welcome/controllers/
> >> other.py')"
> >> And they both throw me errors...
>
> >> And also, even if it did work, even though it should, theoretically,
> >> allow me to remotely use the DAL, it would be even more inefficient
> >> then using xml-rpc, as every user would have to remotely invoke an
> >> additional separate partial-web2py server process (if I understand the
> >> mechanism correctly...).
>
> >> Is there any efficient way to do what I need?


[web2py] Re: I created a little app to be able to share some files over the net without authentication

2011-06-27 Thread szimszon


Changelog

110627

   - you can make the upload and download uuid's writable if you set the
  - settings.uuid_writable = True
   
in the file 0.py


[web2py] Re: web2py 1.97.1 is OUT

2011-06-27 Thread Anthony
Massimo, in compileapp.py, I think you need to change:
 
124. other_request.vars = vars
125. other_request.get_vars = vars
to:

124. other_request.vars = Storage(vars)
125. other_request.get_vars = Storage(vars)
 
Otherwise, request.vars in a non-ajax component is just a dict instead of a 
Storage object, so if you try to access a non-existent request variable, you 
get an error.
 
Anthony

On Monday, June 27, 2011 4:41:40 AM UTC-4, apple wrote:

> Just add this to the top of the test function 
> print(request.vars) 
> print(request.vars.table) 
>
> request.vars prints the storage object as expected. However any 
> reference to request.vars.table or request.vars["table"] causes 
> failure. 
>
> On Jun 27, 12:22 am, Massimo Di Pierro  
> wrote: 
> > I cannot reproduce this. I just tried this and it works: 
> > 
> > def index(): 
> > load = LOAD(f='test.load',ajax=False,vars=dict(table='customer')) 
> > return locals() 
> > 
> > def test(): 
> > return 'hello world' 
> > 
> > Would you send me a minimalist app so I can reproduce it. It is not a 
> > good idea to call an action "list" because that is a python keyword, 
> > but that should not causing your problem. 
> > 
> > On Jun 26, 6:14 pm, apple  wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > no difference. with ajax=True it works. with ajax=False it throws a 
> > > restricted error. 
> > 
> > > On Jun 26, 11:50 pm, Massimo Di Pierro  
> > > wrote: 
> > 
> > > > How about you specify the controller? 
> > 
> > > > {{=LOAD('default','list.load', ajax=False, 
> > > > vars=dict(table='customer'))}} 
> > 
> > > > On Jun 26, 5:18 pm, apple  wrote: 
> > 
> > > > > yes. works fine if I just type it in the url box. 
> > 
> > > > > On Jun 26, 9:57 pm, Massimo Di Pierro  
> > > > > wrote: 
> > 
> > > > > > Can you call the list.load action directly? Do you get a ticket? 
> > 
> > > > > > On Jun 26, 3:01 pm, apple  wrote: 
> > 
> > > > > > > {{=LOAD(f='list.load', ajax=True, 
> vars=dict(table='customer'))}} 
> > 
> > > > > > > Works fine but if I change to ajax=False then it gives a 
> restricted 
> > > > > > > error. 
> > 
> > > > > > > On Jun 26, 7:29 pm, Massimo Di Pierro  
> > > > > > > wrote: 
> > 
> > > > > > > > Not many changes but lots of small bug fixes that make things 
> work 
> > > > > > > > better. 
> > > > > > > > generic fields are now disabled by default for old app and 
> only 
> > > > > > > > enabled on localhost for new apps. 
> > > > > > > > This is a security improvement that was discussed extensively 
> here, 
> > > > > > > > was release in 1.96.x but was still not working as it should 
> have. 
> > 
> > > > > > > > Please upgrade and report any bug. 
> > 
> > > > > > > > massimo



[web2py] DAL Query by Date on Datetime Field.

2011-06-27 Thread David J.

How do I use DAL to query by exact date?

I tried

db(db.events.created_on == request.now.date).select()

but this returned no rows?

I also tried

db(db.events.created_on.date == request.now.date).select()

but that throws an exception

Thanks.



[web2py] Re: web2py 1.97.1 is OUT

2011-06-27 Thread Anthony
On Monday, June 27, 2011 6:24:20 AM UTC-4, Anthony wrote: 
>
> Massimo, in compileapp.py, I think you need to change:
>  
> 124. other_request.vars = vars
> 125. other_request.get_vars = vars
> to:
>
> 124. other_request.vars = Storage(vars)
> 125. other_request.get_vars = Storage(vars)
>  
> Otherwise, request.vars in a non-ajax component is just a dict instead of a 
> Storage object, so if you try to access a non-existent request variable, you 
> get an error.
>
 
Also, you won't be able to access individual variables via 
request.vars.varname unless vars is converted to a Storage object -- I think 
that's the problem apple is seeing. request.vars['table'] is getting passed 
to the test() function, but it cannot be accessed as request.vars.table 
because request.vars is a dict rather than a Storage object.
 
Anthony
 


Re: [web2py] DAL Query by Date on Datetime Field.

2011-06-27 Thread Kenneth Lundström

> How do I use DAL to query by exact date?

db((db.events.created_on < datetime(date_of_day+1 
0.00.00)&(db.events.created_on > datetime(date_of_day 0.00.00)).select()


Or then you need to save even just the date of the event, not datetime 
as created_on saves.


I might be totally wrong but this should work.


Kenneth



I tried

db(db.events.created_on == request.now.date).select()

but this returned no rows?

I also tried

db(db.events.created_on.date == request.now.date).select()

but that throws an exception

Thanks.





Re: [web2py] Re: LessCSS -- really interesting CSS "compiler"

2011-06-27 Thread Michele Comitini
Wouldn't it be nice to manage the lesscss variables (they look much
like macros) from inside web2py?
That would add just a tiny computational effort on the server.

mic

2011/6/27 Massimo Di Pierro :
> I agree. Moreover when we move stuff like this to the client our apps
> get faster, when we move it to the server they get slower.
>
> On Jun 26, 10:55 pm, Joe  Barnhart  wrote:
>> I guess we could roll our own.  But I see it more like jQuery and
>> other add-ins.  Life would be very difficult if we tried to duplicate
>> _everything_ in Python!
>>
>> This looks easy to use, it's pretty small, and sort of... well...
>> "elegant" for lack of a better word.  It is aesthetically pleasing as
>> well as useful.
>>
>> I just thought others may like to know about it...
>>
>> -- Joe
>>
>> On Jun 27, 4:16 am, Jason Brower  wrote:
>>
>>
>>
>>
>>
>>
>>
>> > As nice and easy as it is (I love how easy the language is).  Couldn't
>> > we just do this with python? That way we could just add our css file as
>> > a dynamic file like the others.


Re: [web2py] DAL Query by Date on Datetime Field.

2011-06-27 Thread David J.

Thanks Kenneth;

I actually did it this way also but I thought there would be a more 
elegant way to achieve it.


Although I guess not.

Sometimes since DAL does so much for in simple ways; I thought perhaps 
there was a simple way of doing this as well



On 6/27/11 6:54 AM, Kenneth Lundström wrote:

> How do I use DAL to query by exact date?

db((db.events.created_on < datetime(date_of_day+1 
0.00.00)&(db.events.created_on > datetime(date_of_day 0.00.00)).select()


Or then you need to save even just the date of the event, not datetime 
as created_on saves.


I might be totally wrong but this should work.


Kenneth



I tried

db(db.events.created_on == request.now.date).select()

but this returned no rows?

I also tried

db(db.events.created_on.date == request.now.date).select()

but that throws an exception

Thanks.








Re: [web2py] Re: LessCSS -- really interesting CSS "compiler"

2011-06-27 Thread Anthony
Unless you need to generate CSS dynamically based on the request, I would 
think it would be more efficient to compile the CSS once and serve it from 
'static' -- that would avoid repetitive computation and allow for browser 
caching, no? It's also more portable that way.
 
Anthony

On Monday, June 27, 2011 7:23:58 AM UTC-4, mcm wrote:

> Wouldn't it be nice to manage the lesscss variables (they look much
> like macros) from inside web2py?
> That would add just a tiny computational effort on the server. 
>
> mic 
>
> 2011/6/27 Massimo Di Pierro :
> > I agree. Moreover when we move stuff like this to the client our apps
> > get faster, when we move it to the server they get slower.
> >
> > On Jun 26, 10:55 pm, Joe  Barnhart  wrote:
> >> I guess we could roll our own.  But I see it more like jQuery and
> >> other add-ins.  Life would be very difficult if we tried to duplicate
> >> _everything_ in Python!
> >>
> >> This looks easy to use, it's pretty small, and sort of... well...
> >> "elegant" for lack of a better word.  It is aesthetically pleasing as
> >> well as useful.
> >>
> >> I just thought others may like to know about it...
> >>
> >> -- Joe
> >>
> >> On Jun 27, 4:16 am, Jason Brower  wrote:
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> > As nice and easy as it is (I love how easy the language is).  Couldn't
> >> > we just do this with python? That way we could just add our css file 
> as
> >> > a dynamic file like the others.
>
>

[web2py] Re: LessCSS -- really interesting CSS "compiler"

2011-06-27 Thread Stodge
I thought there was a Python tool that did that. I can't remember the
name offhand.

On Jun 26, 4:16 pm, Jason Brower  wrote:
> As nice and easy as it is (I love how easy the language is).  Couldn't
> we just do this with python? That way we could just add our css file as
> a dynamic file like the others. I am personally planning to use the
> python code in my css generation as I need to do a bit of math and want
> variables and functions. Makes for very clean css if you build the css
> for each page. (But much harder work for us programmers.)
> BR,
> Jason
>
> On 06/25/2011 02:50 PM, Joe Barnhart wrote:
>
>
>
>
>
>
>
> >http://lescss.org/
>
> > The crux of this js library is to preprocess your CSS files so you can
> > use a few carefully-chosen extensions to make your CSS files smaller
> > and more powerful (kind of like web2py).
>
> > For example, VARIABLES.  How many times have you wished you could just
> > assign a name to a color and then use it over and over and over inside
> > your CSS file?  Another example, NESTING.  You can actually use a
> > class, id, or element definition within another and its definition
> > nests.  And you can even pass parameters to tailor the nested CSS.
>
> > For something as simple in concept, it's a little overwhelming at how
> > it can transform a complicated CSS file.  I'm still wrapping my head
> > around it.
>
> > -- Joe B.


Re: [web2py] web2py in dropbox folder

2011-06-27 Thread Ross Peoples
I probably overuse DropBox using this method. I actually have my code on 
DropBox AND have the web2py server using those files running on two 
different machines at the same time. I have never had the problem you 
describe. The only problem I have is conflicting cron files from the two 
machines writing to the file at the same time. However, simply turning off 
cron on one of the web2py servers fixes that problem.

[web2py] Re: LessCSS -- really interesting CSS "compiler"

2011-06-27 Thread Anthony
On Monday, June 27, 2011 7:47:43 AM UTC-4, Stodge wrote: 
>
> I thought there was a Python tool that did that. I can't remember the 
> name offhand.

 
There are at least a couple, including CleverCSS and CleanCSS.
 


[web2py] Successful login takes me to index - would like to go back to the prior page

2011-06-27 Thread wdtatenh
I'm building an application that uses the login features provided by
web2py.  Users could login at any time so I was hoping for a solution
that would take the person to the last page they were on before they
logged in instead of going to the index page.  Any suggestions would
be greatly appreciated.

Thanks in advance


[web2py] Re: web2py 1.97.1 is OUT

2011-06-27 Thread apple
request.vars["table"] does not work either.

On Jun 27, 11:36 am, Anthony  wrote:
> On Monday, June 27, 2011 6:24:20 AM UTC-4, Anthony wrote:
>
> > Massimo, in compileapp.py, I think you need to change:
>
> > 124. other_request.vars = vars
> > 125. other_request.get_vars = vars
> > to:
>
> > 124. other_request.vars = Storage(vars)
> > 125. other_request.get_vars = Storage(vars)
>
> > Otherwise, request.vars in a non-ajax component is just a dict instead of a
> > Storage object, so if you try to access a non-existent request variable, you
> > get an error.
>
> Also, you won't be able to access individual variables via
> request.vars.varname unless vars is converted to a Storage object -- I think
> that's the problem apple is seeing. request.vars['table'] is getting passed
> to the test() function, but it cannot be accessed as request.vars.table
> because request.vars is a dict rather than a Storage object.
>
> Anthony


[web2py] Re: The multi-tenant feature and validators ...

2011-06-27 Thread Ross Peoples
Did this ever get resolved? I tried looking for a ticket on this but only 
found one related to setting unique=True. I have to convert my app to 
support multiple tenants and IS_IN_DB() and IS_NOT_IN_DB() are going to be 
used in several places to make sure that a tenant cannot have duplicate rows 
in a table, yet allow duplicates between tenants.

For example, if I have a table called 'keywords' that allows tenants to 
create a list of keywords, it is possible that two tenants would use the 
same keyword, yet you wouldn't want the a tenant to enter the same keyword 
multiple times. Hope that makes sense.

Also, I will have the same requirement as David when it comes to multiple 
user accounts per tenant. I'm not sure how to handle this one.


[web2py] Re: LessCSS -- really interesting CSS "compiler"

2011-06-27 Thread Massimo Di Pierro
this is a good idea.

On Jun 27, 6:34 am, Anthony  wrote:
> Unless you need to generate CSS dynamically based on the request, I would
> think it would be more efficient to compile the CSS once and serve it from
> 'static' -- that would avoid repetitive computation and allow for browser
> caching, no? It's also more portable that way.
>
> Anthony
>
>
>
>
>
>
>
> On Monday, June 27, 2011 7:23:58 AM UTC-4, mcm wrote:
> > Wouldn't it be nice to manage the lesscss variables (they look much
> > like macros) from inside web2py?
> > That would add just a tiny computational effort on the server.
>
> > mic
>
> > 2011/6/27 Massimo Di Pierro :
> > > I agree. Moreover when we move stuff like this to the client our apps
> > > get faster, when we move it to the server they get slower.
>
> > > On Jun 26, 10:55 pm, Joe  Barnhart  wrote:
> > >> I guess we could roll our own.  But I see it more like jQuery and
> > >> other add-ins.  Life would be very difficult if we tried to duplicate
> > >> _everything_ in Python!
>
> > >> This looks easy to use, it's pretty small, and sort of... well...
> > >> "elegant" for lack of a better word.  It is aesthetically pleasing as
> > >> well as useful.
>
> > >> I just thought others may like to know about it...
>
> > >> -- Joe
>
> > >> On Jun 27, 4:16 am, Jason Brower  wrote:
>
> > >> > As nice and easy as it is (I love how easy the language is).  Couldn't
> > >> > we just do this with python? That way we could just add our css file
> > as
> > >> > a dynamic file like the others.


[web2py] Re: The multi-tenant feature and validators ...

2011-06-27 Thread Massimo Di Pierro
The ticket you refer to is about a problem with unique=True. You
cannot use unique=True with multi-tenant app because the latter is
enforced at the DB level and the DB has no knowledge of multi-tenancy.

I do not believe there is any other problem related with IS_IN_DB and
IS_NOT_IN_DB but perhaps I am wrong. If I am wrong, please post an
example of bad behavior.

Massimo

On Jun 27, 8:14 am, Ross Peoples  wrote:
> Did this ever get resolved? I tried looking for a ticket on this but only
> found one related to setting unique=True. I have to convert my app to
> support multiple tenants and IS_IN_DB() and IS_NOT_IN_DB() are going to be
> used in several places to make sure that a tenant cannot have duplicate rows
> in a table, yet allow duplicates between tenants.
>
> For example, if I have a table called 'keywords' that allows tenants to
> create a list of keywords, it is possible that two tenants would use the
> same keyword, yet you wouldn't want the a tenant to enter the same keyword
> multiple times. Hope that makes sense.
>
> Also, I will have the same requirement as David when it comes to multiple
> user accounts per tenant. I'm not sure how to handle this one.


[web2py] Re: The multi-tenant feature and validators ...

2011-06-27 Thread Ross Peoples
Ok, thanks Massimo. I know that unique=True will never work because there's 
no way to tell the database about multi-tenancy, I just wanted to make sure 
the validators were working properly.

[web2py] Re: web2py 1.97.1 is OUT

2011-06-27 Thread Anthony
On Monday, June 27, 2011 9:08:27 AM UTC-4, apple wrote: 
>
> request.vars["table"] does not work either.

 
Hmm, it works for me. Maybe try restarting web2py. Also, make sure you're 
using 1.97.1 (or trunk) -- prior to that, vars passed to LOAD were ignored 
when ajax=False.
 
Anthony
 


[web2py] Analytics application

2011-06-27 Thread Francisco Costa
Hello,
does anyone has build some site analytics application?

It would be great to have some statistics about user navigation,
traffic measure, etc

Something like piwik (http://piwik.org/)



[web2py] How to make faster virtualfields on sql rdbms

2011-06-27 Thread Michele Comitini
Hello,

I have noticed that virtual fields are painfully slow.
Here is a good way to replace them on a SQL server.
I tested it on both mysql and postgres.

suppose you have the following table:

db.define_table('numbers', Field('a', 'integer'), Field('b', 'integer'))

you can add a virtual field:

class MyVF(object):
  def aplusb(self):
return self.a + self.b

db.numbers.virtualfields.append(MyVF)

If the virtual field is something more complex (eg.  subqueries) and
the table has more than a few record,
you would end on your knee asking your server not to die each time you
query that table...

Here is a simple solution:

db.define_table('numbers', Field('a', 'integer'), Field('b', 'integer'))

# create the view if it does not exist yet
if not db.executesql("select * from information_schema.tables where
table_name='numbers_v' limit 1;"):
  db.executesql("""create view numbers_v as
select numbers.*, numbers.a + numbers.b as aplusbs from numbers""")

# inform web2py about the view (just add the computed field the others
can be inherited)
db.define_table('numbers_v', db.numbers, Field('aplusb', 'integer'),
migrate=False)
# alias the view
numbers=db.numbers_v.with_alias('numbers')

now you can use db.numbers_v anywhere you would use db.numbers just
make use of the alias:


a_set_of_sums=db(numbers.id>0).select(numbers.aplusb)

enjoy the speed

mic


Re: [web2py] Re: URGENT: Clarification on Auth

2011-06-27 Thread Michele Comitini
Pystar,

I suggest to use the oauth20_account.py authentication module that
comes included
with web2py.  With that you can use any data coming from where you
want, provided that the field "username"
is unique for each user authenticating on the application.

mic

2011/6/26 Pystar :
> Still awaiting my response
> thanks guys
>
> On Jun 26, 8:36 am, Pystar  wrote:
>> I am using Facebook's "Registration plugin" which allows users to
>> either register or login into a 3rd party site using their facebook
>> account. I would like to know if its possible to get the signed data
>> from facebook and do a manual insert into the "user" table and still
>> have auth working? or in other words can I get my user data from
>> anywhere apart from the auth form, do a manual insert and have auth
>> work sitewide across my app?
>> Thanks for your prompt response.


[web2py] Re: Successful login takes me to index - would like to go back to the prior page

2011-06-27 Thread Anthony
If you add a '_next' variable to your login link, the user will be 
redirected to the URL in the '_next' variable after login. So, wherever you 
are setting your login link, do something like this:
 
   login
 
If you're using the default auth.navbar() to generate your login link, it's 
a little trickier -- you'll have to tweak the login link created by the 
navbar() method:
 
   {{navbar=auth.navbar()}}
   {{login_link=navbar.elements('a')[0]}}
   {{login_link['_href']='%s?_next=%s' % (login_link['_href'], 
URL(r=request, args=request.args, vars=request.vars))}}
   {{=navbar}}
 
 
Anthony

On Monday, June 27, 2011 8:34:09 AM UTC-4, wdtatenh wrote:

> I'm building an application that uses the login features provided by 
> web2py.  Users could login at any time so I was hoping for a solution 
> that would take the person to the last page they were on before they 
> logged in instead of going to the index page.  Any suggestions would 
> be greatly appreciated. 
>
> Thanks in advance



[web2py] web2py_error invalid path?

2011-06-27 Thread Bruce Dickey
I've just started using web2py and had an ajax call working, but must
have done something that broke it. I've been backing out changes but
have not been able to find what went wrong. The call in my js file is

$.post('init.html', function(data) {  ...

and then in /controllers/default.py there is a

def init():
   return "test"

The ajax call fails with 400, and the server log says:

127.0.0.1, 2011-06-27 09:49:43, POST, /init.html, HTTP/1.1, 400,
0.000378

Firebug says:

Response Headers
Content-Length  573
Content-Typetext/html; charset=UTF-8
web2py_errorinvalid path
DateMon, 27 Jun 2011 15:49:43 GMT
Server  Rocket 1.2.2 Python/2.6.6
Connection  keep-alive

So it looks to me like somehow the init() function in /controllers/
default.py is no longer found. Please, can someone tell me what I
might have clobbered to break this? Or what steps I could take to
debug? (I have run web2py in the WingIDE debugger, but it was hard to
follow the path checking thru the regex stuff).

Thanks,
Bruce




Re: [web2py] web2py_error invalid path?

2011-06-27 Thread Michele Comitini
the url you are using is incomplete... try using URL()

$.post('{{=URL("init.html")}}', function(data){ } )

mic

2011/6/27 Bruce Dickey :
> I've just started using web2py and had an ajax call working, but must
> have done something that broke it. I've been backing out changes but
> have not been able to find what went wrong. The call in my js file is
>
> $.post('init.html', function(data) {  ...
>
> and then in /controllers/default.py there is a
>
> def init():
>   return "test"
>
> The ajax call fails with 400, and the server log says:
>
> 127.0.0.1, 2011-06-27 09:49:43, POST, /init.html, HTTP/1.1, 400,
> 0.000378
>
> Firebug says:
>
> Response Headers
> Content-Length  573
> Content-Type    text/html; charset=UTF-8
> web2py_error    invalid path
> Date    Mon, 27 Jun 2011 15:49:43 GMT
> Server  Rocket 1.2.2 Python/2.6.6
> Connection      keep-alive
>
> So it looks to me like somehow the init() function in /controllers/
> default.py is no longer found. Please, can someone tell me what I
> might have clobbered to break this? Or what steps I could take to
> debug? (I have run web2py in the WingIDE debugger, but it was hard to
> follow the path checking thru the regex stuff).
>
> Thanks,
> Bruce
>
>
>


[web2py] example celery integration?

2011-06-27 Thread ariel.glez.m
someone have a example where integrate web2py and celery???


[web2py] web2py connection pooling and database server reboot

2011-06-27 Thread Roman Bataev
We run web2py with ms sql server as a database backend. Every weekend sql 
server gets rebooted (to install microsoft updates), after which web2py apps 
start failing with the following error message:

*('08S02', '[08S02] [Microsoft][SQL Server Native Client 10.0]SMux Provider: 
Physical connection is not usable [x]. (-1) (SQLExecDirectW); 
[08S02] [Microsoft][SQL Server Native Client 10.0]Unable to open a logical 
session (-1)')*

The only way to get them back up and running is to restart web2py. 

I suspect it has something to do with database connection pooling (which we 
do use). I have not taken a look at the code yet, so I am not sure if web2py 
connection pooling reopens physical db connection if it becomes unusable 
because of db server reboot or network failure or something else.

Has anyone had this issue? I cannot think of any good solution for this so 
any help would be highly appreciated. 


[web2py] Re: web2py connection pooling and database server reboot

2011-06-27 Thread Ross Peoples
I have a similar set up, but do not use connection pooling. When the MSSQL 
server is rebooting, any requests by web2py will predictably return an error 
about not being able to connect, but when the MSSQL server becomes available 
again, web2py starts working again, no restart required. So I suspect that 
connection pooling is the culprit. I have never used connection pooling 
before (never needed it), so I wouldn't even know where to begin in 
debugging that part of the code, sorry.

[web2py] Re: example celery integration?

2011-06-27 Thread Massimo Di Pierro
No but I am involved in a project and this will be done by mid August,
if not sooner.

On Jun 27, 11:47 am, "ariel.glez.m"  wrote:
> someone have a example where integrate web2py and celery???


Re: [web2py] Re: example celery integration?

2011-06-27 Thread David J.

Sounds Great also would like to see it;

Thanks.

David.

On 6/27/11 1:40 PM, Massimo Di Pierro wrote:

No but I am involved in a project and this will be done by mid August,
if not sooner.

On Jun 27, 11:47 am, "ariel.glez.m"  wrote:

someone have a example where integrate web2py and celery???




[web2py] Re: web2py connection pooling and database server reboot

2011-06-27 Thread Massimo Di Pierro
Yes this is because of connection pooling. The fact is, when you
database is down, web2py will return errors because it cannot connect
to your database. While on the one side we could have web2py return
more graceful errors, I think it is better follow the following
strategy:

1) redirect all your http requests to a static pages that says "down
for maintenance"
2) turn off web2py (reboot the server if using apache for example)
3) turn off database and do required database maintenance
4) restart database
5) restart web2py
6) redirect http requests back to web2py

I guess web2py could handle the missing database connections itself
but you still are left with the problem of informing the users.


On Jun 27, 12:06 pm, Roman Bataev  wrote:
> We run web2py with ms sql server as a database backend. Every weekend sql
> server gets rebooted (to install microsoft updates), after which web2py apps
> start failing with the following error message:
>
> *('08S02', '[08S02] [Microsoft][SQL Server Native Client 10.0]SMux Provider:
> Physical connection is not usable [x]. (-1) (SQLExecDirectW);
> [08S02] [Microsoft][SQL Server Native Client 10.0]Unable to open a logical
> session (-1)')*
>
> The only way to get them back up and running is to restart web2py.
>
> I suspect it has something to do with database connection pooling (which we
> do use). I have not taken a look at the code yet, so I am not sure if web2py
> connection pooling reopens physical db connection if it becomes unusable
> because of db server reboot or network failure or something else.
>
> Has anyone had this issue? I cannot think of any good solution for this so
> any help would be highly appreciated.


[web2py] Re: web2py 1.97.1 is OUT

2011-06-27 Thread elffikk
I get an error when access an amfrpc3 service from flex (works for
1.96.4)

[FaultEvent fault=[RPC Fault faultString="Send failed"
faultCode="Client.Error.MessageSend"
faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed:
HTTP: Status 500: url: 'http://localhost:8000/myapp/gateway/call/
amfrpc3'"] messageId="6F671232-BAC7-E72A-9829-D278D50BD935"
type="fault" bubbles=false cancelable=true eventPhase=2]

also if you will fix that please make it work with pyamf 0.6

thank you


[web2py] Re: web2py 1.97.1 is OUT

2011-06-27 Thread pbreit
Typo in the code:

*other_request.vars = **Stoarge(**vars**)*


[web2py] Re: Analytics application

2011-06-27 Thread pbreit
Check out Woopra and MixPanel

[web2py] issue with 1.97.1

2011-06-27 Thread Richard Vézina
Hello,

I get this :

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

Traceback (most recent call last):
  File "/programmation/version_197-1/web2py/gluon/restricted.py", line
192, in restricted
exec ccode in environment
  File "/version_197-1/web2py/applications/sgddms/views/ref/creation.html",
line 115, in 
  File "/version_197-1/web2py/gluon/compileapp.py", line 142, in __call__
page = run_controller_in(c, f, other_environment)
  File "/version_197-1/web2py/gluon/compileapp.py", line 418, in
run_controller_in
restricted(code, environment, filename)
  File "/version_197-1/web2py/gluon/restricted.py", line 200, in restricted
raise RestrictedError(layer, code, '', environment)
RestrictedError

With the exact same app that works under 1.96.4...

Any idea where it's coming from??

I got this traceback only with a new feature I just finished to prototype
where I use jQuery UI Tabs plugin... Could it be related to the jQuery UI
build I use??

Richard


[web2py] Re: issue with 1.97.1

2011-06-27 Thread Massimo Di Pierro
Can you send me creation.html?

On Jun 27, 2:12 pm, Richard Vézina 
wrote:
> Hello,
>
> I get this :
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
>
> Traceback (most recent call last):
>   File "/programmation/version_197-1/web2py/gluon/restricted.py", line
> 192, in restricted
>     exec ccode in environment
>   File "/version_197-1/web2py/applications/sgddms/views/ref/creation.html",
> line 115, in 
>   File "/version_197-1/web2py/gluon/compileapp.py", line 142, in __call__
>     page = run_controller_in(c, f, other_environment)
>   File "/version_197-1/web2py/gluon/compileapp.py", line 418, in
> run_controller_in
>     restricted(code, environment, filename)
>   File "/version_197-1/web2py/gluon/restricted.py", line 200, in restricted
>     raise RestrictedError(layer, code, '', environment)
> RestrictedError
>
> With the exact same app that works under 1.96.4...
>
> Any idea where it's coming from??
>
> I got this traceback only with a new feature I just finished to prototype
> where I use jQuery UI Tabs plugin... Could it be related to the jQuery UI
> build I use??
>
> Richard


[web2py] table auth_user already exists

2011-06-27 Thread Christopher Baron
Hi web2py users,

Just upgraded to Version 1.97.1

I checked my code out into the new directory, opened my browser, and
received and error stating 'auth_cas' already exists.

I removed all files from the databases folder and tried again
receiving an error that 'auth_user' already exists.

I'm using a private/config file that points to some mysql database on
another server.

What can I do ?

I'd be happy to share more information needed to help solve the
problem.

Thanks in advance,

Chris


[web2py] Re: issue with 1.97.1

2011-06-27 Thread Richard Vézina
Also, I just tried to change the compileapp.py with Storage... It stop to
send the traceback and I got a : invalid view (ref/create_fvte.load)...

Richard

On Mon, Jun 27, 2011 at 3:12 PM, Richard Vézina  wrote:

> Hello,
>
> I get this :
>
>  1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
>
> Traceback (most recent call last):
>
>   File "/programmation/version_197-1/web2py/gluon/restricted.py", line 192, 
> in restricted
>
> exec ccode in environment
>
>   File "/version_197-1/web2py/applications/sgddms/views/ref/creation.html", 
> line 115, in 
>
>   File "/version_197-1/web2py/gluon/compileapp.py", line 142, in __call__
>
> page = run_controller_in(c, f, other_environment)
>
>   File "/version_197-1/web2py/gluon/compileapp.py", line 418, in 
> run_controller_in
>
> restricted(code, environment, filename)
>
>   File "/version_197-1/web2py/gluon/restricted.py", line 200, in restricted
>
> raise RestrictedError(layer, code, '', environment)
> RestrictedError
>
> With the exact same app that works under 1.96.4...
>
> Any idea where it's coming from??
>
> I got this traceback only with a new feature I just finished to prototype
> where I use jQuery UI Tabs plugin... Could it be related to the jQuery UI
> build I use??
>
> Richard
>
>


Re: [web2py] Re: issue with 1.97.1

2011-06-27 Thread Richard Vézina
Here CREATION :

{{extend 'layout_form.html'}}


@import
"{{=URL('static','plugin_added/jquery-ui-1.8.9.custom/development-bundle/themes/base/jquery.ui.all.css')}}";








{{=T('folder').capitalize()}}
{{=T('volume').capitalize()}}
{{=T('tome').capitalize()}}
{{=T('report').capitalize()}}




{{=LOAD(c='ref',f='create_fvte',args='ref_fnaregistry',extension='load',ajax=False,ajax_trap=False,target='one')}}




{{=LOAD(c='ref',f='create_fvte',args='ref_vregistry',extension='load',ajax=False,ajax_trap=False,target='two')}}




{{=LOAD(c='ref',f='create_fvte',args='ref_tregistry',extension='load',ajax=False,ajax_trap=False,target='three')}}




{{=LOAD(c='ref',f='create_fvte',args='ref_eregistry',extension='load',ajax=False,ajax_trap=False,target='four')}}










$(function() {
var $tabs = $( "#tabs" ).tabs();
$tabs.tabs('select',  {{=session.tab_pos}});
return false;
});


AND CONTROLLER :

# Tabs system for registry tables need creation() and create_fvte()
functions
@auth.requires_login()
def creation():
"""
Empty function for make it works the jQuery tabs plugin for ref_*
tables.
See the create_fvte() function docstring for more details.
creation() and create_fvte() functions work in conjonction.
"""
a = None
return dict(a=a)

@auth.requires_login()
def create_fvte():
"""
This function works in conjonction of creation() function. Both
functions
are required to make works the Tabs System for registry tables.
create_fvte() is used to allow the usage of registry tables as
component
to be loaded into creation() function. There is jQuery UI Tabs plugin
script in the view of the creation() function.

To redirect between the differents tabs programmatically we use the
tab_pos
session variable to store the index of the tabs on which the user has to
be
redirected to. We check if the create_fvte() function is call by GET
(vs POST) to determine when to initialise the pos_tab variable to zero.
The pos_tab vars is embeded into the jQuery code of the script like this
{{session.tab_pos}} in the view of creation() function.
"""
if request.env.request_method == 'GET':
session.tab_pos=0
table = request.args(0)
if auth.has_membership(auth.id_group('admin')):
crud.settings.formstyle='divs'
form = crud.create(db[table])
for i in range(0,len(form[0])):
if len(form[0][i][2][0]) > 0:
form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
del(form[0][i][2])
elif auth.has_membership(auth.id_group('technician')):
crud.settings.formstyle='divs'
form = crud.create(db[table])
for i in range(0,len(form[0])):
if len(form[0][i][2][0]) > 0:
form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
del(form[0][i][2])
elif auth.has_membership(auth.id_group('coordinator')):
crud.settings.formstyle='divs'
form = crud.create(db[table])
for i in range(0,len(form[0])):
if len(form[0][i][2][0]) > 0:
form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
del(form[0][i][2])
elif auth.has_membership(auth.id_group('technician_c')):
crud.settings.formstyle='divs'
form = crud.create(db[table])
for i in range(0,len(form[0])):
if len(form[0][i][2][0]) > 0:
form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
del(form[0][i][2])
elif auth.has_membership(auth.id_group('coordinator_c')):
crud.settings.formstyle='divs'
form = crud.create(db[table])
for i in range(0,len(form[0])):
if len(form[0][i][2][0]) > 0:
form[0][i][0].append(SPAN((helpicon(),
SPAN(form[0][i][2][0])),_class='tooltip'))
del(form[0][i][2])
else:
return dict(form=None)
if form.accepts(request.vars, session):
session.flash = T('form accepted')
if table == 'ref_fnaregistry':
session.tab_pos=1
elif table == 'ref_vregistry':
session.tab_pos=2
elif table == 'ref_tregistry':
session.tab_pos=3
elif form.errors:
response.flash = T('form has errors')
if table == 'ref_fnaregistry':
session.tab_pos=0
elif table == 'ref_vregistry':
session.tab_pos=1
elif table == 'ref_tregistry':
session.tab_pos=2
elif table == 'ref_eregistry':
session.tab_pos=3
else:
response.flash = T('please fill out the form')
return dict(form=form)

I know I am not DRY ;-)

Richard


On Mon, Jun 27, 2011 at 3:27 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Can you send me creation.html?
>

Re: [web2py] table auth_user already exists

2011-06-27 Thread Richard Vézina
Did you upgrade by the web2py "admin" update link?

Richard

On Mon, Jun 27, 2011 at 2:22 PM, Christopher Baron
wrote:

> Hi web2py users,
>
> Just upgraded to Version 1.97.1
>
> I checked my code out into the new directory, opened my browser, and
> received and error stating 'auth_cas' already exists.
>
> I removed all files from the databases folder and tried again
> receiving an error that 'auth_user' already exists.
>
> I'm using a private/config file that points to some mysql database on
> another server.
>
> What can I do ?
>
> I'd be happy to share more information needed to help solve the
> problem.
>
> Thanks in advance,
>
> Chris


Re: [web2py] table auth_user already exists

2011-06-27 Thread Richard Vézina
Have you try :

http://www.web2py.com/book/default/chapter/06?search=migrate#Fixing-Broken-Migrations
http://www.web2py.com/book/default/chapter/06?search=migrate#Migrations

You should use migrate=False in your models once your tables have been
created and you know you will not have to modify them...

Richard

On Mon, Jun 27, 2011 at 3:40 PM, Richard Vézina  wrote:

> Did you upgrade by the web2py "admin" update link?
>
> Richard
>
>
> On Mon, Jun 27, 2011 at 2:22 PM, Christopher Baron  > wrote:
>
>> Hi web2py users,
>>
>> Just upgraded to Version 1.97.1
>>
>> I checked my code out into the new directory, opened my browser, and
>> received and error stating 'auth_cas' already exists.
>>
>> I removed all files from the databases folder and tried again
>> receiving an error that 'auth_user' already exists.
>>
>> I'm using a private/config file that points to some mysql database on
>> another server.
>>
>> What can I do ?
>>
>> I'd be happy to share more information needed to help solve the
>> problem.
>>
>> Thanks in advance,
>>
>> Chris
>
>
>


[web2py] Re: experimental in trunk... common_fields and precints

2011-06-27 Thread Cliff
This is perfect timing.  I, too, was beginning to implement an
organization_id feature in the app I'm porting from PHP.

Bravo!

Cliff


[web2py] Re: table auth_user already exists

2011-06-27 Thread Christopher Baron
I upgraded via the admin update link and received an error, so I went
ahead and downloaded the source.

Regarding the migration techniques, the exception is being thrown on
creating web2py auth tables - specifically the following line of
code :

auth.define_tables()

Shouldn't web2py handle this for me?  Perhaps I need to include a line
similar to the following?

db = DAL('sqlite://storage.db', migrate=False)



On Jun 27, 2:45 pm, Richard Vézina 
wrote:
> Have you try :
>
> http://www.web2py.com/book/default/chapter/06?search=migrate#Fixing-B...http://www.web2py.com/book/default/chapter/06?search=migrate#Migrations
>
> You should use migrate=False in your models once your tables have been
> created and you know you will not have to modify them...
>
> Richard
>
> On Mon, Jun 27, 2011 at 3:40 PM, Richard Vézina 
>
>
>
>
>
>
> > wrote:
> > Did you upgrade by the web2py "admin" update link?
>
> > Richard
>
> > On Mon, Jun 27, 2011 at 2:22 PM, Christopher Baron  > > wrote:
>
> >> Hi web2py users,
>
> >> Just upgraded to Version 1.97.1
>
> >> I checked my code out into the new directory, opened my browser, and
> >> received and error stating 'auth_cas' already exists.
>
> >> I removed all files from the databases folder and tried again
> >> receiving an error that 'auth_user' already exists.
>
> >> I'm using a private/config file that points to some mysql database on
> >> another server.
>
> >> What can I do ?
>
> >> I'd be happy to share more information needed to help solve the
> >> problem.
>
> >> Thanks in advance,
>
> >> Chris


[web2py] Re: table auth_user already exists

2011-06-27 Thread Massimo Di Pierro
Try this:

db = DAL('sqlite://storage.db', migrate=True, fake_migrate=True)

if everything works than your .table files are correct, remove
migrate=True, fake_migrate=True and you should be fine.

On Jun 27, 3:07 pm, Christopher Baron  wrote:
> I upgraded via the admin update link and received an error, so I went
> ahead and downloaded the source.
>
> Regarding the migration techniques, the exception is being thrown on
> creating web2py auth tables - specifically the following line of
> code :
>
> auth.define_tables()
>
> Shouldn't web2py handle this for me?  Perhaps I need to include a line
> similar to the following?
>
> db = DAL('sqlite://storage.db', migrate=False)
>
> On Jun 27, 2:45 pm, Richard Vézina 
> wrote:
>
>
>
>
>
>
>
> > Have you try :
>
> >http://www.web2py.com/book/default/chapter/06?search=migrate#Fixing-B...
>
> > You should use migrate=False in your models once your tables have been
> > created and you know you will not have to modify them...
>
> > Richard
>
> > On Mon, Jun 27, 2011 at 3:40 PM, Richard Vézina 
> > > wrote:
> > > Did you upgrade by the web2py "admin" update link?
>
> > > Richard
>
> > > On Mon, Jun 27, 2011 at 2:22 PM, Christopher Baron  > > > wrote:
>
> > >> Hi web2py users,
>
> > >> Just upgraded to Version 1.97.1
>
> > >> I checked my code out into the new directory, opened my browser, and
> > >> received and error stating 'auth_cas' already exists.
>
> > >> I removed all files from the databases folder and tried again
> > >> receiving an error that 'auth_user' already exists.
>
> > >> I'm using a private/config file that points to some mysql database on
> > >> another server.
>
> > >> What can I do ?
>
> > >> I'd be happy to share more information needed to help solve the
> > >> problem.
>
> > >> Thanks in advance,
>
> > >> Chris


[web2py] Re: table auth_user already exists

2011-06-27 Thread Christopher Baron
I've tried

db = DAL("mysql://%s:%s@%s/%s" % (user, password, host, dbname),
migrate=False)

and still have the same problem.

On Jun 27, 3:07 pm, Christopher Baron  wrote:
> I upgraded via the admin update link and received an error, so I went
> ahead and downloaded the source.
>
> Regarding the migration techniques, the exception is being thrown on
> creating web2py auth tables - specifically the following line of
> code :
>
> auth.define_tables()
>
> Shouldn't web2py handle this for me?  Perhaps I need to include a line
> similar to the following?
>
> db = DAL('sqlite://storage.db', migrate=False)
>
> On Jun 27, 2:45 pm, Richard Vézina 
> wrote:
>
>
>
>
>
>
>
> > Have you try :
>
> >http://www.web2py.com/book/default/chapter/06?search=migrate#Fixing-B...
>
> > You should use migrate=False in your models once your tables have been
> > created and you know you will not have to modify them...
>
> > Richard
>
> > On Mon, Jun 27, 2011 at 3:40 PM, Richard Vézina 
> > > wrote:
> > > Did you upgrade by the web2py "admin" update link?
>
> > > Richard
>
> > > On Mon, Jun 27, 2011 at 2:22 PM, Christopher Baron  > > > wrote:
>
> > >> Hi web2py users,
>
> > >> Just upgraded to Version 1.97.1
>
> > >> I checked my code out into the new directory, opened my browser, and
> > >> received and error stating 'auth_cas' already exists.
>
> > >> I removed all files from the databases folder and tried again
> > >> receiving an error that 'auth_user' already exists.
>
> > >> I'm using a private/config file that points to some mysql database on
> > >> another server.
>
> > >> What can I do ?
>
> > >> I'd be happy to share more information needed to help solve the
> > >> problem.
>
> > >> Thanks in advance,
>
> > >> Chris


[web2py] drop-box with a subset of values

2011-06-27 Thread Martin Weissenboeck
Hi,
I need a SQLFORM with a special drop-box with a subset of values.

This is a simplified example, the whole problem is a little bit more
complex: Let's make two tables:

db.define_table('colors',
Field('color'),
Field('gr'),  # group
format='%(color)s',
)

db.define_table('person',
Field('name'),
Field('color','list:reference colors'),
)


I fill the first table:

def newcolors():
db.colors.truncate()
db.colors.bulk_insert([
{'color':'yellow', 'gr':'B'},
{'color':'green', 'gr':'A'},
{'color':'blue', 'gr':'A'},
{'color':'red', 'gr':'B'},
{'color':'white', 'gr':'B'},
{'color':'black', 'gr':'B'},
])


And now there is the SQLFORM for a new person:


def newperson():
form=SQLFORM(db.person)
return dict(form=form)



The form contains a SELECT/OPTION multiple drop-box for the colors *black to
yellow.*

My question: is it possible to have three different forms

   - a drop-box which contains only the colors of group A (green, blue)
   - a drop-box which contains only the colors of group B (yellow, red,
   white, black)
   - a drop-box with all color

Something like

form=SQLFORM(db.person, colors_for_select=[1,2])


Regards,
Martin


[web2py] Re: table auth_user already exists

2011-06-27 Thread Massimo Di Pierro
Wait... don't just try this or you messed up more. You first used
'sqlite://...' and it told you "table already exists". Now you need to
fix that before you can change database (you changed to "mysql").


On Jun 27, 3:09 pm, Christopher Baron  wrote:
> I've tried
>
> db = DAL("mysql://%s:%s@%s/%s" % (user, password, host, dbname),
> migrate=False)
>
> and still have the same problem.
>
> On Jun 27, 3:07 pm, Christopher Baron  wrote:
>
>
>
>
>
>
>
> > I upgraded via the admin update link and received an error, so I went
> > ahead and downloaded the source.
>
> > Regarding the migration techniques, the exception is being thrown on
> > creating web2py auth tables - specifically the following line of
> > code :
>
> > auth.define_tables()
>
> > Shouldn't web2py handle this for me?  Perhaps I need to include a line
> > similar to the following?
>
> > db = DAL('sqlite://storage.db', migrate=False)
>
> > On Jun 27, 2:45 pm, Richard Vézina 
> > wrote:
>
> > > Have you try :
>
> > >http://www.web2py.com/book/default/chapter/06?search=migrate#Fixing-B...
>
> > > You should use migrate=False in your models once your tables have been
> > > created and you know you will not have to modify them...
>
> > > Richard
>
> > > On Mon, Jun 27, 2011 at 3:40 PM, Richard Vézina 
> > > 
> > > > wrote:
> > > > Did you upgrade by the web2py "admin" update link?
>
> > > > Richard
>
> > > > On Mon, Jun 27, 2011 at 2:22 PM, Christopher Baron 
> > > >  > > > > wrote:
>
> > > >> Hi web2py users,
>
> > > >> Just upgraded to Version 1.97.1
>
> > > >> I checked my code out into the new directory, opened my browser, and
> > > >> received and error stating 'auth_cas' already exists.
>
> > > >> I removed all files from the databases folder and tried again
> > > >> receiving an error that 'auth_user' already exists.
>
> > > >> I'm using a private/config file that points to some mysql database on
> > > >> another server.
>
> > > >> What can I do ?
>
> > > >> I'd be happy to share more information needed to help solve the
> > > >> problem.
>
> > > >> Thanks in advance,
>
> > > >> Chris


[web2py] Re: table auth_user already exists

2011-06-27 Thread Christopher Baron
Ok,

auth.define_tables( migrate=False )

seems to fix it, but what happens when a future web2py update changes
the auth tables ?

On Jun 27, 3:09 pm, Christopher Baron  wrote:
> I've tried
>
> db = DAL("mysql://%s:%s@%s/%s" % (user, password, host, dbname),
> migrate=False)
>
> and still have the same problem.
>
> On Jun 27, 3:07 pm, Christopher Baron  wrote:
>
>
>
>
>
>
>
> > I upgraded via the admin update link and received an error, so I went
> > ahead and downloaded the source.
>
> > Regarding the migration techniques, the exception is being thrown on
> > creating web2py auth tables - specifically the following line of
> > code :
>
> > auth.define_tables()
>
> > Shouldn't web2py handle this for me?  Perhaps I need to include a line
> > similar to the following?
>
> > db = DAL('sqlite://storage.db', migrate=False)
>
> > On Jun 27, 2:45 pm, Richard Vézina 
> > wrote:
>
> > > Have you try :
>
> > >http://www.web2py.com/book/default/chapter/06?search=migrate#Fixing-B...
>
> > > You should use migrate=False in your models once your tables have been
> > > created and you know you will not have to modify them...
>
> > > Richard
>
> > > On Mon, Jun 27, 2011 at 3:40 PM, Richard Vézina 
> > > 
> > > > wrote:
> > > > Did you upgrade by the web2py "admin" update link?
>
> > > > Richard
>
> > > > On Mon, Jun 27, 2011 at 2:22 PM, Christopher Baron 
> > > >  > > > > wrote:
>
> > > >> Hi web2py users,
>
> > > >> Just upgraded to Version 1.97.1
>
> > > >> I checked my code out into the new directory, opened my browser, and
> > > >> received and error stating 'auth_cas' already exists.
>
> > > >> I removed all files from the databases folder and tried again
> > > >> receiving an error that 'auth_user' already exists.
>
> > > >> I'm using a private/config file that points to some mysql database on
> > > >> another server.
>
> > > >> What can I do ?
>
> > > >> I'd be happy to share more information needed to help solve the
> > > >> problem.
>
> > > >> Thanks in advance,
>
> > > >> Chris


[web2py] Re: drop-box with a subset of values

2011-06-27 Thread Massimo Di Pierro
yes

db.person.color.requires=IS_IN_DB(db(db.color.gr=='A'),db.color.id,'%
(color)s')
form=SQLFORM(db.person)

On Jun 27, 3:12 pm, Martin Weissenboeck  wrote:
> Hi,
> I need a SQLFORM with a special drop-box with a subset of values.
>
> This is a simplified example, the whole problem is a little bit more
> complex: Let's make two tables:
>
> db.define_table('colors',
>     Field('color'),
>     Field('gr'),  # group
>     format='%(color)s',
>     )
>
> db.define_table('person',
>     Field('name'),
>     Field('color','list:reference colors'),
>     )
>
> I fill the first table:
>
> def newcolors():
>     db.colors.truncate()
>     db.colors.bulk_insert([
>         {'color':'yellow', 'gr':'B'},
>         {'color':'green', 'gr':'A'},
>         {'color':'blue', 'gr':'A'},
>         {'color':'red', 'gr':'B'},
>         {'color':'white', 'gr':'B'},
>         {'color':'black', 'gr':'B'},
>         ])
>
> And now there is the SQLFORM for a new person:
>
> def newperson():
>     form=SQLFORM(db.person)
>     return dict(form=form)
>
> The form contains a SELECT/OPTION multiple drop-box for the colors *black to
> yellow.*
>
> My question: is it possible to have three different forms
>
>    - a drop-box which contains only the colors of group A (green, blue)
>    - a drop-box which contains only the colors of group B (yellow, red,
>    white, black)
>    - a drop-box with all color
>
> Something like
>
> form=SQLFORM(db.person, colors_for_select=[1,2])
>
> Regards,
> Martin


[web2py] Re: table auth_user already exists

2011-06-27 Thread Anthony
Note, the 'migrate' and 'fake_migrate' arguments to DAL may not do what you 
think they should do -- they merely set the 'migrate' and 'fake_migrate' 
default values for any table definitions that do not explicitly set those 
arguments -- if a table explicitly sets one or both of those arguments, that 
will override the DAL arguments. I think auth.define_tables may explicitly 
set 'migrate' to True for auth tables unless you do 
auth.define_tables(migrate=False).
 If you want to override the explicit arguments of all individual tables, 
use DAL(...,fake_migrate_all=True) to force fake migration of all tables, 
and DAL(...,migrate_enabled=False) to force all migrations off.
 Anthony


On Monday, June 27, 2011 4:09:54 PM UTC-4, Christopher Baron wrote:

> I've tried 
>
> db = DAL("mysql://%s:%s@%s/%s" % (user, password, host, dbname), 
> migrate=False) 
>
> and still have the same problem. 
>
> On Jun 27, 3:07 pm, Christopher Baron  wrote: 
> > I upgraded via the admin update link and received an error, so I went 
> > ahead and downloaded the source. 
> > 
> > Regarding the migration techniques, the exception is being thrown on 
> > creating web2py auth tables - specifically the following line of 
> > code : 
> > 
> > auth.define_tables() 
> > 
> > Shouldn't web2py handle this for me?  Perhaps I need to include a line 
> > similar to the following? 
> > 
> > db = DAL('sqlite://storage.db', migrate=False) 
> > 
> > On Jun 27, 2:45 pm, Richard Vézina  
> > wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > Have you try : 
> > 
> > >http://www.web2py.com/book/default/chapter/06?search=migrate#Fixing-B... 
>
> > 
> > > You should use migrate=False in your models once your tables have been 
> > > created and you know you will not have to modify them... 
> > 
> > > Richard 
> > 
> > > On Mon, Jun 27, 2011 at 3:40 PM, Richard Vézina  > 
> > > > wrote: 
> > > > Did you upgrade by the web2py "admin" update link? 
> > 
> > > > Richard 
> > 
> > > > On Mon, Jun 27, 2011 at 2:22 PM, Christopher Baron <
> cba...@fieldmuseum.org 
> > > > > wrote: 
> > 
> > > >> Hi web2py users, 
> > 
> > > >> Just upgraded to Version 1.97.1 
> > 
> > > >> I checked my code out into the new directory, opened my browser, and 
>
> > > >> received and error stating 'auth_cas' already exists. 
> > 
> > > >> I removed all files from the databases folder and tried again 
> > > >> receiving an error that 'auth_user' already exists. 
> > 
> > > >> I'm using a private/config file that points to some mysql database 
> on 
> > > >> another server. 
> > 
> > > >> What can I do ? 
> > 
> > > >> I'd be happy to share more information needed to help solve the 
> > > >> problem. 
> > 
> > > >> Thanks in advance, 
> > 
> > > >> Chris



Re: [web2py] Re: drop-box with a subset of values

2011-06-27 Thread Martin Weissenboeck
Hi Massimo,
looks great. But I got:

 web2py™ Version 1.97.1 (2011-06-26 19:25:44) Python Python 2.5.4:
C:\Web2Py\web2py_win\web2py\web2py.exe TRACEBACK


1.
2.
3.
4.
5.
6.
7.
8.
9.


Traceback (most recent call last):

  File "gluon/restricted.py", line 192, in restricted

  File 
"C:/Web2Py/web2py_win/web2py/applications/test16rechte/controllers/default.py"
,
line 88, in 

  File "gluon/globals.py", line 137, in 

  File 
"C:/Web2Py/web2py_win/web2py/applications/test16rechte/controllers/default.py"
,
line 84, in newperson

  File "gluon/dal.py", line 4255, in __getattr__

  File "gluon/dal.py", line 4249, in __getitem__

KeyError: 'color'

ERROR SNAPSHOT [image: help]

('color')

2011/6/27 Massimo Di Pierro 

> yes
>
> db.person.color.requires=IS_IN_DB(db(db.color.gr=='A'),db.color.id,'%
> (color)s')
> form=SQLFORM(db.person)
>
> On Jun 27, 3:12 pm, Martin Weissenboeck  wrote:
> > Hi,
> > I need a SQLFORM with a special drop-box with a subset of values.
> >
> > This is a simplified example, the whole problem is a little bit more
> > complex: Let's make two tables:
> >
> > db.define_table('colors',
> > Field('color'),
> > Field('gr'),  # group
> > format='%(color)s',
> > )
> >
> > db.define_table('person',
> > Field('name'),
> > Field('color','list:reference colors'),
> > )
> >
> > I fill the first table:
> >
> > def newcolors():
> > db.colors.truncate()
> > db.colors.bulk_insert([
> > {'color':'yellow', 'gr':'B'},
> > {'color':'green', 'gr':'A'},
> > {'color':'blue', 'gr':'A'},
> > {'color':'red', 'gr':'B'},
> > {'color':'white', 'gr':'B'},
> > {'color':'black', 'gr':'B'},
> > ])
> >
> > And now there is the SQLFORM for a new person:
> >
> > def newperson():
> > form=SQLFORM(db.person)
> > return dict(form=form)
> >
> > The form contains a SELECT/OPTION multiple drop-box for the colors *black
> to
> > yellow.*
> >
> > My question: is it possible to have three different forms
> >
> >- a drop-box which contains only the colors of group A (green, blue)
> >- a drop-box which contains only the colors of group B (yellow, red,
> >white, black)
> >- a drop-box with all color
> >
> > Something like
> >
> > form=SQLFORM(db.person, colors_for_select=[1,2])
> >
> > Regards,
> > Martin
>


Re: [web2py] Re: issue with 1.97.1

2011-06-27 Thread Anthony
On Monday, June 27, 2011 3:28:18 PM UTC-4, Richard wrote: 
>
> Also, I just tried to change the compileapp.py with Storage... It stop to 
> send the traceback and I got a : invalid view (ref/create_fvte.load)...

 
Do you have an explicit create_fvte.load view, or are you relying on 
generic.load? I think generic views aren't being used with LOAD and 
ajax=False (generic views are also disabled by default unless the request is 
local).
 
Anthony


[web2py] MSSQL2Adapter

2011-06-27 Thread E L
Hello

Rather than storing strings as UTF8 in VARCHAR, I would like to store
the strings as NVARCHAR in MSSQL.
It appears that is what MSSQL2Adapter is meant to do, but there were
errors when I tried to use it.
I believe a couple changes in the MSSQLAdapater code could make it
work (it seems to work for me).
I'm using python 2.7, pyodbc 2.1.8.

Eric

-if fieldtype == 'string' or fieldtype == 'text' and value[:1]=="'":
+if (fieldtype == 'string' or fieldtype == 'text') and value[:1]=="'":

-return self.log_execute(a,'utf8')
+return self.log_execute(a.decode('utf-8'))


Re: [web2py] Re: drop-box with a subset of values

2011-06-27 Thread Anthony
It's just a typo -- db.color.gr and db.color.id should be db.colors.gr and 
db.colors.id.
 
Anthony

On Monday, June 27, 2011 4:35:01 PM UTC-4, mweissen wrote:

> Hi Massimo, 
> looks great. But I got: 
>
>   web2py™ Version 1.97.1 (2011-06-26 19:25:44) Python Python 2.5.4: 
> C:\Web2Py\web2py_win\web2py\web2py.exe TRACEBACK 
>   
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
>
> Traceback (most recent call last):
>
>
>   File "gluon/restricted.py", line 192, in restricted
>
>
>   File 
> "C:/Web2Py/web2py_win/web2py/applications/test16rechte/controllers/default.py"
>  
> ,
>  line 88, in 
>
>
>   File "gluon/globals.py", line 137, in 
>
>
>   File 
> "C:/Web2Py/web2py_win/web2py/applications/test16rechte/controllers/default.py"
>  
> ,
>  line 84, in newperson
>
>
>   File "gluon/dal.py", line 4255, in __getattr__
>
>
>   File "gluon/dal.py", line 4249, in __getitem__
>
>
> KeyError: 'color'
>
>  ERROR SNAPSHOT [image: help] 
>
> ('color')
>
> 2011/6/27 Massimo Di Pierro 
>
>> yes
>>
>> db.person.color.requires=IS_IN_DB(db(db.color.gr=='A'),db.color.id,'%
>> (color)s')
>> form=SQLFORM(db.person)
>>  
>> On Jun 27, 3:12 pm, Martin Weissenboeck  wrote:
>> > Hi,
>> > I need a SQLFORM with a special drop-box with a subset of values.
>> >
>> > This is a simplified example, the whole problem is a little bit more
>> > complex: Let's make two tables:
>> >
>> > db.define_table('colors',
>> > Field('color'),
>> > Field('gr'),  # group
>> > format='%(color)s',
>> > )
>> >
>> > db.define_table('person',
>> > Field('name'),
>> > Field('color','list:reference colors'),
>> > )
>> >
>> > I fill the first table:
>> >
>> > def newcolors():
>> > db.colors.truncate()
>> > db.colors.bulk_insert([
>> > {'color':'yellow', 'gr':'B'},
>> > {'color':'green', 'gr':'A'},
>> > {'color':'blue', 'gr':'A'},
>> > {'color':'red', 'gr':'B'},
>> > {'color':'white', 'gr':'B'},
>> > {'color':'black', 'gr':'B'},
>> > ])
>> >
>> > And now there is the SQLFORM for a new person:
>> >
>> > def newperson():
>> > form=SQLFORM(db.person)
>> > return dict(form=form)
>> >
>> > The form contains a SELECT/OPTION multiple drop-box for the colors 
>> *black to
>> > yellow.*
>> >
>> > My question: is it possible to have three different forms
>> >
>> >- a drop-box which contains only the colors of group A (green, blue)
>> >- a drop-box which contains only the colors of group B (yellow, red,
>> >white, black)
>> >- a drop-box with all color
>> >
>> > Something like
>> >
>> > form=SQLFORM(db.person, colors_for_select=[1,2])
>> >
>> > Regards,
>> > Martin
>>
>
>
>
>
>

[web2py] Re: MSSQL2Adapter

2011-06-27 Thread Massimo Di Pierro
Your suggested change is in trunk. I am trusting you one this since I
am not a MSSQL user and cannot test it. If anybody else is using
MSSQL2Adaperter, i.e.

   DAL('mssql2://')

please check that this change does not break your code.

On Jun 27, 3:30 pm, E L  wrote:
> Hello
>
> Rather than storing strings as UTF8 in VARCHAR, I would like to store
> the strings as NVARCHAR in MSSQL.
> It appears that is what MSSQL2Adapter is meant to do, but there were
> errors when I tried to use it.
> I believe a couple changes in the MSSQLAdapater code could make it
> work (it seems to work for me).
> I'm using python 2.7, pyodbc 2.1.8.
>
> Eric
>
> -        if fieldtype == 'string' or fieldtype == 'text' and value[:1]=="'":
> +        if (fieldtype == 'string' or fieldtype == 'text') and value[:1]=="'":
>
> -        return self.log_execute(a,'utf8')
> +        return self.log_execute(a.decode('utf-8'))


[web2py] Re: table auth_user already exists

2011-06-27 Thread pbreit
I still need a tutorial on 1) how the .table and sql.log files are used, 2) 
what exactly migrate and fake_migrate do and 3) how to best resolve broken 
migrations.

Re: [web2py] Re: drop-box with a subset of values

2011-06-27 Thread Martin Weissenboeck
Oooops - thank you very much.
I think I could have found the difference between "color" and "colors"
myself  :-(

About the solution: it works very well and it is very import for my project.
I have tried to find a solution for several hours and now I have got it in
10 minutes.

web2py is great! Thank you both again!

2011/6/27 Anthony 

> It's just a typo -- db.color.gr and db.color.id should be db.colors.gr and
> db.colors.id.
>
> Anthony
>
> On Monday, June 27, 2011 4:35:01 PM UTC-4, mweissen wrote:
>
>> Hi Massimo,
>> looks great. But I got:
>>
>>web2py™ Version 1.97.1 (2011-06-26 19:25:44)  Python Python 2.5.4:
>> C:\Web2Py\web2py_win\web2py\**web2py.exe  TRACEBACK
>>
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>>
>>
>> Traceback (most recent call last):
>>
>>
>>
>>   File "gluon/restricted.py", line 192, in restricted
>>
>>
>>
>>   File 
>> "C:/Web2Py/web2py_win/web2py/**applications/test16rechte/**controllers/default.py"
>>  
>> ,
>>  line 88, in 
>>
>>
>>
>>   File "gluon/globals.py", line 137, in 
>>
>>
>>
>>   File 
>> "C:/Web2Py/web2py_win/web2py/**applications/test16rechte/**controllers/default.py"
>>  
>> ,
>>  line 84, in newperson
>>
>>
>>
>>   File "gluon/dal.py", line 4255, in __getattr__
>>
>>
>>
>>   File "gluon/dal.py", line 4249, in __getitem__
>>
>>
>>
>> KeyError: 'color'
>>
>>
>>  ERROR SNAPSHOT [image: help]
>>
>> ('color'**)
>>
>> 2011/6/27 Massimo Di Pierro 
>>
>>> yes
>>>
>>> db.person.color.requires=IS_**IN_DB(db(db.color.gr=='A'),db.**color.id
>>> ,'%
>>> (color)s')
>>> form=SQLFORM(db.person)
>>>
>>> On Jun 27, 3:12 pm, Martin Weissenboeck  wrote:
>>> > Hi,
>>> > I need a SQLFORM with a special drop-box with a subset of values.
>>> >
>>> > This is a simplified example, the whole problem is a little bit more
>>> > complex: Let's make two tables:
>>> >
>>> > db.define_table('colors',
>>> > Field('color'),
>>> > Field('gr'),  # group
>>> > format='%(color)s',
>>> > )
>>> >
>>> > db.define_table('person',
>>> > Field('name'),
>>> > Field('color','list:reference colors'),
>>> > )
>>> >
>>> > I fill the first table:
>>> >
>>> > def newcolors():
>>> > db.colors.truncate()
>>> > db.colors.bulk_insert([
>>> > {'color':'yellow', 'gr':'B'},
>>> > {'color':'green', 'gr':'A'},
>>> > {'color':'blue', 'gr':'A'},
>>> > {'color':'red', 'gr':'B'},
>>> > {'color':'white', 'gr':'B'},
>>> > {'color':'black', 'gr':'B'},
>>> > ])
>>> >
>>> > And now there is the SQLFORM for a new person:
>>> >
>>> > def newperson():
>>> > form=SQLFORM(db.person)
>>> > return dict(form=form)
>>> >
>>> > The form contains a SELECT/OPTION multiple drop-box for the colors
>>> *black to
>>> > yellow.*
>>> >
>>> > My question: is it possible to have three different forms
>>> >
>>> >- a drop-box which contains only the colors of group A (green, blue)
>>> >- a drop-box which contains only the colors of group B (yellow, red,
>>> >white, black)
>>> >- a drop-box with all color
>>> >
>>> > Something like
>>> >
>>> > form=SQLFORM(db.person, colors_for_select=[1,2])
>>> >
>>> > Regards,
>>> > Martin
>>>
>>
>>
>>
>>


Re: [web2py] Re: drop-box with a subset of values

2011-06-27 Thread Anthony
Yes, web2py has lots of neat tricks. Rather than a whole db connection, 
the IS_IN_DB validator can also take a DAL Set to limit the records shown -- 
see http://web2py.com/book/default/chapter/07#Database-Validators.

On Monday, June 27, 2011 4:44:52 PM UTC-4, mweissen wrote:

> Oooops - thank you very much. 
> I think I could have found the difference between "color" and "colors" 
> myself  :-(
>
> About the solution: it works very well and it is very import for my 
> project.
> I have tried to find a solution for several hours and now I have got it in 
> 10 minutes.
>
> web2py is great! Thank you both again!
>
> 2011/6/27 Anthony 
>
>> It's just a typo -- db.color.gr and db.color.id should be db.colors.grand 
>> db.colors.id.
>>  
>> Anthony
>>   
>> On Monday, June 27, 2011 4:35:01 PM UTC-4, mweissen wrote:
>>
>>> Hi Massimo, 
>>>  looks great. But I got: 
>>>
>>> web2py™ Version 1.97.1 (2011-06-26 19:25:44) Python Python 2.5.4: 
>>> C:\Web2Py\web2py_win\web2py\**web2py.exe TRACEBACK 
>>>   
>>> 1.
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>>
>>> Traceback (most recent call last):
>>>
>>>
>>>
>>>
>>>   File "gluon/restricted.py", line 192, in restricted
>>>
>>>
>>>
>>>
>>>   File 
>>> "C:/Web2Py/web2py_win/web2py/**applications/test16rechte/**controllers/default.py"
>>>  
>>> ,
>>>  line 88, in 
>>>
>>>
>>>
>>>
>>>   File "gluon/globals.py", line 137, in 
>>>
>>>
>>>
>>>
>>>   File 
>>> "C:/Web2Py/web2py_win/web2py/**applications/test16rechte/**controllers/default.py"
>>>  
>>> ,
>>>  line 84, in newperson
>>>
>>>
>>>
>>>
>>>   File "gluon/dal.py", line 4255, in __getattr__
>>>
>>>
>>>
>>>
>>>   File "gluon/dal.py", line 4249, in __getitem__
>>>
>>>
>>>
>>>
>>> KeyError: 'color'
>>>
>>>
>>>
>>>  ERROR SNAPSHOT [image: help] 
>>>
>>> ('color'**)
>>>
>>> 2011/6/27 Massimo Di Pierro 
>>>
 yes

 db.person.color.requires=IS_**IN_DB(db(db.color.gr=='A'),db.**color.id
 ,'%
 (color)s')
 form=SQLFORM(db.person)

 On Jun 27, 3:12 pm, Martin Weissenboeck  wrote:
 > Hi,
 > I need a SQLFORM with a special drop-box with a subset of values.
 >
 > This is a simplified example, the whole problem is a little bit more
 > complex: Let's make two tables:
 >
 > db.define_table('colors',
 > Field('color'),
 > Field('gr'),  # group
 > format='%(color)s',
 > )
 >
 > db.define_table('person',
 > Field('name'),
 > Field('color','list:reference colors'),
 > )
 >
 > I fill the first table:
 >
 > def newcolors():
 > db.colors.truncate()
 > db.colors.bulk_insert([
 > {'color':'yellow', 'gr':'B'},
 > {'color':'green', 'gr':'A'},
 > {'color':'blue', 'gr':'A'},
 > {'color':'red', 'gr':'B'},
 > {'color':'white', 'gr':'B'},
 > {'color':'black', 'gr':'B'},
 > ])
 >
 > And now there is the SQLFORM for a new person:
 >
 > def newperson():
 > form=SQLFORM(db.person)
 > return dict(form=form)
 >
 > The form contains a SELECT/OPTION multiple drop-box for the colors 
 *black to
 > yellow.*
 >
 > My question: is it possible to have three different forms
 >
 >- a drop-box which contains only the colors of group A (green, 
 blue)
 >- a drop-box which contains only the colors of group B (yellow, 
 red,
 >white, black)
 >- a drop-box with all color
 >
 > Something like
 >
 > form=SQLFORM(db.person, colors_for_select=[1,2])
 >
 > Regards,
 > Martin

>>>
>>>
>>>
>>>

Re: [web2py] Re: issue with 1.97.1

2011-06-27 Thread Richard Vézina
I use generic...

I try to make a  create_fvte.load view and report back.

Thanks.

Richard

On Mon, Jun 27, 2011 at 4:36 PM, Anthony  wrote:

> On Monday, June 27, 2011 3:28:18 PM UTC-4, Richard wrote:
>>
>> Also, I just tried to change the compileapp.py with Storage... It stop to
>> send the traceback and I got a : invalid view (ref/create_fvte.load)...
>
>
> Do you have an explicit create_fvte.load view, or are you relying on
> generic.load? I think generic views aren't being used with LOAD and
> ajax=False (generic views are also disabled by default unless the request is
> local).
>
> Anthony
>


Re: [web2py] Re: issue with 1.97.1

2011-06-27 Thread Richard Vézina
You got it again Anthony!

Does it cause security hole to occure if I just copy and rename the
generic.load under create_fvte.load?

Related thread :
http://groups.google.com/group/web2py-developers/browse_thread/thread/8a5885186144e194


Thanks you...

Richard




On Mon, Jun 27, 2011 at 5:00 PM, Richard Vézina  wrote:

> I use generic...
>
> I try to make a  create_fvte.load view and report back.
>
> Thanks.
>
> Richard
>
> On Mon, Jun 27, 2011 at 4:36 PM, Anthony  wrote:
>
>> On Monday, June 27, 2011 3:28:18 PM UTC-4, Richard wrote:
>>>
>>> Also, I just tried to change the compileapp.py with Storage... It stop to
>>> send the traceback and I got a : invalid view (ref/create_fvte.load)...
>>
>>
>> Do you have an explicit create_fvte.load view, or are you relying on
>> generic.load? I think generic views aren't being used with LOAD and
>> ajax=False (generic views are also disabled by default unless the request is
>> local).
>>
>> Anthony
>>
>
>


Re: [web2py] Re: issue with 1.97.1

2011-06-27 Thread Anthony
You could also explicitly set response.view='generic.load' in your 
create_fvte function.
 
Anthony

On Monday, June 27, 2011 5:00:00 PM UTC-4, Richard wrote:

> I use generic... 
>
> I try to make a  create_fvte.load view and report back.
>
> Thanks.
>
> Richard
>
> On Mon, Jun 27, 2011 at 4:36 PM, Anthony  wrote:
>
>> On Monday, June 27, 2011 3:28:18 PM UTC-4, Richard wrote: 
>>>
>>> Also, I just tried to change the compileapp.py with Storage... It stop to 
>>> send the traceback and I got a : invalid view (ref/create_fvte.load)...
>>
>>  
>> Do you have an explicit create_fvte.load view, or are you relying on 
>> generic.load? I think generic views aren't being used with LOAD and 
>> ajax=False (generic views are also disabled by default unless the request is 
>> local).
>>  
>> Anthony
>>
>
>

[web2py] Re: web2py 1.97.1 is OUT

2011-06-27 Thread pbreit
Bump. wanted to make sure this didn't get lost:

Typo in:
http://code.google.com/p/web2py/source/detail?r=04f1d1cb11c193bf813d427e77c101a0eb90e495

"Storage" mis-spelled:

*other_request.vars = **Stoarge(**vars**)*


Re: [web2py] Re: web2py connection pooling and database server reboot

2011-06-27 Thread Roman Bataev
Informing the users is not a problem in our case because it's our internal
app that is used by our employees during business hours and we reboot the
database  server on weekend. The only problem is that without restarting
web2py people get the above error once they start using the app on Monday.
Looks like the only solution to this right now is to schedule web2py restart
right after db server reboot. Not ideal, but should work for our weekly
updates. This will still be a problem in case of intermittent
network glitches or if db server goes down unexpectedly which may result in
unusable connections in the pool. Ideally web2py should be able to recover
without restarting. While it obviously cannot do anything while db is down
it should be able to start working again once the db is back up. I think
ADO.Net pooling works this way (at least we never had the above problem in
.Net apps).


-Roman


On Mon, Jun 27, 2011 at 1:49 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Yes this is because of connection pooling. The fact is, when you
> database is down, web2py will return errors because it cannot connect
> to your database. While on the one side we could have web2py return
> more graceful errors, I think it is better follow the following
> strategy:
>
> 1) redirect all your http requests to a static pages that says "down
> for maintenance"
> 2) turn off web2py (reboot the server if using apache for example)
> 3) turn off database and do required database maintenance
> 4) restart database
> 5) restart web2py
> 6) redirect http requests back to web2py
>
> I guess web2py could handle the missing database connections itself
> but you still are left with the problem of informing the users.
>
>
> On Jun 27, 12:06 pm, Roman Bataev  wrote:
> > We run web2py with ms sql server as a database backend. Every weekend sql
> > server gets rebooted (to install microsoft updates), after which web2py
> apps
> > start failing with the following error message:
> >
> > *('08S02', '[08S02] [Microsoft][SQL Server Native Client 10.0]SMux
> Provider:
> > Physical connection is not usable [x]. (-1) (SQLExecDirectW);
> > [08S02] [Microsoft][SQL Server Native Client 10.0]Unable to open a
> logical
> > session (-1)')*
> >
> > The only way to get them back up and running is to restart web2py.
> >
> > I suspect it has something to do with database connection pooling (which
> we
> > do use). I have not taken a look at the code yet, so I am not sure if
> web2py
> > connection pooling reopens physical db connection if it becomes unusable
> > because of db server reboot or network failure or something else.
> >
> > Has anyone had this issue? I cannot think of any good solution for this
> so
> > any help would be highly appreciated.


[web2py] Re: web2py connection pooling and database server reboot

2011-06-27 Thread Massimo Di Pierro
One possible solution is reset the pool when one connection from the
pool is lost. Will look into it. Can you please open a ticket in
google code?

On Jun 27, 4:23 pm, Roman Bataev  wrote:
> Informing the users is not a problem in our case because it's our internal
> app that is used by our employees during business hours and we reboot the
> database  server on weekend. The only problem is that without restarting
> web2py people get the above error once they start using the app on Monday.
> Looks like the only solution to this right now is to schedule web2py restart
> right after db server reboot. Not ideal, but should work for our weekly
> updates. This will still be a problem in case of intermittent
> network glitches or if db server goes down unexpectedly which may result in
> unusable connections in the pool. Ideally web2py should be able to recover
> without restarting. While it obviously cannot do anything while db is down
> it should be able to start working again once the db is back up. I think
> ADO.Net pooling works this way (at least we never had the above problem in
> .Net apps).
>
> -Roman
>
> On Mon, Jun 27, 2011 at 1:49 PM, Massimo Di Pierro <
>
>
>
>
>
>
>
> massimo.dipie...@gmail.com> wrote:
> > Yes this is because of connection pooling. The fact is, when you
> > database is down, web2py will return errors because it cannot connect
> > to your database. While on the one side we could have web2py return
> > more graceful errors, I think it is better follow the following
> > strategy:
>
> > 1) redirect all your http requests to a static pages that says "down
> > for maintenance"
> > 2) turn off web2py (reboot the server if using apache for example)
> > 3) turn off database and do required database maintenance
> > 4) restart database
> > 5) restart web2py
> > 6) redirect http requests back to web2py
>
> > I guess web2py could handle the missing database connections itself
> > but you still are left with the problem of informing the users.
>
> > On Jun 27, 12:06 pm, Roman Bataev  wrote:
> > > We run web2py with ms sql server as a database backend. Every weekend sql
> > > server gets rebooted (to install microsoft updates), after which web2py
> > apps
> > > start failing with the following error message:
>
> > > *('08S02', '[08S02] [Microsoft][SQL Server Native Client 10.0]SMux
> > Provider:
> > > Physical connection is not usable [x]. (-1) (SQLExecDirectW);
> > > [08S02] [Microsoft][SQL Server Native Client 10.0]Unable to open a
> > logical
> > > session (-1)')*
>
> > > The only way to get them back up and running is to restart web2py.
>
> > > I suspect it has something to do with database connection pooling (which
> > we
> > > do use). I have not taken a look at the code yet, so I am not sure if
> > web2py
> > > connection pooling reopens physical db connection if it becomes unusable
> > > because of db server reboot or network failure or something else.
>
> > > Has anyone had this issue? I cannot think of any good solution for this
> > so
> > > any help would be highly appreciated.


[web2py] Re: web2py 1.97.1 is OUT

2011-06-27 Thread Massimo Di Pierro
fixed. thanks.

On Jun 27, 4:11 pm, pbreit  wrote:
> Bump. wanted to make sure this didn't get lost:
>
> Typo 
> in:http://code.google.com/p/web2py/source/detail?r=04f1d1cb11c193bf813d4...
>
> "Storage" mis-spelled:
>
> *other_request.vars = **Stoarge(**vars**)*


Re: [web2py] Re: issue with 1.97.1

2011-06-27 Thread Richard Vézina
My session.tab_pos variable is not updated anymore :-(

Richard

On Mon, Jun 27, 2011 at 5:07 PM, Anthony  wrote:

> You could also explicitly set response.view='generic.load' in your
> create_fvte function.
>
> Anthony
>
> On Monday, June 27, 2011 5:00:00 PM UTC-4, Richard wrote:
>
>> I use generic...
>>
>> I try to make a  create_fvte.load view and report back.
>>
>> Thanks.
>>
>> Richard
>>
>> On Mon, Jun 27, 2011 at 4:36 PM, Anthony  wrote:
>>
>>> On Monday, June 27, 2011 3:28:18 PM UTC-4, Richard wrote:

 Also, I just tried to change the compileapp.py with Storage... It stop
 to send the traceback and I got a : invalid view (ref/create_fvte.load)...
>>>
>>>
>>> Do you have an explicit create_fvte.load view, or are you relying on
>>> generic.load? I think generic views aren't being used with LOAD and
>>> ajax=False (generic views are also disabled by default unless the request is
>>> local).
>>>
>>> Anthony
>>>
>>
>>


[web2py] Re: issue with 1.97.1

2011-06-27 Thread Massimo Di Pierro
Please use ajax=True for this not ajax=False. because changing the
session within another session is problematic conceptually. I am
surprised this worked before. Anyway, open a ticket and I will look
more into it.

On Jun 27, 4:32 pm, Richard Vézina 
wrote:
> My session.tab_pos variable is not updated anymore :-(
>
> Richard
>
>
>
>
>
>
>
> On Mon, Jun 27, 2011 at 5:07 PM, Anthony  wrote:
> > You could also explicitly set response.view='generic.load' in your
> > create_fvte function.
>
> > Anthony
>
> > On Monday, June 27, 2011 5:00:00 PM UTC-4, Richard wrote:
>
> >> I use generic...
>
> >> I try to make a  create_fvte.load view and report back.
>
> >> Thanks.
>
> >> Richard
>
> >> On Mon, Jun 27, 2011 at 4:36 PM, Anthony  wrote:
>
> >>> On Monday, June 27, 2011 3:28:18 PM UTC-4, Richard wrote:
>
>  Also, I just tried to change the compileapp.py with Storage... It stop
>  to send the traceback and I got a : invalid view 
>  (ref/create_fvte.load)...
>
> >>> Do you have an explicit create_fvte.load view, or are you relying on
> >>> generic.load? I think generic views aren't being used with LOAD and
> >>> ajax=False (generic views are also disabled by default unless the request 
> >>> is
> >>> local).
>
> >>> Anthony


Re: [web2py] Re: web2py 1.97.1 is OUT

2011-06-27 Thread Richard Vézina
You got the typo... Good.

Richard

On Mon, Jun 27, 2011 at 5:27 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> fixed. thanks.
>
> On Jun 27, 4:11 pm, pbreit  wrote:
> > Bump. wanted to make sure this didn't get lost:
> >
> > Typo in:
> http://code.google.com/p/web2py/source/detail?r=04f1d1cb11c193bf813d4...
> >
> > "Storage" mis-spelled:
> >
> > *other_request.vars = **Stoarge(**vars**)*


Re: [web2py] Re: issue with 1.97.1

2011-06-27 Thread Richard Vézina
I did it this way because ajax=True was pretty slow and seams to conflict
with jQuery UI Tabs plugin ajax call...

Really not a master of javascript, so I can determine if it is component, my
usage of components, LOAD call, etc.

I will try ajax=True and report back tomorrow...

Richard





On Mon, Jun 27, 2011 at 5:37 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Please use ajax=True for this not ajax=False. because changing the
> session within another session is problematic conceptually. I am
> surprised this worked before. Anyway, open a ticket and I will look
> more into it.
>
> On Jun 27, 4:32 pm, Richard Vézina 
> wrote:
> > My session.tab_pos variable is not updated anymore :-(
> >
> > Richard
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Jun 27, 2011 at 5:07 PM, Anthony  wrote:
> > > You could also explicitly set response.view='generic.load' in your
> > > create_fvte function.
> >
> > > Anthony
> >
> > > On Monday, June 27, 2011 5:00:00 PM UTC-4, Richard wrote:
> >
> > >> I use generic...
> >
> > >> I try to make a  create_fvte.load view and report back.
> >
> > >> Thanks.
> >
> > >> Richard
> >
> > >> On Mon, Jun 27, 2011 at 4:36 PM, Anthony  wrote:
> >
> > >>> On Monday, June 27, 2011 3:28:18 PM UTC-4, Richard wrote:
> >
> >  Also, I just tried to change the compileapp.py with Storage... It
> stop
> >  to send the traceback and I got a : invalid view
> (ref/create_fvte.load)...
> >
> > >>> Do you have an explicit create_fvte.load view, or are you relying on
> > >>> generic.load? I think generic views aren't being used with LOAD and
> > >>> ajax=False (generic views are also disabled by default unless the
> request is
> > >>> local).
> >
> > >>> Anthony
>


[web2py] Re: issue with 1.97.1

2011-06-27 Thread Anthony
With ajax=False, LOAD doesn't start a whole new request or do anything with 
the session, so shouldn't it be possible for non-ajax components to access 
and write to the session?
 
Anthony

On Monday, June 27, 2011 5:37:29 PM UTC-4, Massimo Di Pierro wrote:

> Please use ajax=True for this not ajax=False. because changing the 
> session within another session is problematic conceptually. I am 
> surprised this worked before. Anyway, open a ticket and I will look 
> more into it. 
>
> On Jun 27, 4:32 pm, Richard Vézina  
> wrote: 
> > My session.tab_pos variable is not updated anymore :-( 
> > 
> > Richard 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Mon, Jun 27, 2011 at 5:07 PM, Anthony  wrote: 
> > > You could also explicitly set response.view='generic.load' in your 
> > > create_fvte function. 
> > 
> > > Anthony 
> > 
> > > On Monday, June 27, 2011 5:00:00 PM UTC-4, Richard wrote: 
> > 
> > >> I use generic... 
> > 
> > >> I try to make a  create_fvte.load view and report back. 
> > 
> > >> Thanks. 
> > 
> > >> Richard 
> > 
> > >> On Mon, Jun 27, 2011 at 4:36 PM, Anthony  wrote: 
> > 
> > >>> On Monday, June 27, 2011 3:28:18 PM UTC-4, Richard wrote: 
> > 
> >  Also, I just tried to change the compileapp.py with Storage... It 
> stop 
> >  to send the traceback and I got a : invalid view 
> (ref/create_fvte.load)... 
> > 
> > >>> Do you have an explicit create_fvte.load view, or are you relying on 
> > >>> generic.load? I think generic views aren't being used with LOAD and 
> > >>> ajax=False (generic views are also disabled by default unless the 
> request is 
> > >>> local). 
> > 
> > >>> Anthony



[web2py] suggestion for improvement for A

2011-06-27 Thread Sebastian E. Ovide
Hi All,

some times a link A will reload a component (via cid=request.cid). In those
situations would be nice to have some kind of "loading" message displayed.

thanks

-- 
Sebastian E. Ovide


Re: [web2py] Re: web2py with Eclipse

2011-06-27 Thread Sebastian E. Ovide
That's it !

thanks

On Mon, Jun 27, 2011 at 1:16 AM, Pierre Thibault  wrote:

> from applications.soso.models.some_module import my_db_helper_here
>
> I'm sorry I forgot the "some_module" in my first example.
>



-- 
Sebastian E. Ovide


Re: [web2py] suggestion for improvement for A

2011-06-27 Thread David J.

You can pass a loading image to the load function



On 6/27/11 6:13 PM, Sebastian E. Ovide wrote:

Hi All,

some times a link A will reload a component (via cid=request.cid). In 
those situations would be nice to have some kind of "loading" message 
displayed.


thanks

--
Sebastian E. Ovide








[web2py] proper way to mobile and desktop 'skins'

2011-06-27 Thread Luis Goncalves
Hello!

I need to customize my views so that they look good on a computer screen and 
on a smart phone.

One way to do so, It think, is to have separate layout definitions and then 
do something like:

{{if session.platform == 'mobile':}}
{{extend 'mobile-layout.html}}
{{else:}}
{{extend 'desktop-layout.html'}}
{{pass}}

This does not seem to be working -  I get lots of syntax errors (can't even 
figure out where they are!)

Is this approach wrong?   Is it possible to have a conditional "extend" ?

Is there a smarter/better way to make the view rendering platform dependent?

Thanks,
Luis.


Re: [web2py] Re: issue with 1.97.1

2011-06-27 Thread Anthony
On Monday, June 27, 2011 4:36:29 PM UTC-4, Anthony wrote: 
>
> On Monday, June 27, 2011 3:28:18 PM UTC-4, Richard wrote: 
>>
>> Also, I just tried to change the compileapp.py with Storage... It stop to 
>> send the traceback and I got a : invalid view (ref/create_fvte.load)...
>
>  
> Do you have an explicit create_fvte.load view, or are you relying on 
> generic.load? I think generic views aren't being used with LOAD and 
> ajax=False (generic views are also disabled by default unless the request is 
> local).
>
 
FYI, I just submitted a patch to fix this problem -- so components with 
ajax=False should be able to make use of generic views again (this broke 
when we introduced response.generic_patterns, which wasn't getting passed to 
non-ajax components).
 
Anthony


[web2py] Re: proper way to mobile and desktop 'skins'

2011-06-27 Thread Anthony
I don't think you can have conditional extend commands like that (extend and 
include are not Python commands -- they are processed by the template engine 
before the Python is run). You can have conditional include commands, but 
technically all of the included views will be included and then 
conditionally executed.
 
You might be able to do an extend with a variable (set in the controller and 
passed to the view in the returned dict) in place of the view name, but in 
that case, you will not be able to bytecode compile the views because the 
compiler needs to know the extended view at compile time, but it won't 
actually be determined until run time.
 
Anthony

On Monday, June 27, 2011 7:28:37 PM UTC-4, Luis Goncalves wrote:

> Hello!
>
> I need to customize my views so that they look good on a computer screen 
> and on a smart phone.
>
> One way to do so, It think, is to have separate layout definitions and then 
> do something like:
>
> {{if session.platform == 'mobile':}}
> {{extend 'mobile-layout.html}}
> {{else:}}
> {{extend 'desktop-layout.html'}}
> {{pass}}
>
> This does not seem to be working -  I get lots of syntax errors (can't even 
> figure out where they are!)
>
> Is this approach wrong?   Is it possible to have a conditional "extend" ?
>
> Is there a smarter/better way to make the view rendering platform 
> dependent?
>
> Thanks,
> Luis.
>


[web2py] Re: proper way to mobile and desktop 'skins'

2011-06-27 Thread Anthony
On Monday, June 27, 2011 7:38:39 PM UTC-4, Anthony wrote: 
>
> I don't think you can have conditional extend commands like that (extend 
> and include are not Python commands -- they are processed by the template 
> engine before the Python is run). You can have conditional include commands, 
> but technically all of the included views will be included and then 
> conditionally executed.
>  
> You might be able to do an extend with a variable (set in the controller 
> and passed to the view in the returned dict) in place of the view name, but 
> in that case, you will not be able to bytecode compile the views because the 
> compiler needs to know the extended view at compile time, but it won't 
> actually be determined until run time.
>
 
FYI, I think bytecode compiling yields a significant performance 
improvement, particularly for views, so foregoing bytecode for views could 
be a bit of a sacrifice. I'm not sure if there's another solution (other 
than creating separate desktop and mobile views for individual actions, 
which would then extend different layouts).
 
Anthony


[web2py] Re: proper way to mobile and desktop 'skins'

2011-06-27 Thread Luis Goncalves
Thanks for the quick reply, Anthony!!!

We may try the following : break layout.html into  header and footer  
(everything before and after ),  then instead of using {{extend}}  we 
will use conditional {{include}} statements at the top and bottom of each 
view.  That will still give us bytecode compiling, and a fairly 
clean/straightforward way to have multiple platform dependent layouts (with 
minimal code change, and maximal code reuse!).

Thanks for your insight!!!
Luis.


Re: [web2py] Re: web2py connection pooling and database server reboot

2011-06-27 Thread Roman Bataev
Done. #317.

Thank you!

-Roman


On Mon, Jun 27, 2011 at 5:26 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> One possible solution is reset the pool when one connection from the
> pool is lost. Will look into it. Can you please open a ticket in
> google code?
>
> On Jun 27, 4:23 pm, Roman Bataev  wrote:
> > Informing the users is not a problem in our case because it's our
> internal
> > app that is used by our employees during business hours and we reboot the
> > database  server on weekend. The only problem is that without restarting
> > web2py people get the above error once they start using the app on
> Monday.
> > Looks like the only solution to this right now is to schedule web2py
> restart
> > right after db server reboot. Not ideal, but should work for our weekly
> > updates. This will still be a problem in case of intermittent
> > network glitches or if db server goes down unexpectedly which may result
> in
> > unusable connections in the pool. Ideally web2py should be able to
> recover
> > without restarting. While it obviously cannot do anything while db is
> down
> > it should be able to start working again once the db is back up. I think
> > ADO.Net pooling works this way (at least we never had the above problem
> in
> > .Net apps).
> >
> > -Roman
> >
> > On Mon, Jun 27, 2011 at 1:49 PM, Massimo Di Pierro <
> >
> >
> >
> >
> >
> >
> >
> > massimo.dipie...@gmail.com> wrote:
> > > Yes this is because of connection pooling. The fact is, when you
> > > database is down, web2py will return errors because it cannot connect
> > > to your database. While on the one side we could have web2py return
> > > more graceful errors, I think it is better follow the following
> > > strategy:
> >
> > > 1) redirect all your http requests to a static pages that says "down
> > > for maintenance"
> > > 2) turn off web2py (reboot the server if using apache for example)
> > > 3) turn off database and do required database maintenance
> > > 4) restart database
> > > 5) restart web2py
> > > 6) redirect http requests back to web2py
> >
> > > I guess web2py could handle the missing database connections itself
> > > but you still are left with the problem of informing the users.
> >
> > > On Jun 27, 12:06 pm, Roman Bataev  wrote:
> > > > We run web2py with ms sql server as a database backend. Every weekend
> sql
> > > > server gets rebooted (to install microsoft updates), after which
> web2py
> > > apps
> > > > start failing with the following error message:
> >
> > > > *('08S02', '[08S02] [Microsoft][SQL Server Native Client 10.0]SMux
> > > Provider:
> > > > Physical connection is not usable [x]. (-1) (SQLExecDirectW);
> > > > [08S02] [Microsoft][SQL Server Native Client 10.0]Unable to open a
> > > logical
> > > > session (-1)')*
> >
> > > > The only way to get them back up and running is to restart web2py.
> >
> > > > I suspect it has something to do with database connection pooling
> (which
> > > we
> > > > do use). I have not taken a look at the code yet, so I am not sure if
> > > web2py
> > > > connection pooling reopens physical db connection if it becomes
> unusable
> > > > because of db server reboot or network failure or something else.
> >
> > > > Has anyone had this issue? I cannot think of any good solution for
> this
> > > so
> > > > any help would be highly appreciated.
>


[web2py] Question preview images

2011-06-27 Thread kevin...@internode.on.net
I dont have much programming exp in python and web2py.
I am creating a project where you create a a database of say jigsaw
puzzles. Is there any way to preview the image of a uploaded database
field before you would submit and process the input form


I would like the add form, to display the preview of the image before
being added to the database
my code so far
db.py file

db=SQLDB("sqlite://jigsaw.db")

db.define_table('size',
SQLField('pices'))


db.define_table('jigsaw',
SQLField('Company_Brand'),
SQLField('Series_Name'),
SQLField('Name_of_Puzzle'),
SQLField('Size_of_Puzzle',db.size),
SQLField('Non_Standard_No_of_Piecs'),
SQLField('picture','upload'))

db.jigsaw.Company_Brand.requires=[IS_NOT_EMPTY()]
db.jigsaw.Series_Name.requires=[IS_NOT_EMPTY()]
db.jigsaw.Name_of_Puzzle.requires=[IS_NOT_EMPTY()]
db.size.pices.requires = IS_NOT_IN_DB(db,'size.pices')
db.jigsaw.Size_of_Puzzle.requires = IS_IN_DB(db,'size.id','%(pices)s')


controller

def index():
return dict() ###

def download(): ###
return response.download(request,db) ###

def add():
form=SQLFORM(db.jigsaw)
if form.accepts(request.vars, session):
redirect(URL(r=request, c='default', f='index'))
records=db(db.jigsaw.id>3).select()
return dict(form = form,records =
records,upload=URL(r=request,f='download')) ###

views are standard