[web2py] Re: web2py 2.0 almost done

2012-08-08 Thread pbreit
Seems to me a workflow engine should be an add-on of some sort. Does any 
other framework include something similar?

-- 





[web2py] Re: web2py 2.0 almost done

2012-08-08 Thread Andrew
I guess Ross People's worflow process engine didn't make it in to 2.0 ?


On Thursday, August 9, 2012 5:29:58 PM UTC+12, Andrew wrote:
>
> Just a note on IE7 navbar behaviour:
>
> The Menu has taken a turn for the worse:
> Initially the Welcome App Sub Menus dissapeared in :  "welcome css pathc, 
> issue 896, thanks Angelo"
> They then returned in "fixed issue qith clicking on toplevel menus" 
> except all of the submenus are displayed when the menu first appears and 
> they are all on top of each other.
>
> The login options are still blue, and the space between the navbar and 
> "Welcome" isn't there.
> See screen shot.
>
>
> On Thursday, August 9, 2012 9:17:17 AM UTC+12, Massimo Di Pierro wrote:
>>
>> more issues have been addressed. In order to fix an issue I had to 
>> introduce a slight change of behavior and I am not sure what is the best 
>> way to handle it.
>>
>> If you login using a third party service (for example janrain using 
>> facebook) and the service sends info about you, if web2py has corresponding 
>> fields in auth_user, it stores them. If you edit your profile, logout, 
>> change your facebook profile, login again using janrain, should web2py keep 
>> the current local profile or update it? The bug report suggested that 
>> web2oy should always give preference to the local profile.
>>
>> I changed web2py accordingly. In practice this change will probably not 
>> affect anybody because none of the services sends any information stored by 
>> auth_user.
>>
>> Yet, please check it.
>>
>> Massimo
>>
>>
>>
>> On Monday, 6 August 2012 23:33:48 UTC-5, Massimo Di Pierro wrote:
>>>
>>> Web2py 2.0 is almost done. 
>>> Please try the nightly build.
>>> Let us know if it breaks anything.
>>>
>>> massimo
>>>
>>

-- 





[web2py] Re: Legacy table without primary key?

2012-08-08 Thread pbreit
OK, I think I may have found the answer.

The legacy definition is:

CREATE TABLE `users_to_landlords` (
  `user_id` smallint(6) NOT NULL DEFAULT '0',
  `landlord_id` smallint(6) NOT NULL DEFAULT '0',
  `prop_id` smallint(8) NOT NULL DEFAULT '0',
  PRIMARY KEY (`user_id`,`landlord_id`,`prop_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

So I think I can add "primarykey=['user_id', 'landlord_id', 'prop_id']" to 
the define_table()

-- 





Re: [web2py] Re: web2py on appfog

2012-08-08 Thread Mandar Vaze
I have been using pythonanywhere last few days (Free account for testing 
purposes)
Deployment is easy - They have a big "deploy web2py app" button :)
They give you access to bash/mysql console via browser - Very nice. Paid 
accounts get native ssh access too.
Their response time for support queries also has been decent.

Only problem - it seems slow. I say "seems" because I have no benchmark 
numbers. Since I'm new to web2py - it maybe problem with how i've coded my 
app. 

Anyone else using pythonanywhere ? Especially "paid" account ? Would you 
recommend it for "long term" and/or production deployment ?

-Mandar

On Sunday, August 5, 2012 11:26:00 PM UTC+5:30, curiouslearn wrote:
>
> Thanks for sharing that Spiffytech. 
>
> I think it would be helpful to new users like me if on web2py page we 
> collect information on which are good hosts and easy  instructions on 
> how to deploy web2py on these hosts. 
>
>
>
> On Sun, Jul 29, 2012 at 12:04 AM, spiffytech 
> > 
> wrote: 
> > Tonight I threw up a copy of my personal site, just to see if AppFog is 
> > worth looking into. Perhaps my experience would have been better if I 
> tried 
> > during business hours while their live chat support was open, but I 
> don't 
> > plan to use AppFog after this experience. 
> > 
> > The highlights: 
> > 
> > They advertise unlimited apps, but you're limited by how many apps you 
> can 
> > squeeze into the RAM your account gets. Sure, you don't have the hard 
> cap of 
> > 10 apps like App Engine (still?) gives you, but "unlimited" isn't really 
> > true 
> > AppFog's founder wants you to believe they're proving PaaS doesn't have 
> to 
> > be slow and expensive, but I found AppFog to be slow, and their pricing 
> gets 
> > nutty-expensive very fast 
> > Getting my app working at all was a trying experience, and AppFog 
> doesn't 
> > offer much in the way of documentation or debug output to help you 
> > No sign of a cron system, so you'll be relying on web2py's built-in cron 
> > (didn't check if it works there, but I assume so) 
> > All apps have a 100MB disk limit, and I don't see a way to buy more. 
> Better 
> > hope you're apps don't get very big! 
> > You do have a writable filesystem, for what that's worth with the 100MB 
> disk 
> > use limit. I didn't check whether all instances access the same FS 
> (that's 
> > kind of an important way so design the service) 
> > 
> > My conclusion: If you want a free place to host something that (really, 
> > really) doesn't need to be performant, AppFog is a decent choice 
> because: 
> > 
> > It has a writable filesystem, which sets it apart from App Engine 
> > It has MySQL, which sets it apart from App Engine 
> > It looks more likely to stick around than some of the other free web 
> host 
> > services that I've seen mentioned here 
> > 
> > However, to get that free hosting you'll have to put up with terrible 
> > performance (or highly variable performance if it magically speeds up by 
> > tomorrow morning), poor documentation, and a tricky and opaque setup 
> > procedure. 
> > 
> > On to doing stuff, and statistics! 
> > 
> > First off, I could not find any links on their site instructing me on 
> how to 
> > configure a Python app to work on AppFog. I eventually gave up and 
> resorted 
> > to Googling for a tutorial, which led me to this section in AppFog's 
> docs. 
> > Not sure how you are supposed to find that. 
> > 
> > That link isn't too helpful, though- it shows how to make a Flask site 
> that 
> > works on AppFog, and links to working Bottle and Django sites, but 
> doesn't 
> > spell out how to make a generic WSGI site work. To make my simple web2py 
> > site work, I had to do the following: 
> > 
> > mv wsgihandler.py wsgi.py  # AppFog needs wsgi.py. I tried a symlink 
> instead 
> > of a move, but couldn't make AppFog work in that arrangement 
> > ln -s wsgi.py wsgihandler.py  # This ensures updates to web2py affect 
> your 
> > wsgi.py 
> > gem install af 
> > af login 
> > af push   # This gives you an Amazon East app. I can't figure 
> out 
> > how to use `af` to deploy to a different infrastructure 
> > 
> > I tried creating an app on the Rackspace infrastructure through AppFog's 
> web 
> > admin `af update `, but couldn't get my app to start. It didn't 
> > start automatically, and `af start  --debug` tells me I don't 
> have 
> > the "run" mode available. So no Rackspace for me. 
> > 
> > Once I got my app running on AppFog's Amazon EC2 infrastructure (after a 
> > number of false starts related to not having wsgi.py) I noticed my app 
> ran 
> > very slowly. The front page of my app doesn't really do anything; it 
> could 
> > almost be a static HTML file, yet it was unbearably slow on AppFog. 
> > 
> > I fired up Apache Benchmark and got some very disappointing results. 
> With a 
> > concurrency of 50, run for 30 seconds: 
> > 
> > 1 instance, 128MB RAM: 139 requests completed, mean average of 10.5 
> seconds 
> > to fulfill a request 
> > 1 

Re: [web2py] Re: How to keep database connection alive ?

2012-08-08 Thread Amit
This is also not working giving same error: "ProgrammingError: Cannot
operate on a closed database." :(

Regards,
Amit

On Thu, Aug 9, 2012 at 9:58 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> This definitively would not work...
>
> how about
>
> @sched.interval_schedule(**seconds=15)
> def purge_appliance_tbl():
> yesterday = request.now - datetime.timedelta(days=1)
> db(db.appliance_tbl.created_on < yesterday).delete()
> db.commit()
>
>
> On Wednesday, 8 August 2012 22:24:40 UTC-5, Amit wrote:
>
>> So as i understood, i need again re-establish the db connection before
>> purging the records from the table , like below:
>>
>> @sched.interval_schedule(**seconds=15)
>> def purge_appliance_tbl():
>> yesterday = request.now - datetime.timedelta(days=1)
>> db = DAL('sqlite://storage.sqlite')
>> db(db.appliance_tbl.created_on < yesterday).delete()
>>
>> is it correct? OR do I need to re-define all the tables for local db
>> instance?if no, then how this instance will be able to recognize all tables?
>>
>> Please guide me to resolve this.
>>
>> Thanks,
>> Amit
>>
>> On Wed, Aug 8, 2012 at 10:49 PM, Massimo Di Pierro > > wrote:
>>
>>> yes. it should
>>>
>>> On Wednesday, 8 August 2012 11:36:58 UTC-5, Anthony wrote:

 SQLite ignores the pool_size parameter, though, right? In any case,
 shouldn't a background task run through the scheduler be able to establish
 a db connection, even without pooling?

 Anthony

 On Wednesday, August 8, 2012 10:45:18 AM UTC-4, Massimo Di Pierro wrote:
>
> Normally you would do
>
> db = DAL('sqlite://storage.**sql**ite',pool_size=10)
>
> where 10 is the max number of connections to keep alive and to be
> recycled across multiple requests.
> I am not sure how this interact with scheduler.
>
> On Wednesday, 8 August 2012 01:59:06 UTC-5, Amit wrote:
>>
>>
>> Hi,
>> I am using SQlite database for my web2py application, I have to keep
>> the same db instance which is created at first time request comes to 
>> model
>> db.py
>>
>>
>> db = DAL('sqlite://storage.sqlite')
>>
>> database connection is getting closed once request is completed so I
>> am not able to use the "db" for some background process like purging the
>> records every day so can anyone suggest me the proper way to keep the
>> database connection alive irrespective of request?
>>
>> Scenario:
>> 1. when first time request made , db connection is established, I
>> need to keep this connection alive
>> 2. One background scheduler running continuously to check the records
>> in db and purge it based on some condition.
>>
>> Problem facing:
>> when first request made and get fulfilled, database connection is
>> getting closed because of that scheduler is not able to use the db 
>> instance
>> and start throwing error "Cannot operate on a closed database." every 
>> time
>> when it tries to execute the job.So I need to keep the "db"instance
>> connected to db , how can it be achieved?
>
>  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Re: SQLFORM.grid, checkboxes and mor than one page

2012-08-08 Thread Martin Weissenboeck
Ok, I will try it. Thank you!

2012/8/9 Massimo Di Pierro 

> You need custom JS that when you select a checkbox calls a controller
> action via ajax and registers the id of the row in a session.mylist.
>
>
>
> On Wednesday, 8 August 2012 16:37:54 UTC-5, mweissen wrote:
>>
>> I have a SQLFORM.grid for 100 persons. Checkboxes are activated with a
>> function for the selectable-field.
>> Now this long list breaks down to serveral pages.
>> But a check on page 1 gets lost on changing to another page. So it is not
>> possible to select persons from the whole list.
>> Yes, with the paginate parameter I can create one long list without pages
>> - but that is not the idea of the grid?
>>
>> Any ideas?
>> Regards Martin
>>
>  --

-- 





[web2py] Re: Set a cookie and raise a 403/404

2012-08-08 Thread Massimo Di Pierro
Please open a bug report.

On Wednesday, 8 August 2012 22:46:07 UTC-5, Yarin wrote:
>
> Is it possible to set a cookie on a response that returns a 403/404?
>
> def bad_access():
>  
> # Set a cookie
> response.cookies['SOME_COOKIE'] = datetime.now()
> response.cookies['SOME_COOKIE']['path'] = '/'
> # And then throw a 403:
> raise HTTP(403,"An error.")
>
>
> This code never succeeds in setting the cookie.
>

-- 





Re: [web2py] Re: How to keep database connection alive ?

2012-08-08 Thread Massimo Di Pierro
This definitively would not work...

how about

@sched.interval_schedule(seconds=15)
def purge_appliance_tbl():
yesterday = request.now - datetime.timedelta(days=1)
db(db.appliance_tbl.created_on < yesterday).delete() 
db.commit()


On Wednesday, 8 August 2012 22:24:40 UTC-5, Amit wrote:
>
> So as i understood, i need again re-establish the db connection before 
> purging the records from the table , like below:
>
> @sched.interval_schedule(seconds=15)
> def purge_appliance_tbl():
> yesterday = request.now - datetime.timedelta(days=1)
> db = DAL('sqlite://storage.sqlite')
> db(db.appliance_tbl.created_on < yesterday).delete() 
>
> is it correct? OR do I need to re-define all the tables for local db 
> instance?if no, then how this instance will be able to recognize all tables?
>
> Please guide me to resolve this.
>
> Thanks,
> Amit
>
> On Wed, Aug 8, 2012 at 10:49 PM, Massimo Di Pierro 
> 
> > wrote:
>
>> yes. it should
>>
>> On Wednesday, 8 August 2012 11:36:58 UTC-5, Anthony wrote:
>>>
>>> SQLite ignores the pool_size parameter, though, right? In any case, 
>>> shouldn't a background task run through the scheduler be able to establish 
>>> a db connection, even without pooling?
>>>
>>> Anthony
>>>
>>> On Wednesday, August 8, 2012 10:45:18 AM UTC-4, Massimo Di Pierro wrote:

 Normally you would do

 db = DAL('sqlite://storage.**sqlite',pool_size=10)

 where 10 is the max number of connections to keep alive and to be 
 recycled across multiple requests.
 I am not sure how this interact with scheduler.

 On Wednesday, 8 August 2012 01:59:06 UTC-5, Amit wrote:
>
>
> Hi,
> I am using SQlite database for my web2py application, I have to keep 
> the same db instance which is created at first time request comes to 
> model 
> db.py
>
>
> db = DAL('sqlite://storage.sqlite')
>
> database connection is getting closed once request is completed so I 
> am not able to use the "db" for some background process like purging the 
> records every day so can anyone suggest me the proper way to keep the 
> database connection alive irrespective of request?
>
> Scenario:
> 1. when first time request made , db connection is established, I need 
> to keep this connection alive
> 2. One background scheduler running continuously to check the records 
> in db and purge it based on some condition.
>
> Problem facing:
> when first request made and get fulfilled, database connection is 
> getting closed because of that scheduler is not able to use the db 
> instance 
> and start throwing error "Cannot operate on a closed database." every 
> time 
> when it tries to execute the job.So I need to keep the "db"instance 
> connected to db , how can it be achieved?

  -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: Cookie chaos- please see this example

2012-08-08 Thread Massimo Di Pierro
if we default path = '/' then all apps share cookies and that may be a 
problem.

expiration is also not set. They are Cookies.SimpleCookie() objects. 

On Wednesday, 8 August 2012 22:14:25 UTC-5, Yarin wrote:
>
> Got it- added the path and everything's working now.
>
> I was not aware cookies are path dependent- I thought they were restricted 
> only by domains/sub-domains. Maybe I'm the only one, but my guess would be 
> that a lot of people are operating under that assumption. For that reason 
> my vote would be to either make the default the root path or at the very 
> least to make clear in the documentation what the default behavior is now. 
> I punched the wall a few times this afternoon trying to understand why my 
> cookies wouldn't persist on the same function call from one request to 
> another, and the whole time was barking up the wrong trees.
>
> Also, what's the default expiration value for cookies?
>
> On Wednesday, August 8, 2012 9:35:04 PM UTC-4, Massimo Di Pierro wrote:
>>
>> I can reproduce your behavior. The problem is that when you set 
>>
>>   response.cookies['LAST_FUNCTION'] = request.function
>>
>> you are not setting a path
>>
>>   response.cookies['LAST_FUNCTION']['path']='/myapplication'
>>
>> therefore the browser assumes the scope of the cookie is the URL.
>>
>> web2py cannot set the path (scope) automatically because it does not know 
>> how your application is exposed. For example:
>>
>> response.cookies['LAST_FUNCTION']['path']='/'+request.application
>>
>> would behave differently depending on the routes.
>> I would not be tremendously opposed to changing this default but I am not 
>> convinced there is a better default.
>>
>>
>>
>>
>> On Wednesday, 8 August 2012 18:25:36 UTC-5, Yarin wrote:
>>>
>>> This is a weird issue turned weirder, but I've at least been able to 
>>> reproduce it:
>>>
>>> *Controller:*
>>>
>>> def func_a():
>>>  
>>>  response.cookies['LAST_FUNCTION'] = request.function
>>>  return str(request.cookies)
>>>  
>>> def func_b():
>>>  
>>>  response.cookies['LAST_FUNCTION'] = request.function
>>>  return str(request.cookies)
>>>
>>>
>>> def dump_cookies():
>>>  
>>>  return str(request.cookies)
>>>
>>>
>>>
>>> Make 5 calls in succession:
>>> /func_a
>>> /func_b(LAST_FUNCTION = 'func_a')
>>> /func_a(LAST_FUNCTION = 'func_b')
>>> /func_b(LAST_FUNCTION = 'func_a')
>>> /dump_cookies(LAST_FUNCTION = 'func_b')
>>>
>>> Everything checks out.
>>>
>>> Now clear cookies, and try the calls again, but this time with different 
>>> args for each:
>>> /func_a/1
>>> /func_b/2
>>> /func_a/1(LAST_FUNCTION = 'func_a')
>>> /func_b/2(LAST_FUNCTION = 'func_b')
>>> /dump_cookies-No LAST_FUNCTION cookie-
>>>
>>> In other words, the cookies are no longer being shared across functions!
>>>
>>> Please try this yourself and report back. If anyone can make sense of 
>>> this, I want to hear it...
>>>
>>>

-- 





[web2py] Legacy table without primary key?

2012-08-08 Thread pbreit
Is there any way to handle a legacy table that does not have a primary key?

-- 





[web2py] LinkedIn not working? - Am I importing the wrong library?

2012-08-08 Thread Alec Taylor
Just trying to test out LinkedIn login, but having some trouble.

I've tried placing 
https://github.com/michaelhelmick/linkedin/blob/master/linkedin.py in 
web2py\gluon\contrib\login_methods, but I still was getting the "linkedin 
module not found" error. Same error was received after a `pip install 
linkedin`.

I also tried removing the try/except and replacing it inline with the 
contents of that linkedin.py. That gave me a " No module named 
gluon.contrib.login_methods.linkedin_account" error on page refresh.

I have been following this guide: 
http://web2py.com/books/default/chapter/29/9 

Am I using the wrong linkedin library? Or is there something else I'm doing 
wrong?

Thanks for all suggestions,

Alec Taylor

-- 





[web2py] Re: Foreign Key fields as null?

2012-08-08 Thread Mandar Vaze
I too am getting similar error (am using sqlform.grid, not smartgrid)
I've posted a query here 
: https://groups.google.com/d/msg/web2py/SxTKewH-nS8/G5iT8ycUAKgJ
Waiting for feedback

Thanks,
-Mandar

On Saturday, July 21, 2012 1:17:33 AM UTC+5:30, joe wrote:
>
> That hasn't worked for me.  When I try, I get the error: 'exceptions.KeyError'> 'name'
>
> It points to the smartgrid I made, with this code:  grid = 
> SQLFORM
> .smartgrid(db.dog)
>
> Thanks!
> -Joe Peacock
>
>
> On Tuesday, July 17, 2012 6:22:53 PM UTC-5, Anthony wrote:
>>
>> You should probably make it a reference field. By default, if you don't 
>> specify any "requires", you'll automatically get an IS_IN_DB validator as 
>> well as a "represent" attribute that displays whatever is specifying by the 
>> "format" attribute of the referenced table. However, if you specify your 
>> own validator(s), then you don't get any default "represent" -- so just add 
>> your own explicit represent:
>>
>> db.define_table('dog',
>> Field ('name'), 
>> Field ('owner', db.
>> person, 
>> requires=IS_EMPTY_OR
>> (IS_IN_DB (db, '
>> person.id', '%(name)')),
>>   represent=lambda id, row: db.person(id).name),
>> format = '%(name)s')
>>
>> Anthony
>>
>> On Tuesday, July 17, 2012 10:26:52 AM UTC-4, joe wrote:
>>>
>>> Is there any way to make a field in a form referencing a foreign key 
>>> null, while storing a foreign key as a foreign key, but making dropdowns 
>>> corrospond to the format.  Here is my example:
>>>
>>> Model:
>>>
>>> db = DAL 
>>> ('sqlite://storage.sqlite')
>>>
>>> db.define_table('person',
>>> Field ('name'),
>>> Field ('email'),
>>> format = '%(name)s')
>>> 
>>> db.define_table('dog',
>>> Field ('name'), 
>>> Field ('owner', 
>>> requires = IS_EMPTY_OR 
>>> (IS_IN_DB 
>>> (db,db.person))), #I 
>>> have also tried default=None, and required = False, no difference
>>> format = '%(name)s')
>>>
>>>
>>> Controller:
>>>
>>> *from gluon.tools import Crud
>>> crud = Crud(db)
>>>
>>> def index():
>>> form = SQLFORM(db.person)
>>> if form.process().accepted:
>>> response.flash = 'success'
>>> return dict(form=form)
>>> 
>>> def add_dog():
>>> form = SQLFORM(db.dog)
>>> if form.process().accepted:
>>> response.flash = 'success'
>>> return dict(form=form)
>>>
>>> def view():
>>> grid = SQLFORM.smartgrid(db.dog)
>>> grid2 = crud.select(db.person)
>>> return dict(grid=grid, grid2=grid2)
>>> *
>>>
>>> *
>>> *
>>>
>>> When I have the above code, a foreign key will be stored in the database, 
>>> but all views of that key will be rendered as the numerical value of the 
>>> foreign key, and not the name.  In the table definition, if I just have 
>>> *db.person* instead of requires = *IS_EMPTY_OR*(*IS_IN_DB*(db,db.person)), 
>>> It requires the field.  
>>>
>>>
>>> Are there any workarounds?
>>>
>>> -Joe Peacock
>>>
>>>

-- 





[web2py] Set a cookie and raise a 403/404

2012-08-08 Thread Yarin
Is it possible to set a cookie on a response that returns a 403/404?

def bad_access():
 
# Set a cookie
response.cookies['SOME_COOKIE'] = datetime.now()
response.cookies['SOME_COOKIE']['path'] = '/'
# And then throw a 403:
raise HTTP(403,"An error.")


This code never succeeds in setting the cookie.

-- 





Re: [web2py] combine Autocomplete widget and SELECT_OR_ADD_OPTION widget

2012-08-08 Thread lyn2py
Thanks Richard, I managed to do up one using jquery (different behavior), 
guess I won't be needing this!

On Wednesday, August 8, 2012 9:32:08 PM UTC+8, Richard wrote:
>
> There is no slice... I didn't have time, but I can help you as much as I 
> can here.
>
> Notice that there seems to have a new implementation of the autocomplete 
> widget coming with the new web2py 2.0, so I will have to look at the code 
> and implement again the add option to it.
>
> Richard
>
> On Tue, Aug 7, 2012 at 12:46 AM, lyn2py >wrote:
>
>> Hi Richard, I'm interested in this, how can I get this web2py slice?
>>
>>
>> On Wednesday, May 30, 2012 3:44:20 AM UTC+8, Richard wrote:
>>>
>>> Can't link the app too big (thanks to google 4 meg max :( )...
>>>
>>> Ask me in private I will send you the app directly.
>>>
>>> Richard
>>>
>>> On Tue, May 29, 2012 at 3:40 PM, Richard Vézina 
>>> 
>>> > wrote:
>>>
 Hello,

 Here a demo app, hope it will help for now... It the best I can do now.

  Try to understand it carefully, if you can make works the slice about 
 SelectOrAddOption, you will be able to adapt my **
 AutocompleteWidgetSelectOrAddO**ption to your needs. So follow the 
 slice tutorial carefully and transpose to the need widget. Only the part 
 about *"add" function* that you don't initialize same way, you just 
 pass everything to the widget like this : AutocompleteWidgetSelectOrAddO
 **ption(request, db.table2.table2field1,
 id_field=db.table2.id, limitby=(0,10), min_length=2,
 form_title=T('Add new table2 item'), controller="tables",
 *function="add_table2_item"*, button_text = T('Add new'))

 There is only one error I can't get rid of is that Add Option trigger a 
 not belong field error on update form... I don't have this error in my own 
 app so I should be minor, I will try to find why it not working. I thought 
 that it could be because of similar name between table so I rename form 
 field1 to table1field1 and table2field1, not working neither. Will try to 
 find the origin of the issue.

 NOTE : It base on Autocomplete available in web2py 1.99.4 and it should 
 works (except the error I am talking about) with web2py 1.99.4.

 TODO : Look for change that Manuele did to autocomplete widget and use 
 this version of the widget to merge the SelectOrAddOption.
  
 Richard


 On Tue, May 29, 2012 at 1:19 PM, Richard Vézina 
 
 > wrote:

> Ok, I will work on this to allow possible user to have access to this 
> ressource.
>
> I will clean the code a bit and write a tutorial step by step with the 
> element to adapt to your context.
>
> Give me a couples of hours.
>
> Richard
>
>
> On Tue, May 29, 2012 at 6:44 AM, Johann Spies 
> 
> > wrote:
>
>> On 25 April 2012 23:48, Richard Vézina 
>> 
>> > wrote:
>>
>>  
>>
>>> Hope it works for you Johann.
>>>
>>
>> Unfortunately I did not have any success with this recipe.  I can get 
>> the select_or_add widget working but not this one.
>>
>> Thanks for your trouble anyhow.
>>
>> Regards
>> Johann 
>> -- 
>> Because experiencing your loyal love is better than life itself, 
>> my lips will praise you.  (Psalm 63:3)
>>
>>
>

>>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] Re: How to keep database connection alive ?

2012-08-08 Thread Amit
So as i understood, i need again re-establish the db connection before
purging the records from the table , like below:

@sched.interval_schedule(seconds=15)
def purge_appliance_tbl():
yesterday = request.now - datetime.timedelta(days=1)
db = DAL('sqlite://storage.sqlite')
db(db.appliance_tbl.created_on < yesterday).delete()

is it correct? OR do I need to re-define all the tables for local db
instance?if no, then how this instance will be able to recognize all tables?

Please guide me to resolve this.

Thanks,
Amit

On Wed, Aug 8, 2012 at 10:49 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> yes. it should
>
> On Wednesday, 8 August 2012 11:36:58 UTC-5, Anthony wrote:
>>
>> SQLite ignores the pool_size parameter, though, right? In any case,
>> shouldn't a background task run through the scheduler be able to establish
>> a db connection, even without pooling?
>>
>> Anthony
>>
>> On Wednesday, August 8, 2012 10:45:18 AM UTC-4, Massimo Di Pierro wrote:
>>>
>>> Normally you would do
>>>
>>> db = DAL('sqlite://storage.**sqlite',pool_size=10)
>>>
>>> where 10 is the max number of connections to keep alive and to be
>>> recycled across multiple requests.
>>> I am not sure how this interact with scheduler.
>>>
>>> On Wednesday, 8 August 2012 01:59:06 UTC-5, Amit wrote:


 Hi,
 I am using SQlite database for my web2py application, I have to keep
 the same db instance which is created at first time request comes to model
 db.py


 db = DAL('sqlite://storage.sqlite')

 database connection is getting closed once request is completed so I am
 not able to use the "db" for some background process like purging the
 records every day so can anyone suggest me the proper way to keep the
 database connection alive irrespective of request?

 Scenario:
 1. when first time request made , db connection is established, I need
 to keep this connection alive
 2. One background scheduler running continuously to check the records
 in db and purge it based on some condition.

 Problem facing:
 when first request made and get fulfilled, database connection is
 getting closed because of that scheduler is not able to use the db instance
 and start throwing error "Cannot operate on a closed database." every time
 when it tries to execute the job.So I need to keep the "db"instance
 connected to db , how can it be achieved?
>>>
>>>  --
>
>
>
>

-- 





[web2py] Re: Small bug?

2012-08-08 Thread lyn2py
Thanks Massimo!

On Wednesday, August 8, 2012 10:43:40 PM UTC+8, Massimo Di Pierro wrote:
>
> Fixed in trunk, although I have problems pushing to github this morning.
>
> On Wednesday, 8 August 2012 01:06:09 UTC-5, lyn2py wrote:
>>
>> Correction! 
>>
>> Good news - the form submission works again.
>>> However, the form%20accepted is not resolved, 
>>>
>>
>> The good news is correct and the form%20accepted is resolved.
>> Previously it didn't work because I downloaded a zip instead of cloning 
>> git. 
>> It works after I clone git.
>>  
>>
>>> and also the member welcome at the top became: Logout | | PasswordProfile
>>>
>>
>> This part of the post is still true.
>> I tested this on the new welcome app and the bug in formatting is still 
>> there.
>>
>> On Wednesday, August 8, 2012 1:52:20 PM UTC+8, lyn2py wrote:
>>>
>>> I updated to the latest version of web2py.js
>>>
>>> Good news - the form submission works again.
>>> However, the form%20accepted is not resolved, 
>>> and also the member welcome at the top became: Logout | | PasswordProfile
>>>
>>> On Wednesday, August 8, 2012 11:36:51 AM UTC+8, Anthony wrote:

 Yes. Massimo, I think 
 http://code.google.com/p/web2py/source/detail?r=65caec4dae5f7c971d406beb0eb3b32f471d84a4
  broke 
 Ajax form submission.

 Anthony

 On Tuesday, August 7, 2012 11:20:44 PM UTC-4, lyn2py wrote:
>
> I've discovered a difference between the previous and the new is the 
> form submission.
>
> The old version post has parameters 
> for application/x-www-form-urlencoded.
> The new version post has no parameters. 
> So it seems that the form was not POSTed at all?
>
>
> On Wednesday, August 8, 2012 11:06:53 AM UTC+8, lyn2py wrote:
>>
>> Ok, I found web2py.js. It is in the static folder of the app.
>> I took the new one from welcome app and replaced the one in my app.
>>
>> Now my code wouldn't work (my form was not processed). I'm still 
>> trying to find out why. Any pointers will be helpful. Thanks.
>>
>> On Wednesday, August 8, 2012 9:22:23 AM UTC+8, Anthony wrote:
>>>
>>> I cannot reproduce the problem. Do you have the absolutely latest 
>>> trunk, including the latest web2py.js?
>>>
>>> Anthony
>>>
>>> On Tuesday, August 7, 2012 5:16:06 PM UTC-4, lyn2py wrote:

 My code is simple

 form=SQLFORM(db.category)
 if form.process().accepted:
 response.flash = 'form accepted'
 elif form.errors:
 response.flash = 'form has errors'
 return dict(form=form)

 views is using generic.load to LOAD into a dialog via ajax.

 I'm using the latest trunk.
 

 On Wednesday, August 8, 2012 4:51:56 AM UTC+8, Anthony wrote:
>
> Are you using trunk (if not, can you try it -- including the trunk 
> version of web2py.js)? Can you show your code?
>
> Anthony
>
> On Tuesday, August 7, 2012 4:21:16 PM UTC-4, lyn2py wrote:
>>
>> Spotted a small bug in response.flash:
>>
>> Normally when we submit a form, response.flash will appear "form 
>> accepted"
>> However if it is a form submitted within dialog 
>> box, response.flash will appear "form%20accepted"
>>
>>
>>
>>
>>> On Wednesday, August 8, 2012 11:36:51 AM UTC+8, Anthony wrote:

 Yes. Massimo, I think 
 http://code.google.com/p/web2py/source/detail?r=65caec4dae5f7c971d406beb0eb3b32f471d84a4
  broke 
 Ajax form submission.

 Anthony

 On Tuesday, August 7, 2012 11:20:44 PM UTC-4, lyn2py wrote:
>
> I've discovered a difference between the previous and the new is the 
> form submission.
>
> The old version post has parameters 
> for application/x-www-form-urlencoded.
> The new version post has no parameters. 
> So it seems that the form was not POSTed at all?
>
>
> On Wednesday, August 8, 2012 11:06:53 AM UTC+8, lyn2py wrote:
>>
>> Ok, I found web2py.js. It is in the static folder of the app.
>> I took the new one from welcome app and replaced the one in my app.
>>
>> Now my code wouldn't work (my form was not processed). I'm still 
>> trying to find out why. Any pointers will be helpful. Thanks.
>>
>> On Wednesday, August 8, 2012 9:22:23 AM UTC+8, Anthony wrote:
>>>
>>> I cannot reproduce the problem. Do you have the absolutely latest 
>>> trunk, including the latest web2py.js?
>>>
>>> Anthony
>>>
>>> On Tuesday, August 7, 2012 5:16:06 PM UTC-4, lyn2py wrote:

 My code is simple

 form=SQLFORM(db.category)
 if form.process().accepted:
 response.flash = 'form accepted'
 elif form.errors:
   

[web2py] Re: Cookie chaos- please see this example

2012-08-08 Thread Yarin
Got it- added the path and everything's working now.

I was not aware cookies are path dependent- I thought they were restricted 
only by domains/sub-domains. Maybe I'm the only one, but my guess would be 
that a lot of people are operating under that assumption. For that reason 
my vote would be to either make the default the root path or at the very 
least to make clear in the documentation what the default behavior is now. 
I punched the wall a few times this afternoon trying to understand why my 
cookies wouldn't persist on the same function call from one request to 
another, and the whole time was barking up the wrong trees.

Also, what's the default expiration value for cookies?

On Wednesday, August 8, 2012 9:35:04 PM UTC-4, Massimo Di Pierro wrote:
>
> I can reproduce your behavior. The problem is that when you set 
>
>   response.cookies['LAST_FUNCTION'] = request.function
>
> you are not setting a path
>
>   response.cookies['LAST_FUNCTION']['path']='/myapplication'
>
> therefore the browser assumes the scope of the cookie is the URL.
>
> web2py cannot set the path (scope) automatically because it does not know 
> how your application is exposed. For example:
>
> response.cookies['LAST_FUNCTION']['path']='/'+request.application
>
> would behave differently depending on the routes.
> I would not be tremendously opposed to changing this default but I am not 
> convinced there is a better default.
>
>
>
>
> On Wednesday, 8 August 2012 18:25:36 UTC-5, Yarin wrote:
>>
>> This is a weird issue turned weirder, but I've at least been able to 
>> reproduce it:
>>
>> *Controller:*
>>
>> def func_a():
>>  
>>  response.cookies['LAST_FUNCTION'] = request.function
>>  return str(request.cookies)
>>  
>> def func_b():
>>  
>>  response.cookies['LAST_FUNCTION'] = request.function
>>  return str(request.cookies)
>>
>>
>> def dump_cookies():
>>  
>>  return str(request.cookies)
>>
>>
>>
>> Make 5 calls in succession:
>> /func_a
>> /func_b(LAST_FUNCTION = 'func_a')
>> /func_a(LAST_FUNCTION = 'func_b')
>> /func_b(LAST_FUNCTION = 'func_a')
>> /dump_cookies(LAST_FUNCTION = 'func_b')
>>
>> Everything checks out.
>>
>> Now clear cookies, and try the calls again, but this time with different 
>> args for each:
>> /func_a/1
>> /func_b/2
>> /func_a/1(LAST_FUNCTION = 'func_a')
>> /func_b/2(LAST_FUNCTION = 'func_b')
>> /dump_cookies-No LAST_FUNCTION cookie-
>>
>> In other words, the cookies are no longer being shared across functions!
>>
>> Please try this yourself and report back. If anyone can make sense of 
>> this, I want to hear it...
>>
>>

-- 





[web2py] Re: Initialize one-time configuration data in DB

2012-08-08 Thread Massimo Di Pierro
If they are contants I suggest you write them in a python file and import 
them.

If they must be in the database, use a script to import them and run it 
once 

python web2py.py -S yourapp -M -N -R yourscript.py

On Wednesday, 8 August 2012 20:30:10 UTC-5, mrtn wrote:
>
>
> Hi,
>
> I need to have a few rows of data in the database for configuration 
> purposes. I just need to set them once and forget about them, in some sense 
> that they are like 'constants'.
>
> What is the best approach to do this with web2py? Or should I just do it 
> completely separately from web2py, e.g. insert them using SQL command line 
> before I start the app?
>
>  
>

-- 





[web2py] Problems with restful + PUT

2012-08-08 Thread Tito Garrido
Hi folks,

*I have a simple table:*

*db.define_table('estadio',
Field('cod_estadio','id'),
Field('nome_estadio'),
Field('cidade'),migrate=False) *

*A simple entry:*

*estadio.cod_estadio**estadio.nome_estadio* *estadio.cidade**1**A Definir**A
Definir*
and using Bruno's example in web2pyslice:


   1. @request.restful()
   2. def api():
   3. response.view = 'generic.'+request.extension
   4. def GET(*args,**vars):
   5. patterns = 'auto'
   6. parser = db.parse_as_rest(patterns,args,vars)
   7. if parser.status == 200:
   8. return dict(content=parser.response)
   9. else:
   10. raise HTTP(parser.status,parser.error)
   11. def POST(table_name,**vars):
   12. return db[table_name].validate_and_insert(**vars)
   13. def PUT(table_name,record_id,**vars):
   14. return db(db[table_name]._id==record_id).update(**vars)
   15. def DELETE(table_name,record_id):
   16. return db(db[table_name]._id==record_id).delete()
   17. return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)


*but when I try to:*
*
curl -i -H "Accept: application/json" -X PUT -d "nome_estadio='teste"
http://127.0.0.1:8080/ws/default/api/estadio/cod-estadio/1.json*

*it returns:*

HTTP/1.1 400 BAD REQUEST
Server: nginx
Date: Thu, 09 Aug 2012 01:41:44 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Set-Cookie: session_id_ws=xx-65e0b712-7d93-4b21-a553-d06ce06af2a2;
Path=/
Content-Length: 540

invalid arguments

*What am I missing here?

Thanks in advance!*

-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___

-- 





Re: [web2py] Re: How do larger teams develop with Web2py?

2012-08-08 Thread Massimo Di Pierro
LOL

On Wednesday, 8 August 2012 20:17:33 UTC-5, rochacbruno wrote:
>
>
> That is how I am used to work: http://programming-motherfucker.com/ 

-- 





[web2py] Re: web2py not reading Amazon SNS Subscription Confirmation requests?

2012-08-08 Thread Massimo Di Pierro
There is nothing in request.args because I assume the URL is called without 
args.
There is nothing in request.vars because the request contains no HTTP 
variables. It is an HTTP post with a json data in the request body. HTTP 
does not know anything about json. Web2py has no clue or way to guess the 
request body contains json. It may as well be gibberish. Whoever created 
the protocol should have used a mime multipart content (which is how forms 
are submitted).

Anyway, you can still email yourself:

   request.env # the headers

and 

   request.body.read()  # the content of the body

and you will get what you want.




On Wednesday, 8 August 2012 19:55:49 UTC-5, Osman Masood wrote:
>
> Hi all,
> I'm trying to confirm an Amazon SNS subscription with a web2py controller 
> action. The Amazon SNS subscription format is described 
> here
>  (through 
> probably not necessary to understand this problem.)
>
> My controller action (default/amazon_sns_endpoint) basically just emails 
> request.vars and request.args to myself. It receives a POST request from 
> the subscription service. However, for some reason, it doesn't seem to be 
> able to process the POST request, i.e. request.vars and request.args are 
> always {} and []. (I do, however, get the email.) 
>
> Maybe web2py messes up when it handles some of the headers? An example 
> POST request looks like this:
>
> POST / HTTP/1.1
> x-amz-sns-message-type: SubscriptionConfirmation
> x-amz-sns-message-id: 165545c9-2a5c-472c-8df2-7ff2be2b3b1b
> x-amz-sns-topic-arn: arn:aws:sns:us-east-1:123456789012:MyTopic
> x-amz-sns-subscription-arn: 
> arn:aws:sns:us-east-1:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55
> Content-Length: 1336
> Content-Type: text/plain; charset=UTF-8
> Host: example.com
> Connection: Keep-Alive
> User-Agent: Amazon Simple Notification Service Agent
>
> {
>   "Type" : "SubscriptionConfirmation",
>   "MessageId" : "165545c9-2a5c-472c-8df2-7ff2be2b3b1b",
>   "Token" : 
> "2336412f37fb687f5d51e6e241d09c805a5a57b30d712f794cc5f6a988666d92768dd60a747ba6f3beb71854e285d6ad02428b09ceece29417f1f02d609c582afbacc99c583a916b9981dd2728f4ae6fdb82efd087cc3b7849e05798d2d2785c03b0879594eeac82c01f235d0e717736",
>   "TopicArn" : "arn:aws:sns:us-east-1:123456789012:MyTopic",
>   "Message" : "You have chosen to subscribe to the topic 
> arn:aws:sns:us-east-1:123456789012:MyTopic.\nTo confirm the subscription, 
> visit the SubscribeURL included in this message.",
>   "SubscribeURL" : 
> "https://sns.us-east-1.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-east-1:123456789012:MyTopic&Token=2336412f37fb687f5d51e6e241d09c805a5a57b30d712f794cc5f6a988666d92768dd60a747ba6f3beb71854e285d6ad02428b09ceece29417f1f02d609c582afbacc99c583a916b9981dd2728f4ae6fdb82efd087cc3b7849e05798d2d2785c03b0879594eeac82c01f235d0e717736";,
>   "Timestamp" : "2012-04-26T20:45:04.751Z",
>   "SignatureVersion" : "1",
>   "Signature" : 
> "skvXQIEpH+DcEwjAPg8O9mY8dReBSwksfg2S7WKQcikcNKWLQjwu6A4VbeS0QHVCkhRS7fUQvi2egU3N858fiTDN6bkkOxYDVrY0Ad8L10Hs3zH81mtnPk5uvvolIC1CXGu43obcgFxeL3khZl8IKvO61GWB6jI9b5+gLPoBc1Q=",
>   "SigningCertURL" : 
> "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem";
>   }
>
>

-- 





[web2py] Re: Cookie chaos- please see this example

2012-08-08 Thread Massimo Di Pierro
I can reproduce your behavior. The problem is that when you set 

  response.cookies['LAST_FUNCTION'] = request.function

you are not setting a path

  response.cookies['LAST_FUNCTION']['path']='/myapplication'

therefore the browser assumes the scope of the cookie is the URL.

web2py cannot set the path (scope) automatically because it does not know 
how your application is exposed. For example:

response.cookies['LAST_FUNCTION']['path']='/'+request.application

would behave differently depending on the routes.
I would not be tremendously opposed to changing this default but I am not 
convinced there is a better default.




On Wednesday, 8 August 2012 18:25:36 UTC-5, Yarin wrote:
>
> This is a weird issue turned weirder, but I've at least been able to 
> reproduce it:
>
> *Controller:*
>
> def func_a():
>  
>  response.cookies['LAST_FUNCTION'] = request.function
>  return str(request.cookies)
>  
> def func_b():
>  
>  response.cookies['LAST_FUNCTION'] = request.function
>  return str(request.cookies)
>
>
> def dump_cookies():
>  
>  return str(request.cookies)
>
>
>
> Make 5 calls in succession:
> /func_a
> /func_b(LAST_FUNCTION = 'func_a')
> /func_a(LAST_FUNCTION = 'func_b')
> /func_b(LAST_FUNCTION = 'func_a')
> /dump_cookies(LAST_FUNCTION = 'func_b')
>
> Everything checks out.
>
> Now clear cookies, and try the calls again, but this time with different 
> args for each:
> /func_a/1
> /func_b/2
> /func_a/1(LAST_FUNCTION = 'func_a')
> /func_b/2(LAST_FUNCTION = 'func_b')
> /dump_cookies-No LAST_FUNCTION cookie-
>
> In other words, the cookies are no longer being shared across functions!
>
> Please try this yourself and report back. If anyone can make sense of 
> this, I want to hear it...
>
>

-- 





[web2py] Initialize one-time configuration data in DB

2012-08-08 Thread mrtn

Hi,

I need to have a few rows of data in the database for configuration 
purposes. I just need to set them once and forget about them, in some sense 
that they are like 'constants'.

What is the best approach to do this with web2py? Or should I just do it 
completely separately from web2py, e.g. insert them using SQL command line 
before I start the app?

 

-- 





Re: [web2py] Re: How do larger teams develop with Web2py?

2012-08-08 Thread Bruno Rocha
That is how I am used to work: http://programming-motherfucker.com/

-- 





[web2py] Re: How do larger teams develop with Web2py?

2012-08-08 Thread Osman Masood
I'm a back-end developer and work in parallel with a front-end developer 
and designer. Because of the MVC architecture (separate models, views, and 
controllers), we are able to work in parallel just fine.
And you're absolutely right that people at all levels can benefit from the 
rapid adjustment of requirements. web2py comes with a lot of functionality 
(like RESTful API calls) out-of-the-box, as well as other very useful tools 
such as a scheduler and markmin processing. It makes web2py apps have 
significantly less lines of code than would be required in other web 
frameworks. With less lines of code, it has been easier to develop, debug 
and maintain.

I've used perl CGI, PHP, Ruby on Rails (1.5 years of experience) , and have 
been using web2py for about 3 months now. It was a bit quirky to learn in 
the beginning, and even now I sometimes have to look through the source 
code to know what's going on, but even that's not bad because it's Python 
and there's not many lines of code anyway. I wish there was a very good 
guide for web2py (like there is for RoR at railstutorial.org), but the 
current one is sufficient, as long as you go through all the chapters and 
don't skip around. 

On Thursday, August 9, 2012 4:39:20 AM UTC+8, Luc Chase wrote:
>
> What particular constraints and advantages does using web2py tend to bring 
> for larger project development teams as opposed to those working solo or in 
> very small teams?
>
> I assume for example these roles benefit from rapid feedback and ability 
> to adjust requirements more easily?
>
>- Project stakeholder (client or business owner)
>- Project manager
>- Producer
>- Editor/copywriter
>- Information architect
>- Business-systems analyst
>- Tech lead
>- Database administrator
>- Quality assurance engineer
>
> But are these roles less-able or more-able to work in parallel?
>
>- Graphic designer
>- HTML developer
>- Developer
>
>
On Thursday, August 9, 2012 4:39:20 AM UTC+8, Luc Chase wrote:
>
> What particular constraints and advantages does using web2py tend to bring 
> for larger project development teams as opposed to those working solo or in 
> very small teams?
>
> I assume for example these roles benefit from rapid feedback and ability 
> to adjust requirements more easily?
>
>- Project stakeholder (client or business owner)
>- Project manager
>- Producer
>- Editor/copywriter
>- Information architect
>- Business-systems analyst
>- Tech lead
>- Database administrator
>- Quality assurance engineer
>
> But are these roles less-able or more-able to work in parallel?
>
>- Graphic designer
>- HTML developer
>- Developer
>
>

-- 





Re: [web2py] How do larger teams develop with Web2py?

2012-08-08 Thread vinicius...@gmail.com

It's not a Web2py question. It's a team management point.

As far as Web2py work with MVC (Django, Rails, etc. as well), all pros 
and cons apply here, too.


It's a matter of your workload approach. Maybe some reading in scrum or 
other management technique may help you.


--
Vinicius Assef


On 08/08/2012 05:39 PM, Luc Chase wrote:

What particular constraints and advantages does using web2py tend to
bring for larger project development teams as opposed to those working
solo or in very small teams?

I assume for example these roles benefit from rapid feedback and ability
to adjust requirements more easily?

  * Project stakeholder (client or business owner)
  * Project manager
  * Producer
  * Editor/copywriter
  * Information architect
  * Tech lead
  * Database administrator
  * Quality assurance engineer

But are these roles less-able or more-able to work in parallel?

  * Graphic designer
  * HTML developer
  * Developer

--





--





[web2py] web2py not reading Amazon SNS Subscription Confirmation requests?

2012-08-08 Thread Osman Masood
Hi all,
I'm trying to confirm an Amazon SNS subscription with a web2py controller 
action. The Amazon SNS subscription format is described 
here
 (through 
probably not necessary to understand this problem.)

My controller action (default/amazon_sns_endpoint) basically just emails 
request.vars and request.args to myself. It receives a POST request from 
the subscription service. However, for some reason, it doesn't seem to be 
able to process the POST request, i.e. request.vars and request.args are 
always {} and []. (I do, however, get the email.) 

Maybe web2py messes up when it handles some of the headers? An example POST 
request looks like this:

POST / HTTP/1.1
x-amz-sns-message-type: SubscriptionConfirmation
x-amz-sns-message-id: 165545c9-2a5c-472c-8df2-7ff2be2b3b1b
x-amz-sns-topic-arn: arn:aws:sns:us-east-1:123456789012:MyTopic
x-amz-sns-subscription-arn: 
arn:aws:sns:us-east-1:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55
Content-Length: 1336
Content-Type: text/plain; charset=UTF-8
Host: example.com
Connection: Keep-Alive
User-Agent: Amazon Simple Notification Service Agent

{
  "Type" : "SubscriptionConfirmation",
  "MessageId" : "165545c9-2a5c-472c-8df2-7ff2be2b3b1b",
  "Token" : 
"2336412f37fb687f5d51e6e241d09c805a5a57b30d712f794cc5f6a988666d92768dd60a747ba6f3beb71854e285d6ad02428b09ceece29417f1f02d609c582afbacc99c583a916b9981dd2728f4ae6fdb82efd087cc3b7849e05798d2d2785c03b0879594eeac82c01f235d0e717736",
  "TopicArn" : "arn:aws:sns:us-east-1:123456789012:MyTopic",
  "Message" : "You have chosen to subscribe to the topic 
arn:aws:sns:us-east-1:123456789012:MyTopic.\nTo confirm the subscription, visit 
the SubscribeURL included in this message.",
  "SubscribeURL" : 
"https://sns.us-east-1.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-east-1:123456789012:MyTopic&Token=2336412f37fb687f5d51e6e241d09c805a5a57b30d712f794cc5f6a988666d92768dd60a747ba6f3beb71854e285d6ad02428b09ceece29417f1f02d609c582afbacc99c583a916b9981dd2728f4ae6fdb82efd087cc3b7849e05798d2d2785c03b0879594eeac82c01f235d0e717736";,
  "Timestamp" : "2012-04-26T20:45:04.751Z",
  "SignatureVersion" : "1",
  "Signature" : 
"skvXQIEpH+DcEwjAPg8O9mY8dReBSwksfg2S7WKQcikcNKWLQjwu6A4VbeS0QHVCkhRS7fUQvi2egU3N858fiTDN6bkkOxYDVrY0Ad8L10Hs3zH81mtnPk5uvvolIC1CXGu43obcgFxeL3khZl8IKvO61GWB6jI9b5+gLPoBc1Q=",
  "SigningCertURL" : 
"https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem";
  }

-- 





[web2py] KeyError : 'name' when inserting/updating via sqlform.grid

2012-08-08 Thread Mandar Vaze / मंदार वझे
I have posted this query sometime ago via google-group's web interface -
but it did not appear in the list - may be it is lost or held in moderation
queue (This is my first post) So I am sending this again via normal gmail
interface.
If this is duplicate - please ignore.



I'm using web2py version : Version 2.0.0 (2012-07-26 06:06:10) dev

I have tables defined as follows :

name = db.Table(db, 'name',

Field('name', 'string', length=128, notnull=True, unique=True))

name_desc = db.Table(db, 'base',
name,
Field('description', 'text', default=''))

db.define_table('mother',
name_desc,
format='%(name)s')
db.define_table('father',
name_desc,
format='%(name)s')
db.define_table('child',

name_desc,

Field('mother', db.mother),

Field('father', db.father),

format='%(name)s')

*I am able to successfully insert data in "mother" table via script (e.g.
db.mother.insert(name="Alice"))*

But when I use appadmin to insert new record into mother table, I get the
following error :
I have a sqlform.grid somewhere in the app, I get same error there too ( I
think appadmin also uses sqlform.grid internally)


Traceback (most recent call last):
  File "/home/mandar/web2py/gluon/restricted.py", line 205, in restricted
exec ccode in environment
  File "/home/mandar/web2py/applications/test1/controllers/appadmin.py",
line 432, in 
  File "/home/mandar/web2py/gluon/globals.py", line 182, in 
self._caller = lambda f: f()
  File "/home/mandar/web2py/applications/test1/controllers/appadmin.py",
line 127, in insert
if form.accepts(request.vars, session):
  File "/home/mandar/web2py/gluon/sqlhtml.py", line 1146, in accepts
hideerror=hideerror,
  File "/home/mandar/web2py/gluon/html.py", line 1870, in accepts
status = self._traverse(status,hideerror)
  File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/home/mandar/web2py/gluon/html.py", line 800, in _traverse
newstatus = self._validate()
  File "/home/mandar/web2py/gluon/html.py", line 1625, in _validate
(value, errors) = validator(value)
  File "/home/mandar/web2py/gluon/validators.py", line 554, in __call__
table = self.dbset.db[tablename]
  File "/home/mandar/web2py/gluon/dal.py", line 6877, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: 'name'

Similarly, after populating mother/father and child tables via script when
I try to update "child" record - In the dropdown I see mother's names
instead of ID (as expected) but when I select different "mother" and submit
I get same error (traceback may be slightly different - but same
KeyError:'name' )

What is wrong with the table definitions ?

Thanks,
-Mandar

P.S: This may be similar to
https://groups.google.com/d/msg/web2py/XR4T92l2rJ4/dtTRnO0e7dcJ

-- 





[web2py] Cookie chaos- please see this example

2012-08-08 Thread Yarin
This is a weird issue turned weirder, but I've at least been able to 
reproduce it:

*Controller:*

def func_a():
 
 response.cookies['LAST_FUNCTION'] = request.function
 return str(request.cookies)
 
def func_b():
 
 response.cookies['LAST_FUNCTION'] = request.function
 return str(request.cookies)


def dump_cookies():
 
 return str(request.cookies)



Make 5 calls in succession:
/func_a
/func_b(LAST_FUNCTION = 'func_a')
/func_a(LAST_FUNCTION = 'func_b')
/func_b(LAST_FUNCTION = 'func_a')
/dump_cookies(LAST_FUNCTION = 'func_b')

Everything checks out.

Now clear cookies, and try the calls again, but this time with different 
args for each:
/func_a/1
/func_b/2
/func_a/1(LAST_FUNCTION = 'func_a')
/func_b/2(LAST_FUNCTION = 'func_b')
/dump_cookies-No LAST_FUNCTION cookie-

In other words, the cookies are no longer being shared across functions!

Please try this yourself and report back. If anyone can make sense of this, 
I want to hear it...

-- 





Re: [web2py] Re: GAE Cloud SQL local dev server problem

2012-08-08 Thread Alexei Vinidiktov
Ok. I've managed to connect to MySQL from GAE local dev server on Windows
if I change line 3845 in dal.py to this:

self.folder = ""

instead of (self.folder = folder or
'$HOME/'+thread.folder.split('/applications/',1)[1])

I don't know if it breaks anything though.

On Thu, Aug 9, 2012 at 6:03 AM, Alexei Vinidiktov <
alexei.vinidik...@gmail.com> wrote:

> The problem is still not resolved in trunk.
>
>
> On Mon, Aug 6, 2012 at 12:56 PM, Alexei Vinidiktov <
> alexei.vinidik...@gmail.com> wrote:
>
>> Here it is: db = DAL('google:sql://vocabilisproject:vocabilis/vocabilis')
>>
>> I pass the password and the user name via App Launcher parameters as
>> suggested in the GAE SDK docs: --mysql_user=root --mysql_password=xx
>> --mysql_host=localhost --mysql_port=3306
>>
>>
>> On Mon, Aug 6, 2012 at 7:59 AM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> Can you show your complete connection string (masking any password of
>>> course)?
>>>
>>>
>>> On Saturday, 4 August 2012 02:11:30 UTC-5, Alexei Vinidiktov wrote:



 On Sat, Aug 4, 2012 at 1:56 PM, Alexei Vinidiktov <
 alexei.vinidik...@gmail.com> wrote:

> Hello,
>
> I'm need hep figuring out how to set up a local GAE development server
> with MySQL.
>
> MySQL connection parameters are specified via App Launcher application
> settings: --mysql_user=root --mysql_password=xx --mysql_host=localhost
> --mysql_port=3306
>
> When I launch my web2py app with GAE Launcher on my local Windows
> box I get this erorr message:
>
> 
> ERROR2012-08-04 06:28:43,515 dal.py:5962] DEBUG: connect attempt
> 0, connection error:
> Traceback (most recent call last):
>   File 
> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
> line 5955, in __init__
> self._adapter = ADAPTERS[self._dbname](*args)
>   File 
> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
> line 3310, in __init__
> self.folder = folder or '$HOME/'+thread.folder.split('**
> /applications/',1)[1]
> IndexError: list index out of range
> #
>
> What does the following line do?
>
> self.folder = folder or '$HOME/'+thread.folder.split('**
> /applications/',1)[1]
>
> If I comment out "or 
> '$HOME/'+thread.folder.split('**/applications/',1)[1]"
> in DAL.py and relaunch the dev server, the application appears to be able
> to connect to MySQL but then I get a different error message:
>
> 
> INFO 2012-08-04 06:42:35,142 rdbms_mysqldb.py:102] Connecting to
> MySQL with kwargs {'passwd': 'xx', 'unix_socket': '', 'host':
> 'localhost', 'port': 3306, 'user': 'root'}
> ERROR2012-08-04 06:42:35,153 warnings.py:29]
> C:\Users\alexei\Dev\web2py\voc**abilis.net 
> \gluon\dal.py:1386:
> Warning: Can't create database 'vocabilis'; database exists
>   ret = self.cursor.execute(*a, **b)
>
> ERROR2012-08-04 06:42:35,575 restricted.py:155] Traceback (most
> recent call last):
>   File 
> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\main.py",
> line 510, in wsgibase
> session._try_store_in_db(**request, response)
>   File 
> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\globals.py",
> line 561, in _try_store_in_db
> record_id = table.insert(**dd)
>   File 
> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
> line 6829, in insert
> return self._db._adapter.insert(self,**self._listify(fields))
>   File 
> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
> line 928, in insert
> raise e
> ProgrammingError: (1146, "Table 'vocabilis.web2py_session_**vocabilis'
> doesn't exist")
> #
>
> The vocabilis database does exist. It was created earlier when I
> connected to MySQL from a non GAE environment.
>
> If I specify a different non-existent database in the connection
> string, then after relaunching the application vith the GAE Launcher I get
> this error message:
>
> ###
> INFO 2012-08-04 06:44:45,415 rdbms_mysqldb.py:102] Connecting to
> MySQL with kwargs {'passwd': 'xx', 'unix_socket': '', 'host':
> 'localhost', 'port': 3306, 'user': 'root'}
> ERROR2012-08-04 06:44:45,828 restricted.py:155] Traceback (most
> recent call last):
>   File 
> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\main.py",
> line 510, in wsgibase
> session._try_store_in_db(**request, response)
>   File 
> "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\globals.py",
> line 561, in _try_store_in_db
> record_id = table.

[web2py] Re: Routing problem

2012-08-08 Thread Paulo Junqueira da Costa
Hi Jonathan,

It is working now as I restarted apache.

Many thank´s for your response.


On Wednesday, August 8, 2012 6:13:08 PM UTC-3, Paulo Junqueira da Costa 
wrote:
>
> I just uploaded my first app do production under apache and following the 
> manual, I wrote a routes.py as follows:
>
> routers = dict(
>   BASE  = dict(
>   default_application = 'vendasexpress',
>   default_controller = 'default',
>   default_function = 'index',
>   domains = {
>   'vendasexpress.com.br': 'vendasexpress',
>   'www.vendasexpress.com.br': 'vendasexpress',
>   'vendasexpress.rt1.webfactional.com': 'vendasexpress',
>   'admin.rt1.webfactional.com': 'admin',
>   }
>   ),
> )
>
> But when I try vendasexpress.com.br or www.vendasexpress.com.br it point 
> me to http://vendasexpress.com.br/welcome/default/index.
>
> If I click on register link, it goes to 
> http://vendasexpress.com.br/user/register and works! Some links are 
> working and some others not. I´m pretty confused on how the routing are 
> going and how to correct it.
>
> The admin site (I created an https domais for it), works only if I go to 
> https://admin.rt1.webfactional.com/admin/default/site.
>
> That´s our first web2py app in prod and we are in a hurry to finish it, so 
> any help will be appreciated.
>
> Thanks in advance.
>
>

-- 





[web2py] Re: Setting cookies in models?

2012-08-08 Thread Yarin
Anthony, Rocha- thanks but this was a completely different problem- nothing 
to do w decorators/models- Im making another post to explain...

On Wednesday, August 8, 2012 4:26:00 PM UTC-4, Yarin wrote:
>
> I need to set a cookie on every request, so I tried setting it in the 
> model, but it never works. Setting it in controllers is no problem. I 
> couldn't find any documentation on this- is this behavior expected?
>
> If so, is there a way to ensure a cookie gets set on every request, short 
> of setting it in each controller file?
>
> Works in controllers, not models:
> response.cookies['my_cookie'] = 'something'
>
>
>

-- 





Re: [web2py] Re: GAE Cloud SQL local dev server problem

2012-08-08 Thread Alexei Vinidiktov
The problem is still not resolved in trunk.

On Mon, Aug 6, 2012 at 12:56 PM, Alexei Vinidiktov <
alexei.vinidik...@gmail.com> wrote:

> Here it is: db = DAL('google:sql://vocabilisproject:vocabilis/vocabilis')
>
> I pass the password and the user name via App Launcher parameters as
> suggested in the GAE SDK docs: --mysql_user=root --mysql_password=xx
> --mysql_host=localhost --mysql_port=3306
>
>
> On Mon, Aug 6, 2012 at 7:59 AM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Can you show your complete connection string (masking any password of
>> course)?
>>
>>
>> On Saturday, 4 August 2012 02:11:30 UTC-5, Alexei Vinidiktov wrote:
>>>
>>>
>>>
>>> On Sat, Aug 4, 2012 at 1:56 PM, Alexei Vinidiktov <
>>> alexei.vinidik...@gmail.com> wrote:
>>>
 Hello,

 I'm need hep figuring out how to set up a local GAE development server
 with MySQL.

 MySQL connection parameters are specified via App Launcher application
 settings: --mysql_user=root --mysql_password=xx --mysql_host=localhost
 --mysql_port=3306

 When I launch my web2py app with GAE Launcher on my local Windows box I
 get this erorr message:

 
 ERROR2012-08-04 06:28:43,515 dal.py:5962] DEBUG: connect attempt 0,
 connection error:
 Traceback (most recent call last):
   File 
 "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
 line 5955, in __init__
 self._adapter = ADAPTERS[self._dbname](*args)
   File 
 "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
 line 3310, in __init__
 self.folder = folder or '$HOME/'+thread.folder.split('**
 /applications/',1)[1]
 IndexError: list index out of range
 #

 What does the following line do?

 self.folder = folder or '$HOME/'+thread.folder.split('**
 /applications/',1)[1]

 If I comment out "or '$HOME/'+thread.folder.split('**/applications/',1)[1]"
 in DAL.py and relaunch the dev server, the application appears to be able
 to connect to MySQL but then I get a different error message:

 
 INFO 2012-08-04 06:42:35,142 rdbms_mysqldb.py:102] Connecting to
 MySQL with kwargs {'passwd': 'xx', 'unix_socket': '', 'host':
 'localhost', 'port': 3306, 'user': 'root'}
 ERROR2012-08-04 06:42:35,153 warnings.py:29]
 C:\Users\alexei\Dev\web2py\voc**abilis.net 
 \gluon\dal.py:1386:
 Warning: Can't create database 'vocabilis'; database exists
   ret = self.cursor.execute(*a, **b)

 ERROR2012-08-04 06:42:35,575 restricted.py:155] Traceback (most
 recent call last):
   File 
 "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\main.py",
 line 510, in wsgibase
 session._try_store_in_db(**request, response)
   File 
 "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\globals.py",
 line 561, in _try_store_in_db
 record_id = table.insert(**dd)
   File 
 "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
 line 6829, in insert
 return self._db._adapter.insert(self,**self._listify(fields))
   File 
 "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
 line 928, in insert
 raise e
 ProgrammingError: (1146, "Table 'vocabilis.web2py_session_**vocabilis'
 doesn't exist")
 #

 The vocabilis database does exist. It was created earlier when I
 connected to MySQL from a non GAE environment.

 If I specify a different non-existent database in the connection
 string, then after relaunching the application vith the GAE Launcher I get
 this error message:

 ###
 INFO 2012-08-04 06:44:45,415 rdbms_mysqldb.py:102] Connecting to
 MySQL with kwargs {'passwd': 'xx', 'unix_socket': '', 'host':
 'localhost', 'port': 3306, 'user': 'root'}
 ERROR2012-08-04 06:44:45,828 restricted.py:155] Traceback (most
 recent call last):
   File 
 "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\main.py",
 line 510, in wsgibase
 session._try_store_in_db(**request, response)
   File 
 "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\globals.py",
 line 561, in _try_store_in_db
 record_id = table.insert(**dd)
   File 
 "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
 line 6829, in insert
 return self._db._adapter.insert(self,**self._listify(fields))
   File 
 "C:\Users\alexei\Dev\web2py\vo**cabilis.net\gluon\dal.py",
 line 928, in insert
 raise e
 ProgrammingError: (1146, "Table 'vocabilis3.web2py_session_**vocabilis'
 doesn't exist")
 ###

 So the applica

[web2py] Re: SQLFORM.grid, checkboxes and mor than one page

2012-08-08 Thread Massimo Di Pierro
You need custom JS that when you select a checkbox calls a controller 
action via ajax and registers the id of the row in a session.mylist.



On Wednesday, 8 August 2012 16:37:54 UTC-5, mweissen wrote:
>
> I have a SQLFORM.grid for 100 persons. Checkboxes are activated with a 
> function for the selectable-field.
> Now this long list breaks down to serveral pages.
> But a check on page 1 gets lost on changing to another page. So it is not 
> possible to select persons from the whole list.
> Yes, with the paginate parameter I can create one long list without pages 
> - but that is not the idea of the grid?
>
> Any ideas?
> Regards Martin 
>

-- 





Re: [web2py] Re: Setting cookies in models?

2012-08-08 Thread Yarin

*model:*

def tracked(fn):
 
def wrapped(*args, **kwargs):
 
response.cookies['TRACKED'] = request.args[0]
logger.debug('TRACKED = ' + str(request.args[0])) # This WILL log
 
return fn(*args, **kwargs)
 
return wrapped


*controller:*

@tracked
def test_cookies():
 
return str(request.cookies)









On Wednesday, August 8, 2012 6:13:34 PM UTC-4, Anthony wrote:
>
> Probably need to see some code...
>
> On Wednesday, August 8, 2012 6:07:08 PM UTC-4, Yarin wrote:
>>
>> Guys, this problem has evolved- the issue is not models per-se- I was 
>> able to set cookies in my models in a test app, and I was able to set them 
>> in a decorator as well. I'm even able to get the cookies to write when I 
>> call the specific decorator in question from a test function. All these 
>> things work, yet when i run my application through the normal paces, the 
>> cookies won't get set in that same decorator. I'm absolutely at wits end- 
>> how could that happen? 
>>
>> Rocha- You mentioned lazy cookie creation, etc- can you please explain 
>> further?
>>
>> On Wednesday, August 8, 2012 5:24:24 PM UTC-4, rochacbruno wrote:
>>>
>>> if he is setting the cookie inside a decorator function (inner-function) 
>>> maybe it gets defined on the start of the request.
>>>
>>> when the decorated function gets passed to the decorator inner-function, 
>>> I guess the cookie will be already setted. (but we need to take a look at 
>>> the code to figure out the scope)
>>>
>>> He needs to make the cookie creation Lazy, maybe put this in a lambda or 
>>> use current.
>>>
>>> It is better to share the important part of your decorator functions
>>>
>>

-- 





Re: [web2py] Re: Setting cookies in models?

2012-08-08 Thread Anthony
Probably need to see some code...

On Wednesday, August 8, 2012 6:07:08 PM UTC-4, Yarin wrote:
>
> Guys, this problem has evolved- the issue is not models per-se- I was able 
> to set cookies in my models in a test app, and I was able to set them in a 
> decorator as well. I'm even able to get the cookies to write when I call 
> the specific decorator in question from a test function. All these things 
> work, yet when i run my application through the normal paces, the cookies 
> won't get set in that same decorator. I'm absolutely at wits end- how could 
> that happen? 
>
> Rocha- You mentioned lazy cookie creation, etc- can you please explain 
> further?
>
> On Wednesday, August 8, 2012 5:24:24 PM UTC-4, rochacbruno wrote:
>>
>> if he is setting the cookie inside a decorator function (inner-function) 
>> maybe it gets defined on the start of the request.
>>
>> when the decorated function gets passed to the decorator inner-function, 
>> I guess the cookie will be already setted. (but we need to take a look at 
>> the code to figure out the scope)
>>
>> He needs to make the cookie creation Lazy, maybe put this in a lambda or 
>> use current.
>>
>> It is better to share the important part of your decorator functions
>>
>

-- 





Re: [web2py] Re: Setting cookies in models?

2012-08-08 Thread Yarin
Guys, this problem has evolved- the issue is not models per-se- I was able 
to set cookies in my models in a test app, and I was able to set them in a 
decorator as well. I'm even able to get the cookies to write when I call 
the specific decorator in question from a test function. All these things 
work, yet when i run my application through the normal paces, the cookies 
won't get set in that same decorator. I'm absolutely at wits end- how could 
that happen? 

Rocha- You mentioned lazy cookie creation, etc- can you please explain 
further?

On Wednesday, August 8, 2012 5:24:24 PM UTC-4, rochacbruno wrote:
>
> if he is setting the cookie inside a decorator function (inner-function) 
> maybe it gets defined on the start of the request.
>
> when the decorated function gets passed to the decorator inner-function, I 
> guess the cookie will be already setted. (but we need to take a look at the 
> code to figure out the scope)
>
> He needs to make the cookie creation Lazy, maybe put this in a lambda or 
> use current.
>
> It is better to share the important part of your decorator functions
>

-- 





Re: [web2py] Routing problem

2012-08-08 Thread Jonathan Lundell
On 8 Aug 2012, at 2:13 PM, Paulo Junqueira da Costa  
wrote:
> I just uploaded my first app do production under apache and following the 
> manual, I wrote a routes.py as follows:
> 
> routers = dict(
>   BASE  = dict(
>   default_application = 'vendasexpress',
>   default_controller = 'default',
>   default_function = 'index',
>   domains = {
>   'vendasexpress.com.br': 'vendasexpress',
>   'www.vendasexpress.com.br': 'vendasexpress',
>   'vendasexpress.rt1.webfactional.com': 'vendasexpress',
>   'admin.rt1.webfactional.com': 'admin',
>   }
>   ),
> )
> 
> But when I try vendasexpress.com.br or www.vendasexpress.com.br it point me 
> to http://vendasexpress.com.br/welcome/default/index.
> 
> If I click on register link, it goes to 
> http://vendasexpress.com.br/user/register and works! Some links are working 
> and some others not. I´m pretty confused on how the routing are going and how 
> to correct it.
> 
> The admin site (I created an https domais for it), works only if I go to 
> https://admin.rt1.webfactional.com/admin/default/site.
> 
> That´s our first web2py app in prod and we are in a hurry to finish it, so 
> any help will be appreciated.
> 

Have you restarted web2py since you installed routes.py (and is routes.py in 
the web2py root directory)? Your symptom (accessing the welcome app) suggests 
that the routes file isn't being loaded at all (or perhaps that it has a syntax 
error, though I don't see one above).

-- 





Re: [web2py] Re: Error in sqlhtml.py? T does not work. Proposal.

2012-08-08 Thread Martin Weissenboeck
Yes, I meant "current"

I am shure I did not find the string " '%(nrows)s records found') " in the
translation table. But now, with the original sqlform.py it works very
fine. I have tried it more than once.

You are right - T works. Please forget my message.

2012/8/8 Anthony 

> What is "common"? Do you mean current.T? Note, in grid(), there is this
> assignment: T = current.T. So, T(...) should work.
>
> Anthony
>
>
> On Wednesday, August 8, 2012 2:41:42 PM UTC-4, mweissen wrote:
>>
>> SQLFORM.grid write "... records found", but this sentence is not in the
>> translation table.
>>
>> In sqlhtml.py line 1956 there is "T('%(nrows)s records found')". I think
>> it should be "common.T('%(nrows)s records found')"
>>
>> This change works for me. There are some other "T"s in sqlhtml - I have
>> all of them changed to "common.T".
>>
>> Regards, Martin
>>
>>
>>
>>
>>

-- 





[web2py] SQLFORM.grid, checkboxes and mor than one page

2012-08-08 Thread Martin Weissenboeck
I have a SQLFORM.grid for 100 persons. Checkboxes are activated with a
function for the selectable-field.
Now this long list breaks down to serveral pages.
But a check on page 1 gets lost on changing to another page. So it is not
possible to select persons from the whole list.
Yes, with the paginate parameter I can create one long list without pages -
but that is not the idea of the grid?

Any ideas?
Regards Martin

-- 





Re: [web2py] Re: Setting cookies in models?

2012-08-08 Thread Bruno Rocha
if he is setting the cookie inside a decorator function (inner-function)
maybe it gets defined on the start of the request.

when the decorated function gets passed to the decorator inner-function, I
guess the cookie will be already setted. (but we need to take a look at the
code to figure out the scope)

He needs to make the cookie creation Lazy, maybe put this in a lambda or
use current.

It is better to share the important part of your decorator functions

-- 





[web2py] Re: web2py 2.0 almost done

2012-08-08 Thread Massimo Di Pierro
more issues have been addressed. In order to fix an issue I had to 
introduce a slight change of behavior and I am not sure what is the best 
way to handle it.

If you login using a third party service (for example janrain using 
facebook) and the service sends info about you, if web2py has corresponding 
fields in auth_user, it stores them. If you edit your profile, logout, 
change your facebook profile, login again using janrain, should web2py keep 
the current local profile or update it? The bug report suggested that 
web2oy should always give preference to the local profile.

I changed web2py accordingly. In practice this change will probably not 
affect anybody because none of the services sends any information stored by 
auth_user.

Yet, please check it.

Massimo



On Monday, 6 August 2012 23:33:48 UTC-5, Massimo Di Pierro wrote:
>
> Web2py 2.0 is almost done. 
> Please try the nightly build.
> Let us know if it breaks anything.
>
> massimo
>

-- 





[web2py] Routing problem

2012-08-08 Thread Paulo Junqueira da Costa
I just uploaded my first app do production under apache and following the 
manual, I wrote a routes.py as follows:

routers = dict(
  BASE  = dict(
  default_application = 'vendasexpress',
  default_controller = 'default',
  default_function = 'index',
  domains = {
  'vendasexpress.com.br': 'vendasexpress',
  'www.vendasexpress.com.br': 'vendasexpress',
  'vendasexpress.rt1.webfactional.com': 'vendasexpress',
  'admin.rt1.webfactional.com': 'admin',
  }
  ),
)

But when I try vendasexpress.com.br or www.vendasexpress.com.br it point me 
to http://vendasexpress.com.br/welcome/default/index.

If I click on register link, it goes to 
http://vendasexpress.com.br/user/register and works! Some links are working 
and some others not. I´m pretty confused on how the routing are going and 
how to correct it.

The admin site (I created an https domais for it), works only if I go to 
https://admin.rt1.webfactional.com/admin/default/site.

That´s our first web2py app in prod and we are in a hurry to finish it, so 
any help will be appreciated.

Thanks in advance.

-- 





[web2py] Re: web2py 2.0 almost done

2012-08-08 Thread Massimo Di Pierro
This is puzzling. Is it a physiological delay?


On Wednesday, 8 August 2012 01:08:27 UTC-5, lyn2py wrote:
>
> Thanks Akash for informing about downloading zip vs clone git.
> I also experienced that the zip download is not the most recent with 
> changes.
> Cloning gets the latest.
>
> On Wednesday, August 8, 2012 1:48:10 PM UTC+8, Akash Kakkar wrote:
>>
>>
>> This behavior was noticed on the src downloaded as zip from git hub, the 
>> web2py_src from the site works fine
>> I am not aware if downloading zip from github is a good practice or not
>>
>>
>> On Wednesday, 8 August 2012 10:44:39 UTC+5:30, Akash Kakkar wrote:
>>>
>>> I am unable to use ajax save (ctrl+S) in the new version after editing 
>>> the file. ctrl+S opens file save dialog. The button save button on top of 
>>> file editor does not work for me.
>>>
>>> Thanks
>>> Akash
>>>
>>> On Tuesday, 7 August 2012 10:03:48 UTC+5:30, Massimo Di Pierro wrote:

 Web2py 2.0 is almost done. 
 Please try the nightly build.
 Let us know if it breaks anything.

 massimo

>>>

-- 





[web2py] Re: Cross-subdomain login status detection

2012-08-08 Thread Massimo Di Pierro
If you use apache there is a way using this script provided by web2py.

web2py/scripts/access.wsgi

Some explanations are inside.

On Wednesday, 8 August 2012 14:11:17 UTC-5, Yarin wrote:
>
> I've got a public-facing non-web2py website at our root domain (
> http://ourdomain.com), and a web2py app at a subdomain (
> http://app.ourdomain.com).
>
> When a user comes to the root site that has a valid logged in session with 
> our app, I'd like to redirect them to the app subdomain automatically. 
>
> Is there a simple recipe for doing this? I was going to have an IFrame in 
> the main site load a 'check_loggedin' function from the app, and use 
> javascript to redirect the parent window to the app if the user was logged 
> in. But possibly there's an simpler solution using cross-subdomain cookies?
>
>
>

-- 





Re: [web2py] Re: Setting cookies in models?

2012-08-08 Thread Anthony
On Wednesday, August 8, 2012 4:51:58 PM UTC-4, rochacbruno wrote:
>
>
> I think you need to use "current"
>
> from gluon import current
>
> and inside the decorator function access current.request instead of request
>

Is the cookie being set in a model file or a module? current shouldn't be 
needed in a model, only a module.

Can you show the code?

Anthony 

-- 





Re: [web2py] Re: Setting cookies in models?

2012-08-08 Thread Bruno Rocha
I think you need to use "current"

from gluon import current

and inside the decorator function access current.request instead of request




On Wed, Aug 8, 2012 at 5:48 PM, Yarin  wrote:

> A little more about what I'm trying to do:
>
> I have a decorator function defined in a model that I use to decorate many
> of my controller functions. I want to set the cookie within this decorator.
>
>
> On Wednesday, August 8, 2012 4:26:00 PM UTC-4, Yarin wrote:
>>
>> I need to set a cookie on every request, so I tried setting it in the
>> model, but it never works. Setting it in controllers is no problem. I
>> couldn't find any documentation on this- is this behavior expected?
>>
>> If so, is there a way to ensure a cookie gets set on every request, short
>> of setting it in each controller file?
>>
>  --
>
>
>
>

-- 





[web2py] Re: Setting cookies in models?

2012-08-08 Thread Yarin
A little more about what I'm trying to do:

I have a decorator function defined in a model that I use to decorate many 
of my controller functions. I want to set the cookie within this decorator.

On Wednesday, August 8, 2012 4:26:00 PM UTC-4, Yarin wrote:
>
> I need to set a cookie on every request, so I tried setting it in the 
> model, but it never works. Setting it in controllers is no problem. I 
> couldn't find any documentation on this- is this behavior expected?
>
> If so, is there a way to ensure a cookie gets set on every request, short 
> of setting it in each controller file?
>

-- 





[web2py] How do larger teams develop with Web2py?

2012-08-08 Thread Luc Chase
What particular constraints and advantages does using web2py tend to bring 
for larger project development teams as opposed to those working solo or in 
very small teams?

I assume for example these roles benefit from rapid feedback and ability to 
adjust requirements more easily?

   - Project stakeholder (client or business owner)
   - Project manager
   - Producer
   - Editor/copywriter
   - Information architect
   - Tech lead
   - Database administrator
   - Quality assurance engineer

But are these roles less-able or more-able to work in parallel?

   - Graphic designer
   - HTML developer
   - Developer

-- 





Re: [web2py] Retreive value (option) from a select list

2012-08-08 Thread Mathias Van Daele
Thanks !!

2012/8/8 Richard Vézina :
> It's just a matter of selecting the proper html select and get the selected
> value.
>
> Richard
>
> On Wed, Aug 8, 2012 at 1:33 PM, Mathias Van Daele
>  wrote:
>>
>> Thanks for your reply Richard !
>>
>> I was hoping I could find a solution without extra Jquery, but I will
>> try it with Jquery .
>>
>> Mathias
>>
>> 2012/8/8 Richard Vézina :
>> > With .val()
>> > http://api.jquery.com/val/
>> >
>> > With :selected
>> > http://api.jquery.com/selected-selector/
>> >
>> > This could also interest you :
>> >
>> > http://stackoverflow.com/questions/496052/jquery-setting-the-selected-value-of-a-select-control-via-its-text-description
>> >
>> > Richard
>> >
>> >
>> > On Wed, Aug 8, 2012 at 11:05 AM, Mathias 
>> > wrote:
>> >>
>> >> Hello,
>> >>
>> >> How can I retreive the selected value (option), from an HTML select ?
>> >>
>> >> I want to use this in an ajax function, but I don't know how to get the
>> >> value.
>> >>
>> >> Thanks
>> >>
>> >> Mathias
>> >>
>> >> --
>> >>
>> >>
>> >>
>> >
>> >
>> > --
>> >
>> >
>> >
>>
>> --
>>
>>
>>
>
> --
>
>
>

-- 





[web2py] Setting cookies in models?

2012-08-08 Thread Yarin
I need to set a cookie on every request, so I tried setting it in the 
model, but it never works. Setting it in controllers is no problem. I 
couldn't find any documentation on this- is this behavior expected?

If so, is there a way to ensure a cookie gets set on every request, short 
of setting it in each controller file?

-- 





Re: [web2py] *** integer values into string variable ***

2012-08-08 Thread Vladimir Makarov
*My problem is solved. Thank you Bruno!!!*
*I used to set this field to integer and then changed it to string.*
*So... now it's OK - I set CHAR type for the field in SQLITEMAN.*


On Wednesday, August 8, 2012 11:35:13 PM UTC+4, rochacbruno wrote:
>
> Is that SQLITE? did you created it as integer and after that changed to 
> string?
>
> SQLITE does not have ALTER-TABLE command, so even if you change a field 
> from integer to string, web2py will see it as string, but the db will still 
> store as integer.
>
> You need to change the datatype to CHAR() on your sqlite database (use 
> sqliteman) or remove and recreate the db, or change the field name.
>
>
> On Wed, Aug 8, 2012 at 4:27 PM, Vladimir Makarov 
> 
> > wrote:
>
>> Hi there! I am a bit puzzled by the following problem.
>>
>> In my db.py file I use *string *type for the field.
>> Field('ras', 'string',  label=T('Account'), 
>> requires=IS_NOT_EMPTY(error_message='you should enter number of your 
>> account')),
>> But when I insert some value into this field, for example *
>> 301018100722*, it stores as *3.010181e+019*.
>> What's the matter? 
>>
>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] *** integer values into string variable ***

2012-08-08 Thread Bruno Rocha
Is that SQLITE? did you created it as integer and after that changed to
string?

SQLITE does not have ALTER-TABLE command, so even if you change a field
from integer to string, web2py will see it as string, but the db will still
store as integer.

You need to change the datatype to CHAR() on your sqlite database (use
sqliteman) or remove and recreate the db, or change the field name.


On Wed, Aug 8, 2012 at 4:27 PM, Vladimir Makarov wrote:

> Hi there! I am a bit puzzled by the following problem.
>
> In my db.py file I use *string *type for the field.
> Field('ras', 'string',  label=T('Account'),
> requires=IS_NOT_EMPTY(error_message='you should enter number of your
> account')),
> But when I insert some value into this field, for example *
> 301018100722*, it stores as *3.010181e+019*.
> What's the matter?
>
>  --
>
>
>
>

-- 





[web2py] *** integer values into string variable ***

2012-08-08 Thread Vladimir Makarov
Hi there! I am a bit puzzled by the following problem.

In my db.py file I use *string *type for the field.
Field('ras', 'string',  label=T('Account'), 
requires=IS_NOT_EMPTY(error_message='you should enter number of your 
account')),
But when I insert some value into this field, for example *
301018100722*, it stores as *3.010181e+019*.
What's the matter? 

-- 





Re: [web2py] Again: how redirect without propagate the .load extension?

2012-08-08 Thread Anthony
Looks good. :-)

On Wednesday, August 8, 2012 3:20:13 PM UTC-4, Massimo Di Pierro wrote:
>
> I agree. Please check trunk again.
>
> On Aug 8, 2012, at 2:04 PM, Anthony wrote:
>
> On Wednesday, August 8, 2012 1:18:11 PM UTC-4, Massimo Di Pierro wrote:
>>
>> ok, I defaulted to type='http' as you did but I allowed a type='auto' as 
>> well.
>>
>
> Good idea. Actually, I'm not sure we need the separate "auto" option -- 
> type='client' only makes sense for Ajax requests anyway, so why not just 
> make "client" behave like "auto" (i.e., when type == "client", ignore the 
> type unless it's an Ajax request):
>
> from gluon import current
> if type == 'client' and current.request.ajax:
>  raise HTTP(200, **{'web2py-redirect-location': location})
>
> Also, I'm re-thinking whether we should go with a "type" argument that can 
> take multiple values or a simple boolean (e.g., client_side=True). I was 
> originally thinking "type" could be extended to take an "internal" value, 
> but perhaps client-side and internal should be considered to be independent 
> rather than mutually exclusive (i.e., you might want a redirect to be both 
> internal, and client-side -- after the internal redirect to generate the 
> response, the redirect itself should still happen on the client in the full 
> window). In that case, we'd need a separate argument to specify "internal" 
> independently (i.e., internal=True, client_side=True), so the client-side 
> specification might as well just be a boolean. Thoughts?
>
> Anthony
>
>
>

-- 





[web2py] MARKMIN change of behavior

2012-08-08 Thread Massimo DiPierro
There is a manor change of behavior in MARKMIN. 

Before:

- markmin 
# title
aaa

bbb
-- end markmin 

would render as

titleaaa

After:

the same markmin would render

title aaa

In other words now headers (#, ##, ###) can be continued to the next line and 
need an empty new line to be separated from the first paragraph.
I think the new behavior is better and previous behavior should be considered a 
bug.

Anyway. I just wanted people to know, in case there are major objections.

Massimo


-- 





[web2py] Re: Error in sqlhtml.py? T does not work. Proposal.

2012-08-08 Thread Anthony
What is "common"? Do you mean current.T? Note, in grid(), there is this 
assignment: T = current.T. So, T(...) should work.

Anthony

On Wednesday, August 8, 2012 2:41:42 PM UTC-4, mweissen wrote:
>
> SQLFORM.grid write "... records found", but this sentence is not in the 
> translation table.
>
> In sqlhtml.py line 1956 there is "T('%(nrows)s records found')". I think 
> it should be "common.T('%(nrows)s records found')"
>
> This change works for me. There are some other "T"s in sqlhtml - I have 
> all of them changed to "common.T".
>
> Regards, Martin
>
>
>
>
>  

-- 





Re: [web2py] Again: how redirect without propagate the .load extension?

2012-08-08 Thread Massimo DiPierro
I agree. Please check trunk again.

On Aug 8, 2012, at 2:04 PM, Anthony wrote:

> On Wednesday, August 8, 2012 1:18:11 PM UTC-4, Massimo Di Pierro wrote:
> ok, I defaulted to type='http' as you did but I allowed a type='auto' as well.
> 
> Good idea. Actually, I'm not sure we need the separate "auto" option -- 
> type='client' only makes sense for Ajax requests anyway, so why not just make 
> "client" behave like "auto" (i.e., when type == "client", ignore the type 
> unless it's an Ajax request):
> 
> from gluon import current
> if type == 'client' and current.request.ajax:
>  raise HTTP(200, **{'web2py-redirect-location': location})
> 
> Also, I'm re-thinking whether we should go with a "type" argument that can 
> take multiple values or a simple boolean (e.g., client_side=True). I was 
> originally thinking "type" could be extended to take an "internal" value, but 
> perhaps client-side and internal should be considered to be independent 
> rather than mutually exclusive (i.e., you might want a redirect to be both 
> internal, and client-side -- after the internal redirect to generate the 
> response, the redirect itself should still happen on the client in the full 
> window). In that case, we'd need a separate argument to specify "internal" 
> independently (i.e., internal=True, client_side=True), so the client-side 
> specification might as well just be a boolean. Thoughts?
> 
> Anthony
> 

-- 





[web2py] Cross-subdomain login status detection

2012-08-08 Thread Yarin
I've got a public-facing non-web2py website at our root domain 
(http://ourdomain.com), and a web2py app at a subdomain 
(http://app.ourdomain.com).

When a user comes to the root site that has a valid logged in session with 
our app, I'd like to redirect them to the app subdomain automatically. 

Is there a simple recipe for doing this? I was going to have an IFrame in 
the main site load a 'check_loggedin' function from the app, and use 
javascript to redirect the parent window to the app if the user was logged 
in. But possibly there's an simpler solution using cross-subdomain cookies?


-- 





Re: [web2py] Again: how redirect without propagate the .load extension?

2012-08-08 Thread Anthony
On Wednesday, August 8, 2012 1:18:11 PM UTC-4, Massimo Di Pierro wrote:
>
> ok, I defaulted to type='http' as you did but I allowed a type='auto' as 
> well.
>

Good idea. Actually, I'm not sure we need the separate "auto" option -- 
type='client' only makes sense for Ajax requests anyway, so why not just 
make "client" behave like "auto" (i.e., when type == "client", ignore the 
type unless it's an Ajax request):

from gluon import current
if type == 'client' and current.request.ajax:
 raise HTTP(200, **{'web2py-redirect-location': location})

Also, I'm re-thinking whether we should go with a "type" argument that can 
take multiple values or a simple boolean (e.g., client_side=True). I was 
originally thinking "type" could be extended to take an "internal" value, 
but perhaps client-side and internal should be considered to be independent 
rather than mutually exclusive (i.e., you might want a redirect to be both 
internal, and client-side -- after the internal redirect to generate the 
response, the redirect itself should still happen on the client in the full 
window). In that case, we'd need a separate argument to specify "internal" 
independently (i.e., internal=True, client_side=True), so the client-side 
specification might as well just be a boolean. Thoughts?

Anthony

-- 





[web2py] Error in sqlhtml.py? T does not work. Proposal.

2012-08-08 Thread Martin Weissenboeck
SQLFORM.grid write "... records found", but this sentence is not in the
translation table.

In sqlhtml.py line 1956 there is "T('%(nrows)s records found')". I think it
should be "common.T('%(nrows)s records found')"

This change works for me. There are some other "T"s in sqlhtml - I have all
of them changed to "common.T".

Regards, Martin

-- 





Re: [web2py] favicon

2012-08-08 Thread Massimo Di Pierro
I removed and moved the favicon(s) in the images subfolder. Chan you please 
check it?

On Wednesday, 8 August 2012 13:14:04 UTC-5, Richard wrote:
>
> Hello,
>
> I read this comment in layout of welcome app for 1.99.4 (sorry if it gone) 
> :
>
> 
>
> It is about those 2 lines :
>
>type="image/x-icon">
>   
>
> I think that those links are the proper way to insert favicon base on w3c 
> : http://www.w3.org/2005/10/howto-favicon
>
> So the comment is miss leading I think.
>
> Should be remove if still there!
>
> Richard
>

-- 





[web2py] Re: Send validation keys to list of emails, so they can update their details?

2012-08-08 Thread Massimo Di Pierro

# insert all the emails
for email in emails:
 db.auth._user.insert(email=email)
# ask everybody to reset their password for login
for user in db(db.auth_user.email.belongs(emails)).select():
 auth.email_reset_password(user)



On Wednesday, 8 August 2012 12:47:57 UTC-5, Alec Taylor wrote:
>
> I am about to import a list of people into web2py.
>
> Each person's record has an email address at the very least.
>
> One purpose for moving to web2py is to allow people to update their 
> details, and only their details.
>
> How would I go about generating accounts for people, emailing them their 
> validation key, then allowing those users with matching email-addresses to 
> edit said record?
>
> Thanks for all suggestions,
>
> Alec Taylor
>
> FYI: Login will be done with LinkedIn, and this whole system will be 
> open-sourced. 
>

-- 





[web2py] favicon

2012-08-08 Thread Richard Vézina
Hello,

I read this comment in layout of welcome app for 1.99.4 (sorry if it gone) :



It is about those 2 lines :

  
  

I think that those links are the proper way to insert favicon base on w3c :
http://www.w3.org/2005/10/howto-favicon

So the comment is miss leading I think.

Should be remove if still there!

Richard

-- 





Re: [web2py] Retreive value (option) from a select list

2012-08-08 Thread Richard Vézina
It's just a matter of selecting the proper html select and get the selected
value.

Richard

On Wed, Aug 8, 2012 at 1:33 PM, Mathias Van Daele  wrote:

> Thanks for your reply Richard !
>
> I was hoping I could find a solution without extra Jquery, but I will
> try it with Jquery .
>
> Mathias
>
> 2012/8/8 Richard Vézina :
> > With .val()
> > http://api.jquery.com/val/
> >
> > With :selected
> > http://api.jquery.com/selected-selector/
> >
> > This could also interest you :
> >
> http://stackoverflow.com/questions/496052/jquery-setting-the-selected-value-of-a-select-control-via-its-text-description
> >
> > Richard
> >
> >
> > On Wed, Aug 8, 2012 at 11:05 AM, Mathias 
> wrote:
> >>
> >> Hello,
> >>
> >> How can I retreive the selected value (option), from an HTML select ?
> >>
> >> I want to use this in an ajax function, but I don't know how to get the
> >> value.
> >>
> >> Thanks
> >>
> >> Mathias
> >>
> >> --
> >>
> >>
> >>
> >
> >
> > --
> >
> >
> >
>
> --
>
>
>
>

-- 





Re: [web2py] Re: Search in Web2Py

2012-08-08 Thread Alec Taylor
On Thu, Aug 9, 2012 at 12:37 AM, Massimo Di Pierro
 wrote:
> I am considering adding Whoosh support in DAL

That would be an excellent addition =)

How are you considering presenting it, e.g.: as a `crud.search`
replacement using `SQLFORM`?

> On Tuesday, 7 August 2012 23:52:48 UTC-5, Anthony wrote:
>>
>> There's nothing built in (would be nice, though), but web2py should work
>> fine with any standard search functionality (e.g., SQLite and Postgres full
>> text search, Whoosh, Sphinx, Solr, ElasticSearch, Searchify, etc.).
>>
>> Anthony
>>
>> On Tuesday, August 7, 2012 11:27:51 PM UTC-4, Mike Girard wrote:
>>>
>>> I notice that there is no search box on the main web2py site.  The search
>>> on the book site is somewhat unorthodox in that it only provides links where
>>> the search term is located but does not show you where. Does web2py have a
>>> robust, conventional search utility? If not, what is the prescribed method
>>> for getting around this?
>
> --
>
>
>

-- 





[web2py] Send validation keys to list of emails, so they can update their details?

2012-08-08 Thread Alec Taylor
I am about to import a list of people into web2py.

Each person's record has an email address at the very least.

One purpose for moving to web2py is to allow people to update their 
details, and only their details.

How would I go about generating accounts for people, emailing them their 
validation key, then allowing those users with matching email-addresses to 
edit said record?

Thanks for all suggestions,

Alec Taylor

FYI: Login will be done with LinkedIn, and this whole system will be 
open-sourced. 

-- 





[web2py] Re: Scheduler: help us test it while learning

2012-08-08 Thread Daniel Haag
Hi Niphlod,

thanks for the great work with the scheduler, I'm using it in a project 
where it handles lots of big data imports into a database and the migration 
to your version was without any problems.

On thing catched my eye in the old version and it still seems to be a 
"problem/missing feature" in the new one. When a long running process gets 
executed and produces output (print etc.) this output is written to the 
database only after the task was run (and finished). It would be really 
great if the output gets written into the task table while the task runs as 
this would be a possible feedback mechanism (and we would not need another 
table etc. just for that) just thinking of a progress meter for example.

What I really miss though is the output of the task when it produces a 
timeout - nothing in the task table about the output...

Daniel





Am Donnerstag, 12. Juli 2012 20:36:38 UTC schrieb Niphlod:
>
> Hello everybody, in the last month several changes were commited to the 
> scheduler, in order to improve it.
> Table schemas were changed, to add some features that were missed by some 
> users.
> On the verge of releasing web2py v.2.0.0, and seeing that the scheduler 
> potential is often missed by regular web2py users, I created a test app 
> with two main objectives: documenting the new scheduler and test the 
> features.
>
> App is available on github (https://github.com/niphlod/w2p_scheduler_tests). 
> All you need is download the trunk version of web2py, download the app and 
> play with it.
>
> Current features:
> - one-time-only tasks
> - recurring tasks
> - possibility to schedule functions at a given time
> - possibility to schedule recurring tasks with a stop_time
> - can operate distributed among machines, given a database reachable for 
> all workers
> - group_names to "divide" tasks among different workers
> - group_names can also influence the "percentage" of assigned tasks to 
> similar workers
> - simple integration using modules for "embedded" tasks (i.e. you can use 
> functions defined in modules directly in your app or have them processed in 
> background)
> - configurable heartbeat to reduce latency: with sane defaults and not 
> t many tasks queued normally a queued task doesn't exceed 5 seconds 
> execution times
> - option to start it, process all available tasks and then die 
> automatically
> - integrated tracebacks
> - monitorable as state is saved on the db
> - integrated app environment if started as web2py.py -K
> - stop processes immediately (set them to "KILL")
> - stop processes gracefully (set them to "TERMINATE")
> - disable processes (set them to "DISABLED")
> - functions that doesn't return results do not generate a scheduler_run 
> entry
> - added a discard_results parameter that doesn't store results "no matter 
> what"
> - added a uuid record to tasks to simplify checkings of "unique" tasks
> - task_name is not required anymore
> - you can skip passing the function to the scheduler istantiation: 
> functions can be dinamically retrieved in the app's environment
>
> So, your mission is:
> - test the scheduler with the app and familiarize with it
> Secondary mission is:
> - report any bug you find here or on github (
> https://github.com/niphlod/w2p_scheduler_tests/issues)
> - propose new examples to be embedded in the app, or correct the current 
> docs (English is not my mother tongue) 
>
> Once approved, docs will be probably embedded in the book (
> http://web2py.com/book)
>
> Feel free to propose features you'd like to see in the scheduler, I have 
> some time to spend implementing it.
>
>
>
>

-- 





[web2py] KeyError: 'name' when inserting/updating via appadmin

2012-08-08 Thread Mandar Vaze
I'm using web2py version : Version 2.0.0 (2012-07-26 06:06:10) dev

I have tables defined as follows : 

name = db.Table(db, 'name', 
 
Field('name', 'string', length=128, notnull=True, unique=True))
  
name_desc = db.Table(db, 'base',
name,
Field('description', 'text', default=''))   

db.define_table('mother', 
name_desc,
format='%(name)s')
db.define_table('father', 
name_desc,
format='%(name)s')
db.define_table('child',   
   
name_desc, 
 
Field('mother', db.mother), 
  
Field('father', db.father), 
 
format='%(name)s')

I am able to insert data in "mother" table via script (like 
db.mother.insert(name="Alice"))
But when I use appadmin to insert new record into mother table, I get the 
following error :

Traceback (most recent call last):
  File "/home/mandar/web2py/gluon/restricted.py", line 205, in restricted
exec ccode in environment
  File "/home/mandar/web2py/applications/test1/controllers/appadmin.py", 
line 432, in 
  File "/home/mandar/web2py/gluon/globals.py", line 182, in 
self._caller = lambda f: f()
  File "/home/mandar/web2py/applications/test1/controllers/appadmin.py", 
line 127, in insert
if form.accepts(request.vars, session):
  File "/home/mandar/web2py/gluon/sqlhtml.py", line 1146, in accepts
hideerror=hideerror,
  File "/home/mandar/web2py/gluon/html.py", line 1870, in accepts
status = self._traverse(status,hideerror)
  File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/home/mandar/web2py/gluon/html.py", line 800, in _traverse
newstatus = self._validate()
  File "/home/mandar/web2py/gluon/html.py", line 1625, in _validate
(value, errors) = validator(value)
  File "/home/mandar/web2py/gluon/validators.py", line 554, in __call__
table = self.dbset.db[tablename]
  File "/home/mandar/web2py/gluon/dal.py", line 6877, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: 'name'

Similarly, after populating mother/father and child tables via script when 
I try to update "child" record - In the dropdown I see mother's names 
instead of ID (as expected) but when I select different "mother" and submit 
I get same error (traceback may be slightly different - but same 
KeyError:'name' )

What is wrong with the table definitions ?

Thanks,
-Mandar

-- 





Re: [web2py] Retreive value (option) from a select list

2012-08-08 Thread Mathias Van Daele
Thanks for your reply Richard !

I was hoping I could find a solution without extra Jquery, but I will
try it with Jquery .

Mathias

2012/8/8 Richard Vézina :
> With .val()
> http://api.jquery.com/val/
>
> With :selected
> http://api.jquery.com/selected-selector/
>
> This could also interest you :
> http://stackoverflow.com/questions/496052/jquery-setting-the-selected-value-of-a-select-control-via-its-text-description
>
> Richard
>
>
> On Wed, Aug 8, 2012 at 11:05 AM, Mathias  wrote:
>>
>> Hello,
>>
>> How can I retreive the selected value (option), from an HTML select ?
>>
>> I want to use this in an ajax function, but I don't know how to get the
>> value.
>>
>> Thanks
>>
>> Mathias
>>
>> --
>>
>>
>>
>
>
> --
>
>
>

-- 





[web2py] Re: How to keep database connection alive ?

2012-08-08 Thread Massimo Di Pierro
yes. it should

On Wednesday, 8 August 2012 11:36:58 UTC-5, Anthony wrote:
>
> SQLite ignores the pool_size parameter, though, right? In any case, 
> shouldn't a background task run through the scheduler be able to establish 
> a db connection, even without pooling?
>
> Anthony
>
> On Wednesday, August 8, 2012 10:45:18 AM UTC-4, Massimo Di Pierro wrote:
>>
>> Normally you would do
>>
>> db = DAL('sqlite://storage.sqlite',pool_size=10)
>>
>> where 10 is the max number of connections to keep alive and to be 
>> recycled across multiple requests.
>> I am not sure how this interact with scheduler.
>>
>> On Wednesday, 8 August 2012 01:59:06 UTC-5, Amit wrote:
>>>
>>>
>>> Hi,
>>> I am using SQlite database for my web2py application, I have to keep the 
>>> same db instance which is created at first time request comes to model db.py
>>>
>>>
>>> db = DAL('sqlite://storage.sqlite')
>>>
>>> database connection is getting closed once request is completed so I am 
>>> not able to use the "db" for some background process like purging the 
>>> records every day so can anyone suggest me the proper way to keep the 
>>> database connection alive irrespective of request?
>>>
>>> Scenario:
>>> 1. when first time request made , db connection is established, I need 
>>> to keep this connection alive
>>> 2. One background scheduler running continuously to check the records in 
>>> db and purge it based on some condition.
>>>
>>> Problem facing:
>>> when first request made and get fulfilled, database connection is 
>>> getting closed because of that scheduler is not able to use the db instance 
>>> and start throwing error "Cannot operate on a closed database." every time 
>>> when it tries to execute the job.So I need to keep the "db"instance 
>>> connected to db , how can it be achieved?
>>
>>

-- 





Re: [web2py] Again: how redirect without propagate the .load extension?

2012-08-08 Thread Massimo Di Pierro
ok, I defaulted to type='http' as you did but I allowed a type='auto' as 
well.

On Wednesday, 8 August 2012 10:30:06 UTC-5, Anthony wrote:
>
> On Wednesday, August 8, 2012 11:05:42 AM UTC-4, Massimo Di Pierro wrote:
>>
>> In trunk, with a minor change that makes the type parameter optional and 
>> auto-detects ajax.
>>
>
> I don't think it should auto-detect ajax and automatically do a 
> client-side full-page redirect in that case. Note, you don't necessarily 
> want a full page redirect with all Ajax requests (when an Ajax component 
> redirects, for example, you typically want the redirect response to load in 
> the component, not the full page). This is just supposed to be an option 
> for those subset of cases where you do need a full-page redirect from an 
> Ajax response.
>
> Anthony
>

-- 





Re: [web2py] Re: Implementing a messaging system

2012-08-08 Thread Bruno Rocha
In this page: http://dev.s-cubism.com/web2py_plugins you can find a set of
plugins, one of them are message plugin. (experimental, but I used and it
works well)

Also there is a video (in portuguese) about real time message:
https://vimeo.com/38972256

-- 





[web2py] Re: How to keep database connection alive ?

2012-08-08 Thread Anthony
SQLite ignores the pool_size parameter, though, right? In any case, 
shouldn't a background task run through the scheduler be able to establish 
a db connection, even without pooling?

Anthony

On Wednesday, August 8, 2012 10:45:18 AM UTC-4, Massimo Di Pierro wrote:
>
> Normally you would do
>
> db = DAL('sqlite://storage.sqlite',pool_size=10)
>
> where 10 is the max number of connections to keep alive and to be recycled 
> across multiple requests.
> I am not sure how this interact with scheduler.
>
> On Wednesday, 8 August 2012 01:59:06 UTC-5, Amit wrote:
>>
>>
>> Hi,
>> I am using SQlite database for my web2py application, I have to keep the 
>> same db instance which is created at first time request comes to model db.py
>>
>>
>> db = DAL('sqlite://storage.sqlite')
>>
>> database connection is getting closed once request is completed so I am 
>> not able to use the "db" for some background process like purging the 
>> records every day so can anyone suggest me the proper way to keep the 
>> database connection alive irrespective of request?
>>
>> Scenario:
>> 1. when first time request made , db connection is established, I need to 
>> keep this connection alive
>> 2. One background scheduler running continuously to check the records in 
>> db and purge it based on some condition.
>>
>> Problem facing:
>> when first request made and get fulfilled, database connection is getting 
>> closed because of that scheduler is not able to use the db instance and 
>> start throwing error "Cannot operate on a closed database." every time when 
>> it tries to execute the job.So I need to keep the "db"instance connected to 
>> db , how can it be achieved?
>
>

-- 





[web2py] Compute field update/update_record problem

2012-08-08 Thread Marek Mollin
Hello,
I know this has been flagged in past. Still I could not find a clean 
solution to handle such events.
When either updating or updating record if fields/keys used in compute are 
not provided it throws a KeyError.
Ok I can handle that no problem. Try,except: pass, but If I do pass it 
assigns compute None. While if I have id I can perform some operations in 
order to get previous values... but sometimes I am performing an update and 
I dont have id.

Compute fields seem very useful.
They are nice because with VirtualFields they are recalculated everytime I 
get records which is not good for performance.
While with LazyFields I have to treat them as methods of model sort of and 
run them everytime I do something.

Has anyone came up with idea for fixing compute fields?
My solution would be to not accept compute function return None. If it 
returns None than field should not change form its previous value.

-- 





Re: [web2py] Retreive value (option) from a select list

2012-08-08 Thread Richard Vézina
With .val()
http://api.jquery.com/val/

With :selected
http://api.jquery.com/selected-selector/

This could also interest you :
http://stackoverflow.com/questions/496052/jquery-setting-the-selected-value-of-a-select-control-via-its-text-description

Richard

On Wed, Aug 8, 2012 at 11:05 AM, Mathias  wrote:

> Hello,
>
> How can I retreive the selected value (option), from an HTML select ?
>
> I want to use this in an ajax function, but I don't know how to get the
> value.
>
> Thanks
>
> Mathias
>
> --
>
>
>
>

-- 





[web2py] Re: Implementing a messaging system

2012-08-08 Thread shartha
Thanks for the replies. What I need is not a realtime messaging system, 
also that is something I have in mind for future extensions -- so still 
helpful, thanks. 

My need is more like an emailing system where each user will have an inbox, 
sent and trash folder, and messages are shown in a thread form. So in the 
inbox page, you see the list of all the messages you've received, and if 
you click on one, all the corresponding to that particular message appears.

Thanks

-- 





Re: [web2py] Again: how redirect without propagate the .load extension?

2012-08-08 Thread Anthony
On Wednesday, August 8, 2012 11:05:42 AM UTC-4, Massimo Di Pierro wrote:
>
> In trunk, with a minor change that makes the type parameter optional and 
> auto-detects ajax.
>

I don't think it should auto-detect ajax and automatically do a client-side 
full-page redirect in that case. Note, you don't necessarily want a full 
page redirect with all Ajax requests (when an Ajax component redirects, for 
example, you typically want the redirect response to load in the component, 
not the full page). This is just supposed to be an option for those subset 
of cases where you do need a full-page redirect from an Ajax response.

Anthony

-- 





Re: [web2py] Re: Appengine CPU cycles

2012-08-08 Thread Massimo Di Pierro
Thanks for the clarification.

On Wednesday, 8 August 2012 10:09:27 UTC-5, Felipe Meirelles wrote:
>
> Sorry about the URL confusion. The processing on web2py version is done on 
> /queues/position, while in the django one is done in /api/position as I 
> didnt implemented queues on the django version.
>
> Json dumps and loads are only used on web2py version, but not using the 
> shipped simplejson (it realy had a performace issue) its done using native 
> json lib for python 2.7.
>
> I just posted the django performance for a matter of rough comparsion, as 
> the code and the aproch for both are sightly diferent, so the performance 
> should be too. The main comparsion is about web2py with or without the 
> models.
>
> On Wed, Aug 8, 2012 at 11:59 AM, Massimo Di Pierro 
> 
> > wrote:
>
>> I do not understand. When you compare Django vs web2p[y performance, you 
>> seem to be comparing the MCycles for 
>> /api/1.0/position
>>  (in 
>> case of Django) with 
>> /main/queues/position
>>  (in 
>> the case of web2py). Shouldn't you be comparing with 
>> /main/api/position?
>>  
>> Or perhaps the names are reversed?
>>
>> Do they perform the same DB IO? Do they both store sessions in DB (web2py 
>> does)?
>>
>> It is likely Django uses simplejson binary while web2py (for portability) 
>> only ships with simplejson in pure python. This may be another performance 
>> loss if you use json a lot. We need to fix this at the web2py level.
>>
>> Massimo
>>
>> On Wednesday, 8 August 2012 08:06:05 UTC-5, Felipe Meirelles wrote:
>>>
>>> Well, after 24h running the new model less code I think I can post some 
>>> data:
>>>
>>> First of all I'll explain my application archtecture:
>>>
>>> I have a cloud server gattering information from around 150 gps on some 
>>> asserts. Each assert sends information every 30s, and some sends additional 
>>> reading information, wich give me a total arround 150k request/day. This 
>>> cloud server is integrated with appengine trought a REST API, speaching 
>>> Json to each other.
>>>
>>> Before the model less refactor I had the following status:
>>> *Current Load [image: 
>>> help]
>>> * URI  Req/Seccurrent Requestslast 6 hrs Runtime MCycleslast hr Avg 
>>> Latency
>>> /main/queues/position
>>>  1.2 48.78K 351 1200ms 
>>> /main/api/position
>>>  0.9 44.37K 267 600 ms
>>> As you can see, I have controllers, the /api/ receives a call from the 
>>> cloud server and enqueues a process request on appengine (this is a very 
>>> simple controller, no data processing at all), and the /queues/ wich 
>>> actualy process the data, make some inserts/updates and handle the memcache.
>>>
>>> After the refactor:
>>>
>>> *Current Load [image: 
>>> help]
>>> * URI  Req/Seccurrent Requestslast 6 hrs Runtime MCycleslast hr Avg 
>>> Latency
>>> /main/queues/position
>>>  1.1 49.34K 180 404 ms 
>>> /main/api/position
>>>  0.9 44.80K 78 139 ms
>>> Im only posting the position URL becouse its the most complex and most 
>>> hitted.
>>>
>>> In comparsion, the Django project (same logic, I have it still runing 
>>> while the web2py one is not ready):
>>>
>>> *Current Load [image: 
>>> help]
>>> * URI  Req/Seccurrent Requestslast 6 hrs Runtime MCycleslast hr Avg 
>>> Latencylast hr 
>>> /api/1.0/position

Re: [web2py] Re: Appengine CPU cycles

2012-08-08 Thread Jonathan Lundell
On 8 Aug 2012, at 7:59 AM, Massimo Di Pierro  wrote:
> It is likely Django uses simplejson binary while web2py (for portability) 
> only ships with simplejson in pure python. This may be another performance 
> loss if you use json a lot. We need to fix this at the web2py level.
> 

This is fixed in at least some places in web2py, where we try to import json 
from the standard library before falling back on python solutions. But not 
everywhere, I think.

-- 





Re: [web2py] Re: Appengine CPU cycles

2012-08-08 Thread Felipe Meirelles
Sorry about the URL confusion. The processing on web2py version is done on
/queues/position, while in the django one is done in /api/position as I
didnt implemented queues on the django version.

Json dumps and loads are only used on web2py version, but not using the
shipped simplejson (it realy had a performace issue) its done using native
json lib for python 2.7.

I just posted the django performance for a matter of rough comparsion, as
the code and the aproch for both are sightly diferent, so the performance
should be too. The main comparsion is about web2py with or without the
models.

On Wed, Aug 8, 2012 at 11:59 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I do not understand. When you compare Django vs web2p[y performance, you
> seem to be comparing the MCycles for 
> /api/1.0/position
>  (in
> case of Django) with 
> /main/queues/position
>  (in
> the case of web2py). Shouldn't you be comparing with 
> /main/api/position?
> Or perhaps the names are reversed?
>
> Do they perform the same DB IO? Do they both store sessions in DB (web2py
> does)?
>
> It is likely Django uses simplejson binary while web2py (for portability)
> only ships with simplejson in pure python. This may be another performance
> loss if you use json a lot. We need to fix this at the web2py level.
>
> Massimo
>
> On Wednesday, 8 August 2012 08:06:05 UTC-5, Felipe Meirelles wrote:
>>
>> Well, after 24h running the new model less code I think I can post some
>> data:
>>
>> First of all I'll explain my application archtecture:
>>
>> I have a cloud server gattering information from around 150 gps on some
>> asserts. Each assert sends information every 30s, and some sends additional
>> reading information, wich give me a total arround 150k request/day. This
>> cloud server is integrated with appengine trought a REST API, speaching
>> Json to each other.
>>
>> Before the model less refactor I had the following status:
>> *Current Load [image: 
>> help]
>> * URI  Req/Seccurrent Requestslast 6 hrs Runtime MCycleslast hr Avg
>> Latency
>> /main/queues/position
>>  1.2 48.78K 351 1200ms
>> /main/api/position
>>  0.9 44.37K 267 600 ms
>> As you can see, I have controllers, the /api/ receives a call from the
>> cloud server and enqueues a process request on appengine (this is a very
>> simple controller, no data processing at all), and the /queues/ wich
>> actualy process the data, make some inserts/updates and handle the memcache.
>>
>> After the refactor:
>>
>> *Current Load [image: 
>> help]
>> * URI  Req/Seccurrent Requestslast 6 hrs Runtime MCycleslast hr Avg
>> Latency
>> /main/queues/position
>>  1.1 49.34K 180 404 ms
>> /main/api/position
>>  0.9 44.80K 78 139 ms
>> Im only posting the position URL becouse its the most complex and most
>> hitted.
>>
>> In comparsion, the Django project (same logic, I have it still runing
>> while the web2py one is not ready):
>>
>> *Current Load [image: 
>> help]
>> * URI  Req/Seccurrent Requestslast 6 hrs Runtime MCycleslast hr Avg
>> Latencylast hr
>> /api/1.0/position
>>  0.8 50.13K 92 406 ms
>> On the django version I didnt had the queue yet, so this one

[web2py] Re: Implementing a messaging system

2012-08-08 Thread Massimo Di Pierro
web2py comes with a realime messaging engine in 
gluon/contrib/comet_messaging.py. It requires tornado installed. read the 
docstrings in the file for more info. It is not well documented but there 
is a video about it http://vimeo.com/18399381.

On Tuesday, 7 August 2012 23:58:33 UTC-5, shartha wrote:
>
>
> Hi, I'd like to implement a messaging system (between the users of the 
> website), and I need help to implement it. The way I've done it is to 
> create a message table that has fields for the sender, receiver, subject, 
> body, two boolean fields that shows whether the sender or the receiver have 
> deleted the message (such that it's not shown to them). This is not quite 
> working. I am thinking there must be a better way to do it, or somebody 
> might have already implemented something. The table is defined as:
>
> db.define_table('messages',
> Field('recipient_id',db.auth_user, label='To'),
> Field('subject','string'),
> Field('body','string'),
> Field('date','datetime'),
> Field('sender_id',db.auth_user),
> Field('sender_deleted','boolean'),
> Field('recipient_deleted','boolean'),
> )
>
> and as it obvious, some of the fields are values from the user database. 
> Could somebody tell me if I am on the right track or if changes need to be 
> made to my structure?
>
> Thanks!
>

-- 





Re: [web2py] Again: how redirect without propagate the .load extension?

2012-08-08 Thread Massimo Di Pierro
In trunk, with a minor change that makes the type parameter optional and 
auto-detects ajax.

On Wednesday, 8 August 2012 08:21:33 UTC-5, Anthony wrote:
>
> Attached is a patch that enables client-side full-page redirects from Ajax 
> requests. It alters the redirect() function in http.py as well as adding an 
> event handler in web2py.js. With it, in a function called via Ajax, you can 
> do:
>
> def my_ajax_function():
> if some_condition:
> redirect(URL('default', 'other_function', extension=False), type=
> 'client')
> return dict()
>
> In that case, redirect does not raise an HTTP(303). Instead, it raises an 
> HTTP(200) and sets a special "web2py-redirect-location" response header 
> with the redirect URL. On the client side, a jQuery.ajaxSuccess event 
> handler checks for that header on every successful Ajax request, and if the 
> header is there, it sets window.location to that URL, which loads the full 
> page in the browser window. Note, if redirecting from a function called 
> with the .load extension, you probably want to set extension=False when 
> constructing the redirect URL so the .load extension is not propagated to 
> the redirect.
>
> Eventually, we might consider adding a type='internal' option to the 
> redirect() function, which could generate a new internal request to the 
> redirect URL rather than sending a 303 to the server (this would have 
> nothing to do with Ajax -- just a way of speeding up regular server-side 
> redirects when you don't need the browser to receive a new URL with the 
> redirect).
>
> Anthony
>
> On Wednesday, August 8, 2012 4:58:44 AM UTC-4, mweissen wrote:
>>
>> Any solution so far?
>>
>> 2012/7/29 Martin Weissenboeck 
>>
>>> Thank you!
>>>
>>>
>>> 2012/7/28 Massimo Di Pierro 
>>>
 I will take a patch. ;-)


 On Friday, 27 July 2012 16:54:51 UTC-5, mweissen wrote:
>
> Hallo Johann,
>
> I have tried your proposal - yes, this "workaround" does the job and I 
> think I will use it.
> But I am surprised that there is not simple solution. Or does nobody 
> else want to get rid the "load"?
>
> 2012/7/27 Johann Spies 
>
>> Hallo Martin, 
>>
>> In stead of redirecting, I am using this script in the view:
>>
>> 
>> jQuery(document).ready(**function() {
>>   
>> jQuery($(":input:submit:last")**.addClass('gaanvoort'));
>>
>>   jQuery($("input.gaanvoort").**click(
>>   function() {
>>   window.location = 
>> "/init/articles/add_article";
>>
>>
>>
>>   }));
>>
>>
>>
>>});
>>  
>>  
>> and then use session variables on the destination.
>>
>> Regards
>> Johann
>>
>> -- 
>> Because experiencing your loyal love is better than life itself, 
>> my lips will praise you.  (Psalm 63:3)
>>
>

-- 





[web2py] Retreive value (option) from a select list

2012-08-08 Thread Mathias
Hello,

How can I retreive the selected value (option), from an HTML select ?

I want to use this in an ajax function, but I don't know how to get the 
value.

Thanks

Mathias

-- 





Re: [web2py] Re: Appengine CPU cycles

2012-08-08 Thread Massimo Di Pierro
I do not understand. When you compare Django vs web2p[y performance, you 
seem to be comparing the MCycles for 
/api/1.0/position
 (in 
case of Django) with 
/main/queues/position
 (in 
the case of web2py). Shouldn't you be comparing with 
/main/api/position?
 
Or perhaps the names are reversed?

Do they perform the same DB IO? Do they both store sessions in DB (web2py 
does)?

It is likely Django uses simplejson binary while web2py (for portability) 
only ships with simplejson in pure python. This may be another performance 
loss if you use json a lot. We need to fix this at the web2py level.

Massimo

On Wednesday, 8 August 2012 08:06:05 UTC-5, Felipe Meirelles wrote:
>
> Well, after 24h running the new model less code I think I can post some 
> data:
>
> First of all I'll explain my application archtecture:
>
> I have a cloud server gattering information from around 150 gps on some 
> asserts. Each assert sends information every 30s, and some sends additional 
> reading information, wich give me a total arround 150k request/day. This 
> cloud server is integrated with appengine trought a REST API, speaching 
> Json to each other.
>
> Before the model less refactor I had the following status:
> *Current Load [image: 
> help]
> *URI Req/SeccurrentRequestslast 6 hrsRuntime MCycleslast hrAvg Latency
> /main/queues/position
> 1.248.78K3511200ms
> /main/api/position
> 0.944.37K267600 ms
> As you can see, I have controllers, the /api/ receives a call from the 
> cloud server and enqueues a process request on appengine (this is a very 
> simple controller, no data processing at all), and the /queues/ wich 
> actualy process the data, make some inserts/updates and handle the memcache.
>
> After the refactor:
>
> *Current Load [image: 
> help]
> *URI Req/SeccurrentRequestslast 6 hrsRuntime MCycleslast hrAvg Latency
> /main/queues/position
> 1.149.34K180404 ms
> /main/api/position
> 0.944.80K78139 ms
> Im only posting the position URL becouse its the most complex and most 
> hitted.
>
> In comparsion, the Django project (same logic, I have it still runing 
> while the web2py one is not ready):
>
> *Current Load [image: 
> help]
> *URI Req/SeccurrentRequestslast 6 hrsRuntime MCycleslast hrAvg Latencylast 
> hr
> /api/1.0/position
> 0.850.13K92406 ms
> On the django version I didnt had the queue yet, so this one URL proccess 
> the request at all.
>
> Final toughts are, after a model less aproch, I reached half of the 
> performance from django (still, some parts of the code are sightly 
> diferent, and a lot more Json conversion and memcache is used in favour of 
> reducing datastore access, wich can explain the loss on processing 
> performance). Also, after the model less aproch, compared to web2py it 
> self, I got a huge performance gain, and expect a solid cost reduction 
> (I'll post the cost reduction latter, when appengine consolidates the 
> billing).
>
> Thanks you all for sharing your toughts.
>
> On Tuesday, August 7, 2012 6:56:15 PM UTC-3, Massimo Di Pierro wrote:
>>
>> Please share you benchmarks when you think you are done.
>>
>> On Tuesday, 7 August 2012 14:29:51 UTC-5, Fe

[web2py] Re: Small bug?

2012-08-08 Thread Massimo Di Pierro
Fixed in trunk, although I have problems pushing to github this morning.

On Wednesday, 8 August 2012 01:06:09 UTC-5, lyn2py wrote:
>
> Correction! 
>
> Good news - the form submission works again.
>> However, the form%20accepted is not resolved, 
>>
>
> The good news is correct and the form%20accepted is resolved.
> Previously it didn't work because I downloaded a zip instead of cloning 
> git. 
> It works after I clone git.
>  
>
>> and also the member welcome at the top became: Logout | | PasswordProfile
>>
>
> This part of the post is still true.
> I tested this on the new welcome app and the bug in formatting is still 
> there.
>
> On Wednesday, August 8, 2012 1:52:20 PM UTC+8, lyn2py wrote:
>>
>> I updated to the latest version of web2py.js
>>
>> Good news - the form submission works again.
>> However, the form%20accepted is not resolved, 
>> and also the member welcome at the top became: Logout | | PasswordProfile
>>
>> On Wednesday, August 8, 2012 11:36:51 AM UTC+8, Anthony wrote:
>>>
>>> Yes. Massimo, I think 
>>> http://code.google.com/p/web2py/source/detail?r=65caec4dae5f7c971d406beb0eb3b32f471d84a4
>>>  broke 
>>> Ajax form submission.
>>>
>>> Anthony
>>>
>>> On Tuesday, August 7, 2012 11:20:44 PM UTC-4, lyn2py wrote:

 I've discovered a difference between the previous and the new is the 
 form submission.

 The old version post has parameters 
 for application/x-www-form-urlencoded.
 The new version post has no parameters. 
 So it seems that the form was not POSTed at all?


 On Wednesday, August 8, 2012 11:06:53 AM UTC+8, lyn2py wrote:
>
> Ok, I found web2py.js. It is in the static folder of the app.
> I took the new one from welcome app and replaced the one in my app.
>
> Now my code wouldn't work (my form was not processed). I'm still 
> trying to find out why. Any pointers will be helpful. Thanks.
>
> On Wednesday, August 8, 2012 9:22:23 AM UTC+8, Anthony wrote:
>>
>> I cannot reproduce the problem. Do you have the absolutely latest 
>> trunk, including the latest web2py.js?
>>
>> Anthony
>>
>> On Tuesday, August 7, 2012 5:16:06 PM UTC-4, lyn2py wrote:
>>>
>>> My code is simple
>>>
>>> form=SQLFORM(db.category)
>>> if form.process().accepted:
>>> response.flash = 'form accepted'
>>> elif form.errors:
>>> response.flash = 'form has errors'
>>> return dict(form=form)
>>>
>>> views is using generic.load to LOAD into a dialog via ajax.
>>>
>>> I'm using the latest trunk.
>>> 
>>>
>>> On Wednesday, August 8, 2012 4:51:56 AM UTC+8, Anthony wrote:

 Are you using trunk (if not, can you try it -- including the trunk 
 version of web2py.js)? Can you show your code?

 Anthony

 On Tuesday, August 7, 2012 4:21:16 PM UTC-4, lyn2py wrote:
>
> Spotted a small bug in response.flash:
>
> Normally when we submit a form, response.flash will appear "form 
> accepted"
> However if it is a form submitted within dialog 
> box, response.flash will appear "form%20accepted"
>
>
>
>
>> On Wednesday, August 8, 2012 11:36:51 AM UTC+8, Anthony wrote:
>>>
>>> Yes. Massimo, I think 
>>> http://code.google.com/p/web2py/source/detail?r=65caec4dae5f7c971d406beb0eb3b32f471d84a4
>>>  broke 
>>> Ajax form submission.
>>>
>>> Anthony
>>>
>>> On Tuesday, August 7, 2012 11:20:44 PM UTC-4, lyn2py wrote:

 I've discovered a difference between the previous and the new is the 
 form submission.

 The old version post has parameters 
 for application/x-www-form-urlencoded.
 The new version post has no parameters. 
 So it seems that the form was not POSTed at all?


 On Wednesday, August 8, 2012 11:06:53 AM UTC+8, lyn2py wrote:
>
> Ok, I found web2py.js. It is in the static folder of the app.
> I took the new one from welcome app and replaced the one in my app.
>
> Now my code wouldn't work (my form was not processed). I'm still 
> trying to find out why. Any pointers will be helpful. Thanks.
>
> On Wednesday, August 8, 2012 9:22:23 AM UTC+8, Anthony wrote:
>>
>> I cannot reproduce the problem. Do you have the absolutely latest 
>> trunk, including the latest web2py.js?
>>
>> Anthony
>>
>> On Tuesday, August 7, 2012 5:16:06 PM UTC-4, lyn2py wrote:
>>>
>>> My code is simple
>>>
>>> form=SQLFORM(db.category)
>>> if form.process().accepted:
>>> response.flash = 'form accepted'
>>> elif form.errors:
>>> response.flash = 'form has errors'
>>> return dict(form=form)
>>>
>>> views is using generic.load to LOAD into a dialog via ajax.
>>>
>>> I'm using the latest trunk.
>>> 
>>>
>>> On Wednesday, Augu

[web2py] Re: How to keep database connection alive ?

2012-08-08 Thread Massimo Di Pierro
Normally you would do

db = DAL('sqlite://storage.sqlite',pool_size=10)

where 10 is the max number of connections to keep alive and to be recycled 
across multiple requests.
I am not sure how this interact with scheduler.

On Wednesday, 8 August 2012 01:59:06 UTC-5, Amit wrote:
>
>
> Hi,
> I am using SQlite database for my web2py application, I have to keep the 
> same db instance which is created at first time request comes to model db.py
>
>
> db = DAL('sqlite://storage.sqlite')
>
> database connection is getting closed once request is completed so I am 
> not able to use the "db" for some background process like purging the 
> records every day so can anyone suggest me the proper way to keep the 
> database connection alive irrespective of request?
>
> Scenario:
> 1. when first time request made , db connection is established, I need to 
> keep this connection alive
> 2. One background scheduler running continuously to check the records in 
> db and purge it based on some condition.
>
> Problem facing:
> when first request made and get fulfilled, database connection is getting 
> closed because of that scheduler is not able to use the db instance and 
> start throwing error "Cannot operate on a closed database." every time when 
> it tries to execute the job.So I need to keep the "db"instance connected to 
> db , how can it be achieved?

-- 





[web2py] Re: register form and service conditions acceptance

2012-08-08 Thread Marco Prosperi

thank you for pointing that out. In this form it works (I've forced id=999 
for PluginMModal in user.html)

_onclick="jQuery('#999').fadeIn(); return false'


On Wednesday, August 8, 2012 2:00:10 PM UTC+2, Anthony wrote:
>
> auth.settings.extra_fields['auth_user']= [
>>   Field('accept_privacy','boolean',default=False,label=DIV('click me!', 
>> _onclick='jQuery(#%s).fadeIn(); return false' % request.cid))]
>>
>
> I'm not sure about the details of pluginMModal or whether this is the only 
> problem, but the jQuery selector should be in quotes:
>
> _onclick='jQuery("#%s").fadeIn(); return false' % request.cid
>
> Anthony
>

-- 





Re: [web2py] update_or_insert() inserting id=None

2012-08-08 Thread vinicius...@gmail.com

Thanks Richard. That's not necessary.

I just found out my sqlite table was corrupted. By some reason ID field 
was not created as autoincrement.


I dropped the table and recreated it. Now it's working fine.

Thank you.

--
Vinicius Assef


On 08/08/2012 11:35 AM, Richard Vézina wrote:

Open an issue on google code!

Which web2py version?

Richard

On Wed, Aug 8, 2012 at 10:10 AM, vinicius...@gmail.com
 mailto:vinicius...@gmail.com>> wrote:

Hi folks.

I'm facing a problem with table.update_or_insert().

I have: my_tab.update_or_insert(my___tab.name
==my_name, name=my_name, phone=my_phone)

When the search condition is not satisfied (i.e no records found) a
new record with id=None is inserted in my_tab. The action is
correct, but id shouldn't be None.

Am I doing something wrong or is it a bug?

--
Vinicius Assef

--




--





--





[web2py] Re: Search in Web2Py

2012-08-08 Thread Massimo Di Pierro
I am considering adding Whoosh support in DAL

On Tuesday, 7 August 2012 23:52:48 UTC-5, Anthony wrote:
>
> There's nothing built in (would be nice, though), but web2py should work 
> fine with any standard search functionality (e.g., SQLite and Postgres full 
> text search, Whoosh, Sphinx, Solr, ElasticSearch, Searchify, etc.).
>
> Anthony
>
> On Tuesday, August 7, 2012 11:27:51 PM UTC-4, Mike Girard wrote:
>>
>> I notice that there is no search box on the main web2py site.  The search 
>> on the book site is somewhat unorthodox in that it only provides links 
>> where the search term is located but does not show you where. Does web2py 
>> have a robust, conventional search utility? If not, what is the prescribed 
>> method for getting around this? 
>>
>>

-- 





Re: [web2py] update_or_insert() inserting id=None

2012-08-08 Thread Richard Vézina
Open an issue on google code!

Which web2py version?

Richard

On Wed, Aug 8, 2012 at 10:10 AM, vinicius...@gmail.com <
vinicius...@gmail.com> wrote:

> Hi folks.
>
> I'm facing a problem with table.update_or_insert().
>
> I have: my_tab.update_or_insert(my_**tab.name ==my_name,
> name=my_name, phone=my_phone)
>
> When the search condition is not satisfied (i.e no records found) a new
> record with id=None is inserted in my_tab. The action is correct, but id
> shouldn't be None.
>
> Am I doing something wrong or is it a bug?
>
> --
> Vinicius Assef
>
> --
>
>
>
>

-- 





Re: [web2py] Redirect to requested function

2012-08-08 Thread Jonathan Lundell
On 8 Aug 2012, at 3:10 AM, Annet  wrote:
> My application is completely nodeID driven, so all front end function run the 
> following test:
> 
> if  not len(request.args) or request.args(0)!=session.id:
> redirect(URL('addressbook','router',args=request.args(0)))

If you can identify your front-end functions, why not just rewrite 
request.{controller,function} here?

if request.args(0) != session.id:
request.controller = 'addressbook'
request.function = 'router'

(Minor point: if len(request.args) is 0, then request.args(0) is None.)

> 
> 
> This is the router function:
> 
> def router():
> if not len(request.args):
> session.flash='Aan de URL ontbreken argumenten. Formuleer een 
> zoekopdracht. ' + response.flash_form
> redirect(URL('addressbook','index'))
> else:  
> 
> session.organization=session.address=session.telecom=session.account=None
> session.id=request.args(0)
> 
> account=db(db.NodeAccount.nodeID==session.id).select(db.NodeAccount.ALL).first()
> if account:
> if account.statusID!=1:
> generateContact(session.id)
> redirect(URL('card',args=session.id))
> elif account.accountID==BASICACCOUNTID:
> session.account=BASICACCOUNTID
> generateContact(session.id)
> redirect(URL('vcard',args=session.id))
> elif account.accountID==ADVANCEDACCOUNTID:
> session.account=ADVANCEDACCOUNTID
> generateContact(session.id)
> redirect(URL('site','index',args=session.id))
> elif account.accountID==BASICCONNECTORACCOUNTID:
> session.account=BASICCONNECTORACCOUNTID
> generateConnectorContact(session.id)
> redirect(URL('vconnector',args=session.id))
> elif account.accountID==ADVANCEDCONNECTORACCOUNTID:
> session.account=ADVANCEDCONNECTORACCOUNTID
> generateConnectorContact(session.id)
> redirect(URL('connector','index',args=session.id))
> else:
> generateContact(session.id)
> redirect(URL('card',args=session.id))
> return None
> 
> In case request.args(0)!=session.id is True instead of redirecting to a 
> predetermined function I'd like to redirect to the function that redirected 
> to the router. How do I code this?

I'm not following your requirement here. args(0)!=session.id is your condition 
for redirecting to the router, right?

-- 





[web2py] update_or_insert() inserting id=None

2012-08-08 Thread vinicius...@gmail.com

Hi folks.

I'm facing a problem with table.update_or_insert().

I have: my_tab.update_or_insert(my_tab.name==my_name, name=my_name, 
phone=my_phone)


When the search condition is not satisfied (i.e no records found) a new 
record with id=None is inserted in my_tab. The action is correct, but id 
shouldn't be None.


Am I doing something wrong or is it a bug?

--
Vinicius Assef

--





Re: [web2py] Implementing a messaging system

2012-08-08 Thread Bruno Rocha
did you see the messaging plugin?

web2py.com/plugins

http://zerp.ly/rochacbruno
Em 08/08/2012 01:58, "shartha"  escreveu:

>
> Hi, I'd like to implement a messaging system (between the users of the
> website), and I need help to implement it. The way I've done it is to
> create a message table that has fields for the sender, receiver, subject,
> body, two boolean fields that shows whether the sender or the receiver have
> deleted the message (such that it's not shown to them). This is not quite
> working. I am thinking there must be a better way to do it, or somebody
> might have already implemented something. The table is defined as:
>
> db.define_table('messages',
> Field('recipient_id',db.auth_user, label='To'),
> Field('subject','string'),
> Field('body','string'),
> Field('date','datetime'),
> Field('sender_id',db.auth_user),
> Field('sender_deleted','boolean'),
> Field('recipient_deleted','boolean'),
> )
>
> and as it obvious, some of the fields are values from the user database.
> Could somebody tell me if I am on the right track or if changes need to be
> made to my structure?
>
> Thanks!
>
> --
>
>
>
>

-- 





Re: [web2py] Re: web2py 2.0 almost done

2012-08-08 Thread Johann Spies
On 8 August 2012 15:36, Anthony  wrote:

> As I recall, the autocomplete doesn't work at all in IE (at least not < 9,
> not sure about 9). That's why I was thinking we should switch to a
> third-party client-side widget.


This was on LInux and with Firefox.

I would appreciate any solution what works!.  The suggest_widget works in
most instances for me, but in this case it also have problems.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





Re: [web2py] Re: web2py hangs while creating the mysql tables

2012-08-08 Thread Yarin
@Aurelijus- If you're dealing with foreign key errors you may have to clean 
the constraints up manually in MySQL- It's actually pretty easy to corrupt 
the foreign key constraints with web2py's db definitions, and cleanup is a 
bitch if you don't know exactly what to do. See my post on this, and follow 
the link within: 
https://groups.google.com/d/msg/web2py/ztQLASakiYg/UtT8Yi3zH1sJ



On Wednesday, August 8, 2012 8:22:18 AM UTC-4, Aurelijus Useckas wrote:
>
> Thanx Yarin, I've fixed this one. There are no more reserved words in the 
> table or field definitions. Nevertheless it returns an error 1005 / 150, 
> which refer to: "table creation failed because a foreign key constraint 
> was not correctly formed".
> If I get rid of any refering fields it works fine. Somehow the mysql 
> doesn't recognise/understand the refering definitions.
>  
> On Wed, Aug 8, 2012 at 4:08 AM, Yarin >wrote:
>
>> Massimo- steps to reproduce (using rocket/mysql/OSX):
>>
>> 1) In db.py pointing to MySQL:
>>
>> db.define_table('bad',
>> Field('field_a', 'string'),
>>  Field('long', 'string')
>> )
>>
>> 2) Make a request. 
>>
>> The app will error out and SQL syntax error will be ticketed.
>>
>> 3) Make another request. 
>>
>> App requests now hang. Other apps are semi-hung (it's strange- i could 
>> open example app, but not others). App admin still works (?). The web2py 
>> process cannot be terminated and must be killed.
>>
>> (I brush up against this whenever I do something MySQL doesn't like- 
>> altering two tables at once in db.py, etc...)
>>
>> On Tuesday, August 7, 2012 5:42:30 PM UTC-4, Massimo Di Pierro wrote:
>>
>>> can you reproduce. If this is a web2py problem, it needs to be fixed. 
>>>
>>> On Tuesday, 7 August 2012 10:41:27 UTC-5, Yarin wrote:
>>>
 Think it actually does return a non-specific SQL syntax error that gets 
 ticketed by web2py- but web2py never goes to an error screen and the 
 browser just hangs- if i recall..

 On Tuesday, August 7, 2012 11:30:37 AM UTC-4, Massimo Di Pierro wrote:

> Damn MySQL. It should not hang, it should return a operationalerror.
>
>
>
> On Tuesday, 7 August 2012 10:03:44 UTC-5, Yarin wrote:
>
>> Change the name of in your Field('long') field in maps table - it's 
>> a reserved keyword in MySQL and will cause it to hang.
>>
>> On Tuesday, August 7, 2012 10:57:07 AM UTC-4, Aurelijus Useckas wrote:
>>
>>> Here it is:
>>>
>>> db.define_table('tag',
>>> Field('tag', notnull=True, unique=True),
>>> format='%(tag)s')
>>>
>>> db.define_table('city',
>>> Field('name', notnull=True, unique=True),
>>> format='%(name)s')
>>> 
>>> db.define_table('maps',
>>> Field('name'),
>>> Field('last_name'),
>>> Field('long'),
>>> Field('lat'))
>>> 
>>> 
>>> db.define_table('asoc',
>>> Field('name', label='Pavadinimas', unique=True),
>>> Field('City', 'list:reference city', label='Miestas'),
>>> Field('address', label='Adresas'),
>>> Field('www'),
>>> Field('tel'),
>>> Field('fax'),
>>> Field('email'),
>>> Field('President', label='Asociacijos prezidentas'),
>>> Field('CEO', label='Asociacijos generalinis'),
>>> Field('CEO_tel', label='Generalinio tel.'),
>>> Field('CEO_email', label='Generalinio email'),
>>> Field('CEO_mob', label='Generalinio mobilus'),
>>> Field('Pres_tel', label='Prezidento tel.'),
>>> Field('Pres_email', label='Prezidento email'),
>>> Field('Pres_mob', label='Prezidento mobilus'),
>>> Field('submited_at', 'datetime', default=request.now, 
>>> writable=False, readable=False),
>>> Field('updated_at', 'datetime', default=request.now, 
>>> update=request.now, writable=False, readable=False),
>>> Field('submited_by', db.auth_user, default=auth.user_id, 
>>> writable=False, readable=False),
>>> Field('updated_by', db.auth_user, update=auth.user_id, 
>>> writable=False, readable=False),
>>> format='%(name)s')
>>>
>>> db.asoc.email.requires=IS_**EMPTY_OR(IS_EMAIL())
>>> db.asoc.CEO_email.requires=IS_**EMPTY_OR(IS_EMAIL())
>>> db.asoc.Pres_email.requires=**IS_EMPTY_OR(IS_EMAIL())
>>> db.asoc.name.requires=IS_NOT_**EMPTY()
>>>
>>> db.define_table('countries',
>>> Field('Country', notnull=True, unique=True),
>>> Field('latitude', readable=True, writable=False),
>>> Field('longitude', readable=True, writable=False),
>>> format = '%(Country)s'
>>> )
>>>
>>> def horizontal_checkboxes(f,v):
>>> horizontal_widget = SQLFORM.widgets.checkboxes.**
>>> widget(f,v,cols=4)
>>> return locals()
>>>
>>> db.define_table('company',
>>> Field('title', label='Pavadinimas', unique=True),
>>> Field('CEO', label='Generalini

Re: [web2py] Re: web2py 2.0 almost done

2012-08-08 Thread Anthony
On Wednesday, August 8, 2012 5:30:10 AM UTC-4, lyn2py wrote:
>
> Does this mean that if I uncomment the jquery-ui in layout.html, the 
> autocomplete will be working even on IE?
>

No, jQuery UI autocomplete is not implemented with web2py.

Anthony 

-- 





Re: [web2py] Re: web2py 2.0 almost done

2012-08-08 Thread Anthony
As I recall, the autocomplete doesn't work at all in IE (at least not < 9, 
not sure about 9). That's why I was thinking we should switch to a 
third-party client-side widget.

Anthony

On Wednesday, August 8, 2012 8:53:00 AM UTC-4, Johann Spies wrote:
>
> On Tuesday, 7 August 2012 17:23:34 UTC+2, Massimo Di Pierro wrote:
>>
>> Has anybody worked out a good CSS for this? I do not think web2py ever 
>> shipped with css for the autocomplete widget.
>>
>> On Tuesday, 7 August 2012 07:56:57 UTC-5, Johann Spies wrote:
>
>  
>
>> The autocomplete widget does look good in Firefox and Chrome on Linux.  
>>> See the attached screenshot. 
>>>
>>>
> I have now determined that my screenshot does not always apply.  A few 
> strange things happened ago.
>
> 1. Today's trunk code made all autocomplete widgets (suggest_widget 
> included) stop working at all.  It seems that no Ajax calls were working.  
> So I restored a backup of yesterday's code and  that restored the ajax 
> functionality.
>
> 2. The following form illustrates something that does not make sense at 
> all. 
>
> Two problems arise out of it:  
> *  The css does not work at all on the first field (see screenshots 1 and 
> 3).
> *   There are two tables (akb_journal, akb_articles) which both have a 
> 'title' field which is a normal string.  The first field's autocomplete 
> (and this is the case with both the suggest_widget and the autocomplete 
> widget) does the lookup in the wrong table. In both cases values from the 
> akb_journal.title field gets returned.  The firstand fourth screenshots 
> illustrate this.
>
> The second field was added as a debugging mechanism:  From the same table 
> (akb_articles) I use another field (authors) and in this case both the css 
> and the lookup values are fine as the second screenshot shows.
>
> The third does the lookup in the correct table, but the css is not 
> functioning in this when I use the Autocomplete widget.  See third 
> screenshot. 
>
> form=SQLFORM.factory(Field('artikel', label = T('Article'),
>widget = SQLFORM.widgets.autocomplete(
> request,
>  db.
> akb_articles.title,
> 
>  id_field = db.akb_articles.uuid,
>  
> orderby = db.akb_articles.title,
> 
>  limitby = (0, 20), min_length = 2)),
>  Field('x', label = T('authors'),
>widget = SQLFORM.widgets.autocomplete(
> request,
>  db.
> akb_articles.authors,
> 
>  id_field = db.akb_articles.uuid,
>  
> orderby = db.akb_articles.authors,
> 
>  limitby = (0, 20), min_length = 2)),
>  Field('skrywer', label = T('author'),
>widget= SQLFORM.widgets.autocomplete(
> request,db.akb_authors.name,
>   id_field 
> = db.akb_authors.uuid,
>   orderby 
> = db.akb_authors.name,
>   limitby 
> = (0, 20), min_length = 2)))
>
>
> I would appreciate it if someone can clear up my confusion about what is 
> going on here.
>
> Regards
> Johann
>
>

-- 





Re: [web2py] combine Autocomplete widget and SELECT_OR_ADD_OPTION widget

2012-08-08 Thread Richard Vézina
There is no slice... I didn't have time, but I can help you as much as I
can here.

Notice that there seems to have a new implementation of the autocomplete
widget coming with the new web2py 2.0, so I will have to look at the code
and implement again the add option to it.

Richard

On Tue, Aug 7, 2012 at 12:46 AM, lyn2py  wrote:

> Hi Richard, I'm interested in this, how can I get this web2py slice?
>
>
> On Wednesday, May 30, 2012 3:44:20 AM UTC+8, Richard wrote:
>>
>> Can't link the app too big (thanks to google 4 meg max :( )...
>>
>> Ask me in private I will send you the app directly.
>>
>> Richard
>>
>> On Tue, May 29, 2012 at 3:40 PM, Richard Vézina <
>> ml.richard.vez...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> Here a demo app, hope it will help for now... It the best I can do now.
>>>
>>> Try to understand it carefully, if you can make works the slice about
>>> SelectOrAddOption, you will be able to adapt my **
>>> AutocompleteWidgetSelectOrAddO**ption to your needs. So follow the
>>> slice tutorial carefully and transpose to the need widget. Only the part
>>> about *"add" function* that you don't initialize same way, you just
>>> pass everything to the widget like this : AutocompleteWidgetSelectOrAddO
>>> **ption(request, db.table2.table2field1,
>>> id_field=db.table2.id, limitby=(0,10), min_length=2,
>>> form_title=T('Add new table2 item'), controller="tables",
>>> *function="add_table2_item"*, button_text = T('Add new'))
>>>
>>> There is only one error I can't get rid of is that Add Option trigger a
>>> not belong field error on update form... I don't have this error in my own
>>> app so I should be minor, I will try to find why it not working. I thought
>>> that it could be because of similar name between table so I rename form
>>> field1 to table1field1 and table2field1, not working neither. Will try to
>>> find the origin of the issue.
>>>
>>> NOTE : It base on Autocomplete available in web2py 1.99.4 and it should
>>> works (except the error I am talking about) with web2py 1.99.4.
>>>
>>> TODO : Look for change that Manuele did to autocomplete widget and use
>>> this version of the widget to merge the SelectOrAddOption.
>>>
>>> Richard
>>>
>>>
>>> On Tue, May 29, 2012 at 1:19 PM, Richard Vézina <
>>> ml.richard.vez...@gmail.com> wrote:
>>>
 Ok, I will work on this to allow possible user to have access to this
 ressource.

 I will clean the code a bit and write a tutorial step by step with the
 element to adapt to your context.

 Give me a couples of hours.

 Richard


 On Tue, May 29, 2012 at 6:44 AM, Johann Spies 
 wrote:

> On 25 April 2012 23:48, Richard Vézina wrote:
>
>
>
>> Hope it works for you Johann.
>>
>
> Unfortunately I did not have any success with this recipe.  I can get
> the select_or_add widget working but not this one.
>
> Thanks for your trouble anyhow.
>
> Regards
> Johann
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>
>

>>>
>>  --
>
>
>
>

-- 





Re: [web2py] Again: how redirect without propagate the .load extension?

2012-08-08 Thread Anthony
Attached is a patch that enables client-side full-page redirects from Ajax 
requests. It alters the redirect() function in http.py as well as adding an 
event handler in web2py.js. With it, in a function called via Ajax, you can 
do:

def my_ajax_function():
if some_condition:
redirect(URL('default', 'other_function', extension=False), type=
'client')
return dict()

In that case, redirect does not raise an HTTP(303). Instead, it raises an 
HTTP(200) and sets a special "web2py-redirect-location" response header 
with the redirect URL. On the client side, a jQuery.ajaxSuccess event 
handler checks for that header on every successful Ajax request, and if the 
header is there, it sets window.location to that URL, which loads the full 
page in the browser window. Note, if redirecting from a function called 
with the .load extension, you probably want to set extension=False when 
constructing the redirect URL so the .load extension is not propagated to 
the redirect.

Eventually, we might consider adding a type='internal' option to the 
redirect() function, which could generate a new internal request to the 
redirect URL rather than sending a 303 to the server (this would have 
nothing to do with Ajax -- just a way of speeding up regular server-side 
redirects when you don't need the browser to receive a new URL with the 
redirect).

Anthony

On Wednesday, August 8, 2012 4:58:44 AM UTC-4, mweissen wrote:
>
> Any solution so far?
>
> 2012/7/29 Martin Weissenboeck >
>
>> Thank you!
>>
>>
>> 2012/7/28 Massimo Di Pierro >
>>
>>> I will take a patch. ;-)
>>>
>>>
>>> On Friday, 27 July 2012 16:54:51 UTC-5, mweissen wrote:

 Hallo Johann,

 I have tried your proposal - yes, this "workaround" does the job and I 
 think I will use it.
 But I am surprised that there is not simple solution. Or does nobody 
 else want to get rid the "load"?

 2012/7/27 Johann Spies >

> Hallo Martin, 
>
> In stead of redirecting, I am using this script in the view:
>
> 
> jQuery(document).ready(**function() {
>   
> jQuery($(":input:submit:last")**.addClass('gaanvoort'));
>
>   jQuery($("input.gaanvoort").**click(
>   function() {
>   window.location = 
> "/init/articles/add_article";
>
>
>
>   }));
>
>
>
>});
>  
>  
> and then use session variables on the destination.
>
> Regards
> Johann
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>


-- 



diff -r 1166e3cd410d applications/welcome/static/js/web2py.js
--- a/applications/welcome/static/js/web2py.js	Tue Aug 07 19:53:42 2012 -0500
+++ b/applications/welcome/static/js/web2py.js	Wed Aug 08 09:00:05 2012 -0400
@@ -44,6 +44,12 @@
   doc.on('keyup', 'input.double, input.decimal', function(){this.value=this.value.reverse().replace(/[^0-9\-\.,]|[\-](?=.)|[\.,](?=[0-9]*[\.,])/g,'').reverse();});
   var confirm_message = (typeof w2p_ajax_confirm_message != 'undefined') ? w2p_ajax_confirm_message : "Are you sure you want to delete this object?";
   doc.on('click', "input[type='checkbox'].delete", function(){if(this.checked) if(!confirm(confirm_message)) this.checked=false;});
+  doc.ajaxSuccess(function(e, xhr) {
+var redirect=xhr.getResponseHeader('web2py-redirect-location');
+if (redirect != null) {
+  window.location = redirect;
+};
+  });
 };
 
 jQuery(function() {
diff -r 1166e3cd410d gluon/http.py
--- a/gluon/http.py	Tue Aug 07 19:53:42 2012 -0500
+++ b/gluon/http.py	Wed Aug 08 09:00:05 2012 -0400
@@ -119,13 +119,16 @@
 return self.message
 
 
-def redirect(location, how=303):
+def redirect(location, how=303, type='http'):
 if not location:
 return
 location = location.replace('\r', '%0D').replace('\n', '%0A')
-raise HTTP(how,
-   'You are being redirected here' % location,
-   Location=location)
+if type == 'client':
+raise HTTP(200, **{'web2py-redirect-location': location})
+else:
+raise HTTP(how,
+   'You are being redirected here' % location,
+   Location=location)
 
 
 


  1   2   >