[web2py] Fields and button in single row in SQLFORM Factory

2017-07-30 Thread Amit Kumar Modak
Hello,

I have created a form using Form Factory, which has two fields.

form=SQLFORM.factory(Field('Name','string'), Field('Age', 'number'))


Is there any by which both the fields and the submit button can be made to 
appear in a single row?

Thanks,
Amit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: passing additional variables in selectable function of sqlform.grid

2017-07-23 Thread Amit Kumar Modak
Thanks Anthony.

I tried that as well, but it didn't work.

Amit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: passing additional variables in selectable function of sqlform.grid

2017-07-22 Thread Amit Kumar Modak
I tried this but it didn't work.

 form=SQLFORM.grid(db.Student,
  editable=False,
  deletable=False,
  showbuttontext=False,
  selectable = [('Assign', lambda ids : assign(ids, 
form))],
  csv=False)

form.append(SQLFORM.factory(Field('Class', 'reference Class', 
requires=IS_IN_DB(db, db.Class.id, '%(Class)s')))

submit = form.element('input',_type='submit', _value='Submit')
submit['_style'] = 'display:none;'

return dict(form=form)

def assign(ids, form):
for id in ids:
db.StudentClass.insert(Class=form.vars.Class, Student=id)

Any help?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] passing additional variables in selectable function of sqlform.grid

2017-07-21 Thread Amit Kumar Modak
Hello,

I have created a form with sqlform.grid and added an additional 
sqlform.factory to the same form.
The sqlform.grid has a selectable function where I want to pass the value 
of sqlform.factory fields.

Please suggest how this can be done.

Regards,
Amit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Customising Calendar widgets in Start Date and End date of SmartGrid

2017-01-14 Thread Amit Kumar Modak
Hello,

Has anybody solution to this?

Regards,
Amit

On Friday, January 13, 2017 at 3:46:14 PM UTC+5:30, Amit Kumar Modak wrote:
>
> Hello,
>
> I am using Smartgrid in which there are two date fields Start Date and End 
> Date.
> Is it possible to make in Start Date field Calendar widget only dates 
> ahead of today enabled and in End Date only dates ahead of date selected in 
> Start Date is enabled.
>
>
> Regards,
> Amit
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Customising Calendar widgets in Start Date and End date of SmartGrid

2017-01-13 Thread Amit Kumar Modak
Hello,

I am using Smartgrid in which there are two date fields Start Date and End 
Date.
Is it possible to make in Start Date field Calendar widget only dates ahead 
of today enabled and in End Date only dates ahead of date selected in Start 
Date is enabled.


Regards,
Amit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] global name 'web2py_extract' is not defined

2016-12-09 Thread Amit Kumar Modak
 The following line of code is giving error 

global name 'web2py_extract' is not defined



response.flash=web2py_extract('month', db.Player.DateOfBirth)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Difference of two date field in years

2016-12-09 Thread Amit Kumar Modak
How to get the difference of two date field in years.
dateutil.relativedelta.relativedelta is not working as it is not able to 
recognise date fields as date.

Thanks,
Amit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Non-Editable field in SQLFORM

2016-12-09 Thread Amit Kumar Modak
Hello,

How can I make a field non-editable in SQLFORM, while it should be allowed 
to take a value in insert.


Regards,
Amit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] web2py framework as iOS app backend

2015-02-25 Thread Amit Kumar
Hi,

We are deciding backend layer for our iOS and Android mobile app. The app 
will interact with MySQL DB via REST JSON service. The implementation is 
not really complex.

I wanted to check if web2py is a good option for our app. We have been 
looking at multiple python framework - Django, Flask and Web2Py... based on 
the documents it appears that web2py is a good fit. I wanted to check in 
the group if anyone has used web2py for iOS backend. These are going to be 
native iOS and Android apps.

thanks for your time.

amit

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Cassandra Support

2013-10-16 Thread Amit Saharana
Hi, just for information, does web2py support Cassandra Database. I didn't 
get any specific information about it through search engines.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: Converting Field of a SQLFORM.grid to local timezone of a user.....

2013-02-12 Thread Amit
Can we use "represent" callback in case of hugh number of rows(lets say
2 or more rows is there in db), will it not be causing to slow down the
whole process, means, while converting utc time to target timezone's time
one by one for each row and then displayed to UI using SQLFORM.grid()?

Please share your thought because I am also using represent callback to
convert each row's utc time to target timezone:

db.table.datefield.represent = convert_time

where convert_time function will be calculating timezone for each row and
return it, so it will be called for each row, in my case it will called for
more than 2 rows.

So will it be an optimized way of achieving this functionality OR is there
any best optimal way of achieve this?

Please provide your suggestions.


On Wed, Feb 13, 2013 at 8:50 AM, Michael Beller  wrote:

> this stores dates in UTC but displays date in alternate timezone.  You can
> set the represent property based on a timezone stored in the users profile
> or derived from locale settings ...
>
> from pytz import timezone
> import pytz
>
> db.define_table('t_date',
> Field('f_name'),
> Field('f_datetime', type='datetime', default=request.utcnow),
> Field('f_utcdatetime', type='datetime', default=request.utcnow),
> migrate=True)
>
> db.t_date.f_datetime.represent = lambda value, row :
> pytz.UTC.localize(value).astimezone(timezone('US/Eastern'))
>
>
> I used information in the following two pages for help ...
>
>
> http://stackoverflow.com/questions/7065164/how-to-make-an-unaware-datetime-timezone-aware-in-python?lq=1
> http://pypi.python.org/pypi/pytz/
>
> On Tuesday, February 12, 2013 7:40:59 AM UTC-5, Michael Beller wrote:
>
>> I've also been researching and experimenting ...
>>
>> I've come to the conclusion to only store utc dates (e.g., using utcnow)
>> in the data base and then use .represent or other means to convert for
>> display.
>>
>> Most notably, use the putz python library ...
>>
>>
>> On Tuesday, February 12, 2013 1:58:26 AM UTC-5, rochacbruno wrote:
>>>
>>> I am on mobile now and I cant ellaborate a good code example, but I can
>>> give you a hint.
>>>
>>> db.table.datefield.represent = lambda value, row :
>>> value.strftime("%Y/%m/%d")
>>>
>>> grid = SQLFORM.grid(db.table)
>>>
>>> so grid will use the represent callback to display the data.
>>>
>>> following this example you can do
>>>
>>> def set_timezone(value, row):
>>>  return value. #do the calculation
>>>
>>> db.table.field.represent = set_timezone
>>> Em 12/02/2013 04:44, "newbie"  escreveu:
>>>

 On Tuesday, 12 February 2013 11:06:00 UTC+5:30, newbie wrote:
>
> Hi,
> I have a table x, with fields name,place,timezone_offset.And
> another table y ,having  field 'servertime',which **stor**es
> the current time of the server its fetching the values from.
>
>  db.define_table('x',Field('**nam**e'),Field('place'),Field('**time**
> zone_offset'))
> db.define_table('y',Field('**nam**e'),Field('ser**vertime'))
>

 User will set the timezone offset in table x, for a particular name.
 There is one thread continuously running in background in the server which
 will save the servertime as local time using datetime.datetime.now() in
 table y for the name.

 And finally this data displayed by using SQLFORM.grid on the UI.

 Problem facing:
 We have to convert the local time saved for the name field as per saved
 timezone_offset in x table and display on the grid without modifying
 anything on database level.
 It means suppose for name ='Alex'  timezone_offset was being saved as
 -5 in x table and suppose server running on different timezone lets say on
 +5.30 so for name Alex server will save the servertime in +5.30 format as
 it is the local time for the server but when it will be displayed on the
 grid servertime should first get converted to Alex timezone_offset which is
 set as -5 and then display on the grid.

 Can anyone please suggest me how can I achieved in web2py? Is there any
 way to achieve it using SQLFORM.grid()?

 Thanks.




>
>
  --

 ---
 You received this message because you are subscribed to the Google
 Groups "web2py-users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to web2py+un...@googlegroups.com.
 For more options, visit 
 https://groups.google.com/**groups/opt_out
 .



>>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" 

[web2py] How to use web2py confirmation form ?

2012-11-21 Thread Amit
Hi,
I have Delete button on SQLFORM.grid and upon clicking on it , it should 
popup confirmation dialog before deleting the records and once user click 
on OK , it should delete the records.
For that purpose I used web2py confirmation form but it is not working.

please check below the code :

def delete_records():
form = FORM.confirm('Are you sure, you want to delete the records?')

if form.accepted:
#delete records

else:
pass

redirect(URL('another_page'))

when I clicked on Delete button, delete_records() function is getting 
called but not popping up the confirmation form and control is always going 
to else part means form is not accepted.

can anyone please suggest me what am I doing wrong?

-- 





[web2py] Re: Set: no tables selected

2012-11-21 Thread Amit
Fixed :).

using smart_query:

db.smart_query([db.status],query).delete()

where query is in string format.

On Wednesday, 21 November 2012 15:23:44 UTC+5:30, Amit wrote:
>
> I have done slight changes in the code and its working for select() 
> statement but still facing problem in case of delete():
>
> code:
>
> def test():
> 
> query = request.vars['keywords']
> 
> if query:
> print query
> row =str(db(query).select(db.status.ALL))
> if row:
> print row
> redirect(URL('status'))
>
> In this case query string is : *status.id = "12"*
> So I am getting result properly, but problem is:
>  if I remove *db.status.ALL* from select() statement , it again gives the 
> same error : 
> * Set: no tables selected*
>
>
> Same applies for delete() statement, even for delete we can't specify the 
> database table name as a parameter like select().
>
>
>
> On Wednesday, 21 November 2012 12:01:08 UTC+5:30, Amit wrote:
>>
>> I have added button "Delete" beside Clear button on SQLFORM.grid and when 
>> user selects query and click on it , I am passing the query to my 
>> controller function and using regular expression I just prepending "db." 
>> and changing "=" to "==" and passing the query to the db() function but it 
>> throws SyntaxError : Set: no tables selected.
>>
>> Please check below the code:
>>
>> def status():
>> 
>> grid = SQLFORM.grid(db.status)
>> 
>> grid[0][1][1].components.append(TAG.a('Delete',_id="px-delete",\
>>   _class 
>> ="btn",_onclick="window.location 
>> = '" \
>>   + URL('default','test')+"?"+ "'+ 
>> $('#web2py_keywords').serialize();\
>>"))
>> 
>> return locals()
>>
>>
>> def test():
>> 
>> query = request.vars['keywords']
>> 
>> if query:
>> modfied_query = re.sub(r'(status)', r'db.\1', query)
>> final_query = re.sub(r'(=)', r'=\1', modfied_query) 
>>
>> row =db(final_query).select().first()
>> if row:
>> print row
>> redirect(URL('status'))
>>
>> here, status is the grid view where I added the Delete button and after 
>> query selection If I click button , I am able to get the query like 
>> status.id = "12", I changed it using regex to db.status.id == "12" and 
>> passing the final string to db() function , please check test() function.
>>
>> I am getting error on the below statement:
>>
>> *row **=db(final_query).select().first()*
>>
>> where "final_query" value will be db.status.id == "12".
>>
>> But if I use the same query like this:
>>
>> *row =db(db.status.id == "12").select().first()*
>>
>> it works fine.
>>
>> So not sure what I am doing wrong on the passing string as query.
>>
>>

-- 





[web2py] Re: Set: no tables selected

2012-11-21 Thread Amit
I have done slight changes in the code and its working for select() 
statement but still facing problem in case of delete():

code:

def test():

query = request.vars['keywords']

if query:
print query
row =str(db(query).select(db.status.ALL))
if row:
print row
redirect(URL('status'))

In this case query string is : *status.id = "12"*
So I am getting result properly, but problem is:
 if I remove *db.status.ALL* from select() statement , it again gives the 
same error : 
* Set: no tables selected*


Same applies for delete() statement, even for delete we can't specify the 
database table name as a parameter like select().



On Wednesday, 21 November 2012 12:01:08 UTC+5:30, Amit wrote:
>
> I have added button "Delete" beside Clear button on SQLFORM.grid and when 
> user selects query and click on it , I am passing the query to my 
> controller function and using regular expression I just prepending "db." 
> and changing "=" to "==" and passing the query to the db() function but it 
> throws SyntaxError : Set: no tables selected.
>
> Please check below the code:
>
> def status():
> 
> grid = SQLFORM.grid(db.status)
> 
> grid[0][1][1].components.append(TAG.a('Delete',_id="px-delete",\
>   _class 
> ="btn",_onclick="window.location 
> = '" \
>   + URL('default','test')+"?"+ "'+ 
> $('#web2py_keywords').serialize();\
>"))
> 
> return locals()
>
>
> def test():
> 
> query = request.vars['keywords']
> 
> if query:
> modfied_query = re.sub(r'(status)', r'db.\1', query)
> final_query = re.sub(r'(=)', r'=\1', modfied_query)   
>  
> row =db(final_query).select().first()
> if row:
> print row
> redirect(URL('status'))
>
> here, status is the grid view where I added the Delete button and after 
> query selection If I click button , I am able to get the query like 
> status.id = "12", I changed it using regex to db.status.id == "12" and 
> passing the final string to db() function , please check test() function.
>
> I am getting error on the below statement:
>
> *row **=db(final_query).select().first()*
>
> where "final_query" value will be db.status.id == "12".
>
> But if I use the same query like this:
>
> *row =db(db.status.id == "12").select().first()*
>
> it works fine.
>
> So not sure what I am doing wrong on the passing string as query.
>
>

-- 





[web2py] Set: no tables selected

2012-11-20 Thread Amit
I have added button "Delete" beside Clear button on SQLFORM.grid and when 
user selects query and click on it , I am passing the query to my 
controller function and using regular expression I just prepending "db." 
and changing "=" to "==" and passing the query to the db() function but it 
throws SyntaxError : Set: no tables selected.

Please check below the code:

def status():

grid = SQLFORM.grid(db.status)

grid[0][1][1].components.append(TAG.a('Delete',_id="px-delete",\
  _class 
="btn",_onclick="window.location 
= '" \
  + URL('default','test')+"?"+ "'+ 
$('#web2py_keywords').serialize();\
   "))

return locals()


def test():

query = request.vars['keywords']

if query:
modfied_query = re.sub(r'(status)', r'db.\1', query)
final_query = re.sub(r'(=)', r'=\1', modfied_query)
row =db(final_query).select().first()
if row:
print row
redirect(URL('status'))

here, status is the grid view where I added the Delete button and after 
query selection If I click button , I am able to get the query like 
status.id = "12", I changed it using regex to db.status.id == "12" and 
passing the final string to db() function , please check test() function.

I am getting error on the below statement:

*row **=db(final_query).select().first()*

where "final_query" value will be db.status.id == "12".

But if I use the same query like this:

*row =db(db.status.id == "12").select().first()*

it works fine.

So not sure what I am doing wrong on the passing string as query.

-- 





Re: [web2py] Re: Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-20 Thread Amit
Thanks Niphold :), Now its working fineyeah I do agree that I am not so
good in Javascript as I am having very less experience on web
development..but I am very sure that with the guidance of you people I will
definitely learn it fast :).


On Tue, Nov 20, 2012 at 4:33 PM, Niphlod  wrote:

>
>
> On Tuesday, November 20, 2012 10:19:25 AM UTC+1, Amit wrote:
>>
>> If I use A instead of button then its calling perfectly but i have to
>> show Delete as a button not as a link.
>>
>
> Style the A as a button. With bootstrap's included just add a class = btn .
>
>
>> Second observation: if I am adding Delete button/link beside Search and
>> Clear button, and if I click Query input field, its not showing query
>> filling fields(drop down menu,conditional fields, New,Close buttons etc...)
>>
>
> That's because you're not appending an element, you are replacing
> [0][1][1] with your own. Use append if you want to preserve what is there.
> grid[0][1][1].components.append(TAG.a('Delete',_id="px-delete",_class=
> "btn",_href=URL('test')))
>
>
>> And third point is : suppose I want to pass the selected query to
>> function "test", how can I do that?
>>
>
> _onclick="window.location = '" + URL('test') + "' +
> $('#web2py_keywords').serialize(); return false;")
>
> But dude, seriously, learn some javascript :-P
>
> --
>
>
>
>

-- 





Re: [web2py] Re: Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-20 Thread Amit
If I use A instead of button then its calling perfectly but i have to show
Delete as a button not as a link.
Second observation: if I am adding Delete button/link beside Search and
Clear button, and if I click Query input field, its not showing query
filling fields(drop down menu,conditional fields, New,Close buttons etc...)
And third point is : suppose I want to pass the selected query to function
"test", how can I do that?


On Tue, Nov 20, 2012 at 2:32 PM, Niphlod  wrote:

> whoopsy, did you try with a simple A instead of a button ?
> TAG.a('Delete',_id="px-**delete",_type="button",_href=U**RL('test'))
>
>
> On Tuesday, November 20, 2012 6:27:18 AM UTC+1, Amit wrote:
>>
>> Thanks Niphold for sharing the example code, but still it is not working
>> means upon clicking on the "Delete" button, it's not calling the test
>> function, Please see below the code:
>>
>>
>> def status():
>> grid = SQLFORM.grid(db.status)
>> grid[0][1][1].components = [
>>   TAG.button('Delete',_id="px-**delete",_type="button",_href=U**RL(
>> 'test'))
>> ]
>> return locals()
>>
>> def test():
>> db().select(db.status.id>0).de**lete()
>> db.commit()
>> redirect(URL('status'))
>>
>> And screenshot of the status page with Delete button:
>>
>>
>>
>> Please help me to find out what wrong I am doing in the code.
>>
>>
>>
>>
>> On Monday, 19 November 2012 20:48:49 UTC+5:30, Niphlod wrote:
>>>
>>> all the records ?
>>> if you need to execurte your "test()" function you just need the browser
>>> to "go" to that page. Let's assume that in your controller you have
>>>
>>> def index():
>>>  grid = grid(db.testtable)
>>>  grid[0][1][1].components = [
>>> TAG.button('testbutton', _id="px-delete",_type="button"**,_href=
>>> URL('test'))
>>>   ]
>>>
>>> def test():
>>> # delete all records of db.testtable
>>> db(db.testtable.id>0).delete()
>>> redirect(URL('index'))
>>>
>>>
>>> Assuming that:
>>> - you go to myapp/default/index and see the grid with the button
>>> (assuming the code fragment you posted works for adding a button, didn't
>>> test it).
>>> - press that button
>>> - the browser will go to the page myapp/default/test (the button was a
>>> normal link)
>>> - web2py will delete the table
>>> - and you'll be redirected back to your (now empty) grid.
>>>
>>> Is it clear ? Is this what you want to achieve ?
>>>
>>>  --
>
>
>
>

-- 





[web2py] Re: Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-19 Thread Amit
I simply have to delete the records from the table, but problem what I am 
facing is : if the function would not be get called then how will I achieve 
this?

On Monday, 19 November 2012 19:31:53 UTC+5:30, Niphlod wrote:
>
> now you're the one that needs explaining it further :P
> I assume that just going to the "test" function and return back would not 
> be enough ? (i.e. a simple _href=URL('test') on that button)
>
> On Monday, November 19, 2012 2:56:36 PM UTC+1, Amit wrote:
>>
>> upon clicking the button , I need to make query to db and delete the 
>> records...
>>
>> On Monday, 19 November 2012 19:23:54 UTC+5:30, Niphlod wrote:
>>>
>>> the _onclick parameter is "translated" to just a plain onclick attribute 
>>> of the tag you're using.
>>>
>>> When you do in HTML mylink nothing will 
>>> happen. 
>>> an _onclick of "alert('clicked me')" will fire an alert box (language: 
>>> javascript).
>>>
>>> What do you need to do upon clicking that button ?
>>
>>

-- 





[web2py] Re: Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-19 Thread Amit
upon clicking the button , I need to make query to db and delete the 
records...

On Monday, 19 November 2012 19:23:54 UTC+5:30, Niphlod wrote:
>
> the _onclick parameter is "translated" to just a plain onclick attribute 
> of the tag you're using.
>
> When you do in HTML mylink nothing will 
> happen. 
> an _onclick of "alert('clicked me')" will fire an alert box (language: 
> javascript).
>
> What do you need to do upon clicking that button ?

-- 





[web2py] Re: Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-19 Thread Amit
Could you elaborate more on this with some example code?

On Monday, 19 November 2012 19:13:58 UTC+5:30, Niphlod wrote:
>
> _onclick expects a javascript fragment to be executed. 
>
> On Monday, November 19, 2012 2:40:24 PM UTC+1, Amit wrote:
>>
>> Hi,
>> I have added one custom button after *Search* and *Clear* buttons of 
>> SQLFORM.grid but unable to associate the action onto it, onclick is not 
>> getting called.Please see below the code:
>>
>> grid = SQLFORM.grid(db.test_table,deletable=True)
>> grid[0][1][1].components = [
>>   TAG.button('testbutton', _id="px-delete",_type="button",_onclick=
>> 'test')
>> ]
>>
>> def test():
>> print 'test called'
>>
>> "testbutton" is getting added perfectly but when i click on it , it 
>> doesn't call test() function, how to achieve it? Please do help me.
>>
>>

-- 





[web2py] Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-19 Thread Amit
Hi,
I have added one custom button after *Search* and *Clear* buttons of 
SQLFORM.grid but unable to associate the action onto it, onclick is not 
getting called.Please see below the code:

grid = SQLFORM.grid(db.test_table,deletable=True)
grid[0][1][1].components = [
  TAG.button('testbutton', _id="px-delete",_type="button",_onclick=
'test')
]

def test():
print 'test called'

"testbutton" is getting added perfectly but when i click on it , it doesn't 
call test() function, how to achieve it? Please do help me.

-- 





Re: [web2py] Re: Getting error near "interval_time": syntax error

2012-11-14 Thread Amit
100% correct :) , now facing problem of replacing the query with sqlite
compatible query :

MySql query were:

*query = Expression(db,"date_sub(now(),interval interval_time minute) >
updated_on")*

where interval_time field is integer field which will be considered to take
interval in minutes for e.g. if user wants to save the interval time is 1
hour then he has to enter it in minutes means 60 minutes.

Now problem is when i tried to replace the above query with sqlite
compitible query like below and pass to the db to get the required records:

*query = Expression(db,"date('now','-interval_time minutes') > updated_on")*

it returns nothing.
So can you please help me out write the above query in Sqlite.

Thanks,
Amit



On Wed, Nov 14, 2012 at 3:36 PM, Niphlod  wrote:

>
> Il giorno mercoledì 14 novembre 2012 09:51:43 UTC+1, Amit ha scritto:
>
>> Hi,
>> I am getting error
>> * near "interval_time": syntax error*
>>
>
> syntax error points to something around "interval_time".. my bet is on
> date_sub() not supported by sqlite
>
> http://www.sqlite.org/cvstrac/wiki/wiki?p=DateAndTimeFunctions
>
>
> --
>
>
>
>

-- 





[web2py] Getting error near "interval_time": syntax error

2012-11-14 Thread Amit
 -  
   
   *File D:\web2py2.1.1\web2py\gluon\dal.py in log_execute at line 1687* 
   code arguments variables 
Function argument list 
   
   (self=, *a=('SELECT status.serial_no, 
   status.name, status.in...dated_on) GROUP BY status.serial_no, 
   status.name;',), **b={})
Code listing 
   
   1682.
   1683.
   1684.
   1685.
   1686.
   1687.
   
   1688.
   1689.
   1690.
   1691.
   
   command = a[0]
   if self.db._debug:
   LOGGER.debug('SQL: %s' % command)
   self.db._lastsql = command
   t0 = time.time()
   ret = self.cursor.execute(*a, **b)
   
   self.db._timings.append((command,time.time()-t0))
   del self.db._timings[:-TIMINGSSIZE]
   return ret
   
Variables  a ('SELECT status.serial_no, status.name, 
   status.in...dated_on) GROUP BY status.serial_no, status.name;',)  b {}  
   self   ret undefined  self.cursor 
  self.cursor.execute 
   

*I am suspecting something is wrong with Expression syntax but unable to 
catch it , please help me resolve this issue.*

Thanks,

Amit

*
*


-- 





[web2py] Re: ImportError: Cannot import module 'requests'

2012-11-12 Thread Amit
One more observation: 
If I am using APScheduler instead of web2py Scheduler , everything works 
fine and I am able to see the post in the mail, so not sure why module 
requests is not recognized in case of web2py Scheduler.

Below are the code using APScheduler:


from apscheduler.scheduler import Scheduler
sched = Scheduler()
sched.start()

@sched.interval_schedule(minutes=1)
def send_mail():
message = 'Hello'
post_message(message)

from mailgun import *
import requests   
def post_message(testmessage):

r = requests.post(("https://api.mailgun.net/v2/amit.mailgun.org/";
  "messages"),
 auth=("api", "key-3k7c-lqsdfnphzid4rbmnr9vp913y9q94"),
 data={
 "from": "Excited User ",
 "to": ["amit.khaw...@gmail.com"],
 "subject": "Update",
 "text": str(testmessage)
 }
 )
return r





On Monday, 12 November 2012 15:00:43 UTC+5:30, Amit wrote:
>
> I am getting below error on python shell:
>
> Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] 
> on win32
> Type "copyright", "credits" or "license()" for more information.
> >>> import requests
>
> Traceback (most recent call last):
>   File "", line 1, in 
> import requests
> ImportError: No module named requests
> >>> 
>
> but I have installed requests module to my Pythonpath :
>
> C:\Python27\Lib\site-packages\requests-0.13.8
>
>
>
> On Monday, 12 November 2012 14:47:19 UTC+5:30, Niphlod wrote:
>>
>> do you have the requests module available on python ?
>>
>> i.e. if you open a python shell, what you get when you do
>>
>> import requests 
>>
>> ?
>>
>> Il giorno lunedì 12 novembre 2012 10:12:08 UTC+1, Amit ha scritto:
>>>
>>> Hi,
>>>
>>> I am using scheduler in my application which will periodically sends 
>>> mail to the user, but when i start worker on command prompt using web2py.py 
>>> -K  MyApp, its giving follwoing error on command prompt: 
>>>
>>> D:\web2py2.1.1\web2py>web2py.py -K  MyApp
>>> No handlers could be found for logger "web2py"
>>> web2py Web Framework
>>> Created by Massimo Di Pierro, Copyright 2007-2012
>>> Version 2.1.1 (2012-10-15 12:44:40) stable
>>> Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(
>>> pg8000),
>>>  IMAP(imaplib)
>>> starting single-scheduler for "MyApp"...
>>> Traceback (most recent call last):
>>>   File "D:\web2py2.1.1\web2py\gluon\restricted.py", line 209, inrestricted
>>> exec ccode in environment
>>>   File "applications\MyApp\models\db.py", line 48, in 
>>> import requests
>>>   File "D:\web2py2.1.1\web2py\gluon\custom_import.py", line 70, 
>>> incustom_import
>>> er
>>> raise ImportError, 'Cannot import module %s' % str(e)
>>> ImportError: Cannot import module 'requests'
>>>
>>> Below are the code of scheduler and function:
>>>
>>> db.scheduler_task.validate_and_insert(
>>> function_name='send_mail',
>>> args='[]',
>>> repeats = 0, # run indifinitely
>>> period = 60, # every 2 mins
>>> timeout = 120, # should take less than 120 seconds
>>> )
>>>
>>> def send_mail():
>>> message = 'Hello'
>>> post_message(message)
>>>
>>> from mailgun import *
>>> import requests   
>>> def post_message(testmessage):
>>> 
>>> r = requests.post(("https://api.mailgun.net/v2/amit.mailgun.org/";
>>>   "messages"),
>>>  auth=("api", "key-3k7c-lqsdfnphzid4rbmnr9vp913y9q94"),
>>>  data={
>>>  "from": "Excited User ",
>>>  "to": ["amit.k...@gmail.com"],
>>>  "subject": "Update",
>>>  "text": str(testmessage)
>>>  }
>>>  )
>>> return r
>>>
>>>
>>> And when i keep statement import requests inside post_message() function 
>>> then the error is not displaying on the command prompt , it seems like 
>>> worker has started successfully but when I checked in verified in database 
>>> the task status is showing as FAILED and when I see the stack trace ,its 
>>> displaying the same error as above.
>>>
>>> Can anyone guide me to solve this issue?
>>>
>>>
>>>
>>>
>>>

-- 





[web2py] Re: ImportError: Cannot import module 'requests'

2012-11-12 Thread Amit
I am getting below error on python shell:

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] 
on win32
Type "copyright", "credits" or "license()" for more information.
>>> import requests

Traceback (most recent call last):
  File "", line 1, in 
import requests
ImportError: No module named requests
>>> 

but I have installed requests module to my Pythonpath :

C:\Python27\Lib\site-packages\requests-0.13.8



On Monday, 12 November 2012 14:47:19 UTC+5:30, Niphlod wrote:
>
> do you have the requests module available on python ?
>
> i.e. if you open a python shell, what you get when you do
>
> import requests 
>
> ?
>
> Il giorno lunedì 12 novembre 2012 10:12:08 UTC+1, Amit ha scritto:
>>
>> Hi,
>>
>> I am using scheduler in my application which will periodically sends mail 
>> to the user, but when i start worker on command prompt using web2py.py -K  
>> MyApp, its giving follwoing error on command prompt: 
>>
>> D:\web2py2.1.1\web2py>web2py.py -K  MyApp
>> No handlers could be found for logger "web2py"
>> web2py Web Framework
>> Created by Massimo Di Pierro, Copyright 2007-2012
>> Version 2.1.1 (2012-10-15 12:44:40) stable
>> Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(
>> pg8000),
>>  IMAP(imaplib)
>> starting single-scheduler for "MyApp"...
>> Traceback (most recent call last):
>>   File "D:\web2py2.1.1\web2py\gluon\restricted.py", line 209, inrestricted
>> exec ccode in environment
>>   File "applications\MyApp\models\db.py", line 48, in 
>> import requests
>>   File "D:\web2py2.1.1\web2py\gluon\custom_import.py", line 70, 
>> incustom_import
>> er
>> raise ImportError, 'Cannot import module %s' % str(e)
>> ImportError: Cannot import module 'requests'
>>
>> Below are the code of scheduler and function:
>>
>> db.scheduler_task.validate_and_insert(
>> function_name='send_mail',
>> args='[]',
>> repeats = 0, # run indifinitely
>> period = 60, # every 2 mins
>> timeout = 120, # should take less than 120 seconds
>> )
>>
>> def send_mail():
>> message = 'Hello'
>> post_message(message)
>>
>> from mailgun import *
>> import requests   
>> def post_message(testmessage):
>> 
>> r = requests.post(("https://api.mailgun.net/v2/amit.mailgun.org/";
>>   "messages"),
>>  auth=("api", "key-3k7c-lqsdfnphzid4rbmnr9vp913y9q94"),
>>  data={
>>  "from": "Excited User ",
>>  "to": ["amit.k...@gmail.com"],
>>  "subject": "Update",
>>  "text": str(testmessage)
>>  }
>>  )
>> return r
>>
>>
>> And when i keep statement import requests inside post_message() function 
>> then the error is not displaying on the command prompt , it seems like 
>> worker has started successfully but when I checked in verified in database 
>> the task status is showing as FAILED and when I see the stack trace ,its 
>> displaying the same error as above.
>>
>> Can anyone guide me to solve this issue?
>>
>>
>>
>>
>>

-- 





[web2py] ImportError: Cannot import module 'requests'

2012-11-12 Thread Amit
Hi,

I am using scheduler in my application which will periodically sends mail 
to the user, but when i start worker on command prompt using web2py.py -K  
MyApp, its giving follwoing error on command prompt: 

D:\web2py2.1.1\web2py>web2py.py -K  MyApp
No handlers could be found for logger "web2py"
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2012
Version 2.1.1 (2012-10-15 12:44:40) stable
Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(
pg8000),
 IMAP(imaplib)
starting single-scheduler for "MyApp"...
Traceback (most recent call last):
  File "D:\web2py2.1.1\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
  File "applications\MyApp\models\db.py", line 48, in 
import requests
  File "D:\web2py2.1.1\web2py\gluon\custom_import.py", line 70, incustom_import
er
raise ImportError, 'Cannot import module %s' % str(e)
ImportError: Cannot import module 'requests'

Below are the code of scheduler and function:

db.scheduler_task.validate_and_insert(
function_name='send_mail',
args='[]',
repeats = 0, # run indifinitely
period = 60, # every 2 mins
timeout = 120, # should take less than 120 seconds
)

def send_mail():
message = 'Hello'
post_message(message)

from mailgun import *
import requests   
def post_message(testmessage):

r = requests.post(("https://api.mailgun.net/v2/amit.mailgun.org/";
  "messages"),
 auth=("api", "key-3k7c-lqsdfnphzid4rbmnr9vp913y9q94"),
 data={
 "from": "Excited User ",
 "to": ["amit.khaw...@gmail.com"],
 "subject": "Update",
 "text": str(testmessage)
 }
 )
return r


And when i keep statement import requests inside post_message() function 
then the error is not displaying on the command prompt , it seems like 
worker has started successfully but when I checked in verified in database 
the task status is showing as FAILED and when I see the stack trace ,its 
displaying the same error as above.

Can anyone guide me to solve this issue?




-- 





Re: [web2py] Re: Optimized way to use web2py Scheduler

2012-11-09 Thread Amit
Thanks Niphold for your informative response so If i understood correctly,
in my case , I don't need to start 10 different workers as all these 10
tasks will have different time period to run hence one worker will be
sufficient to perform the required tasks and in any case, suppose I have to
run more than one tasks at the same time period then I should go to the
approach of starting more than one workers.

Thanks,
Amit

On Fri, Nov 9, 2012 at 3:16 PM, Niphlod  wrote:

> ehm, missing something here: worker(s) do(es) auto-assignments of tasks.
> there's no web2py involved in assigning task to a particular worker.
> Said that, I'd run one worker if there are no requisites like "I need
> function1 and function2 to run concurrently", in which case, start 2
> workers, they'll split the jobs.
>
>
> On Friday, November 9, 2012 7:59:04 AM UTC+1, Amit wrote:
>>
>> Hi,
>> I have more than 10 functions which has to be executed by Scheduler and
>> each task has assigned different time ( for e.g...one has to execute on
>> every 15 minutes, other one has to executes on every 24 hrs etc... ) to
>> execute, so in my CustomScheduler.py module : I wiil have 10 different
>> statements like below:
>>
>>
>> db.scheduler_task.validate_**and_insert(
>> function_name='func1',
>> args='[]',
>> repeats = 0, # run indefinately
>> period = 3600, # every 1h
>> timeout = 120, # should take less than 120 seconds
>> )
>>
>>
>>
>> db.scheduler_task.validate_**and_insert(
>> function_name='func2',
>> args='[]',
>> repeats = 0, # run indefinately
>> period = 900, # every 15 min
>> timeout = 120, # should take less than 120 seconds
>> )
>>
>>   My doubt is what will be the better optimized approach to assign those
>> 10 tasks to Scheduler:
>>
>> 1. Create only one worker  using *web2py -K appname* command for all
>> tasks, which will further takes care of running all tasks at designated
>> time OR
>> 2.  Create 10 different workers means execute above command 10 times and
>> then web2py takes care of assigning the task to each worker.
>>
>> which will be the best optimized way to use web2py scheduler?
>>
>> Regards,
>> Amit
>>
>>  --
>
>
>
>

-- 





[web2py] Optimized way to use web2py Scheduler

2012-11-08 Thread Amit
Hi,
I have more than 10 functions which has to be executed by Scheduler and 
each task has assigned different time ( for e.g...one has to execute on 
every 15 minutes, other one has to executes on every 24 hrs etc... ) to 
execute, so in my CustomScheduler.py module : I wiil have 10 different  
statements like below:


db.scheduler_task.validate_and_insert(
function_name='func1',
args='[]',
repeats = 0, # run indefinately
period = 3600, # every 1h
timeout = 120, # should take less than 120 seconds
)



db.scheduler_task.validate_and_insert(
function_name='func2',
args='[]',
repeats = 0, # run indefinately
period = 900, # every 15 min
timeout = 120, # should take less than 120 seconds
)

  My doubt is what will be the better optimized approach to assign those 10 
tasks to Scheduler:

1. Create only one worker  using *web2py -K appname* command for all tasks, 
which will further takes care of running all tasks at designated time OR
2.  Create 10 different workers means execute above command 10 times and 
then web2py takes care of assigning the task to each worker.

which will be the best optimized way to use web2py scheduler?

Regards,
Amit

-- 





Re: [web2py] Re: Problem in deploying ssl certificates to Rocket server.

2012-11-07 Thread Amit
Thanks Michele, I resolved the issue by overriding class X509Auth :), one
more clarification:
using openssl, i created CA certificates, private key then client and
server certificates with their private key signed by CA certificate,
everything is working fine except:
 when I access My application I always need to provide the server
certificate password on the command prompt (where server has started) to
access the page, is there any way to disable this? Means, user only needs
to import the client certificate to their browser and when they access the
application it will allow to access the pages of the application without
asking the password. Anyways user doesn't have access to the server so they
can't be able to provide the password so in this case, even though they
will be able to import the client certificate, automatically downloaded
server certificate to the browser when they make request for application
but can't be able to access the application pages because on server command
prompt it will ask for password, so how to make it password free?


On Wed, Nov 7, 2012 at 6:52 PM, Michele Comitini  wrote:

> Amit,
>
> A "self" was missing this should work:
>
> class MyX509Auth(X509Auth):
>  def get_user(self):
>   self.subject.surname = 
>   X509Auth.get_user(self)
> auth.settings.login_form = MyX509Auth()
>
>
> 2012/11/7 Michele Comitini 
>
>> Amit,
>>
>> in your model call the derived class
>>
>> auth.settings.login_form = MyX509Auth()
>>
>>
>>
>> 2012/11/7 Michele Comitini 
>>
>>> simpatiCA makes the client certificates already with needed fields.
>>> Since you use openssl directly you can set all the fields you need in
>>> the certificates by changing openssl.cnf in your openssl installation.
>>>  There is plenty of documentation on that.
>>>
>>> OR you can extend the class X509Auth to fit your needs by overriding
>>> get_user()
>>>
>>>
>>> class MyX509Auth(X509Auth):
>>>  def get_user():
>>>   self.subject.surname = 
>>>   X509Auth.get_user(self)
>>>
>>>
>>> mic
>>>
>>>
>>>
>>> 2012/11/7 Amit 
>>>
>>>> Hi,
>>>> I filled the email address in the certificate but what I think is
>>>> problem with surname , please check below the log:
>>>>
>>>>
>>>> *File D:\web2py2.1.1\web2py\gluon\contrib\login_methods\x509_auth.py
>>>> in get_user at line 91* code arguments variables
>>>>  Function argument list
>>>>
>>>> (self=)
>>>>  Code listing
>>>>
>>>> 86.
>>>> 87.
>>>> 88.
>>>> 89.
>>>> 90.
>>>> 91.
>>>>
>>>> 92.
>>>> 93.
>>>> 94.
>>>> 95.
>>>>
>>>>
>>>> p = profile = dict()
>>>>
>>>> username = p['username'] = reduce(lambda a,b: '%s | %s' % (a,b), 
>>>> self.subject.CN or self.subject.commonName)
>>>>
>>>>
>>>>
>>>>
>>>> p['first_name'] = reduce(lambda a,b: '%s | %s' % 
>>>> (a,b),self.subject.givenName or username)
>>>>
>>>>
>>>>
>>>> p['last_name'] = reduce(lambda a,b: '%s | %s' % 
>>>> (a,b),self.subject.surname)
>>>>
>>>>
>>>>
>>>>
>>>> p['email'] = reduce(lambda a,b: '%s | %s' % 
>>>> (a,b),self.subject.Email or self.subject.emailAddress)
>>>>
>>>>
>>>>
>>>>
>>>> # IMPORTANT WE USE THE CERT SERIAL AS UNIQUE KEY FOR THE USER
>>>> p['registration_id'] = self.serial
>>>>
>>>>  Variables
>>>> a undefined  b undefined  builtinreduce 
>>>> self.subject.surname []  self 
>>>> >>> object>  self.subject >>> ...SG'], 'organizationUnitName': ['HSG'], 'SN': []}>  p {'first_name':
>>>> 'A | m | i | t | 1 | | K | h | a | w | a | r | e', 'username': 'Amit1
>>>> Khaware'}
>>>>
>>>> And while generating the certificates it is not asking about surname,
>>>> it's asking below information:
>>>>
>>>> Country Name (2 letter code) [US]:
>>>> State or Prov

Re: [web2py] Re: Problem in deploying ssl certificates to Rocket server.

2012-11-06 Thread Amit
Hi,
I filled the email address in the certificate but what I think is problem
with surname , please check below the log:

*File D:\web2py2.1.1\web2py\gluon\contrib\login_methods\x509_auth.py in
get_user at line 91* code arguments variables
 Function argument list

(self=)
 Code listing

86.
87.
88.
89.
90.
91.

92.
93.
94.
95.


p = profile = dict()

username = p['username'] = reduce(lambda a,b: '%s | %s' %
(a,b), self.subject.CN or self.subject.commonName)
p['first_name'] = reduce(lambda a,b: '%s | %s' %
(a,b),self.subject.givenName or username)
p['last_name'] = reduce(lambda a,b: '%s | %s' %
(a,b),self.subject.surname)

p['email'] = reduce(lambda a,b: '%s | %s' %
(a,b),self.subject.Email or self.subject.emailAddress)

# IMPORTANT WE USE THE CERT SERIAL AS UNIQUE KEY FOR THE USER
p['registration_id'] = self.serial

 Variables a undefined  b undefined  builtinreduce   self.subject.surname []  self
  self.subject   p {'first_name': 'A |
m | i | t | 1 | | K | h | a | w | a | r | e', 'username': 'Amit1 Khaware'}

And while generating the certificates it is not asking about surname, it's
asking below information:

Country Name (2 letter code) [US]:
State or Province Name (full name) [CA]:
Locality Name (eg, city) [San Diego]:
Organization Name (eg, company) [Cafesoft LLC]:
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:*Cafesoft CA*
Email Address [c...@cafenet.com]:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:*password*
An optional company name []:


please check the link :

http://www.cafesoft.com/products/cams/ps/docs30/admin/ConfiguringApache2ForSSLTLSMutualAuthentication.html

So x509_auth.py expects surname but above link doesn't provide option to
fill surname :(


Regards,

Amit








On Tue, Nov 6, 2012 at 8:34 PM, Michele Comitini  wrote:

> self.subject.Email is [] i.e. an empty list.  Check if that is the problem.
>
> mic
> Il giorno 06/nov/2012 14:32, "Amit"  ha scritto:
>
>> I have used below link to generate server certificates, client
>> certificates and CA certificates,  imported client  and CA certificates to
>> Mozilla Firefox browser and then deploy server certificates and CA
>> certificate to the Rocket server :
>>
>> D:\web2py2.1.1\web2py>web2py.py -a password -i 127.0.0.1 -p 8000 -c
>> C:\OpenSSL-Win32\bin\cirrusAwareCA\server\certificates\server.test.com.crt
>> -k C:\OpenSSL-Win32\bin\cirrusAwareCA\server\keys\server.test.com.key
>> --ca-cert=C:\OpenSSL-Win32\bin\cirrusAwareCA\CA\cirrusAwareCA.crt
>>
>> Then Open browser type https://127.0.0.1:8000/MyApp/default/index
>>
>> Now its giving error:
>>  reduce() of empty sequence with no initial
>> value Error snapshot [image: help]
>>
>> (reduce() of empty sequence with no initial
>> value)
>>
>> inspect attributes
>>  Frames
>>
>>-
>>
>>*File D:\web2py2.1.1\web2py\gluon\restricted.py in restricted at line
>>209* code arguments variables
>> -
>>
>>*File
>>
>> D:\web2py2.1.1\web2py\applications\AuthenticationApp\controllers\default.py
>>in  at line 76* code arguments variables
>> -
>>
>>*File D:\web2py2.1.1\web2py\gluon\globals.py in  at line 187*
>>code arguments variables
>> -
>>
>>*File
>>
>> D:\web2py2.1.1\web2py\applications\AuthenticationApp\controllers\default.py
>>in user at line 38* code arguments variables
>> Code listing
>>
>>33.
>>34.
>>35.
>>36.
>>37.
>>38.
>>
>>39.
>>40.
>>41.
>>42.
>>
>>use @auth.requires_login()
>>@auth.requires_membership('group name')
>>
>>
>>@auth.requires_permission('read','table name',record_id)
>>
>>
>>to decorate functions that need access control
>>"""
>>return dict(form=auth())
>>
>>
>>
>>def download():
>>"""
>>
>>  -
>>
>>*File D:\web2py2.1.1\web2py\gluon\tools.py in __call__ at line 1205*
>>code arguments variables
>> -
>>
>>*File D:\web2py2.1.1\web2py\gluon\tools.py in login at line 2016* code
>>arguments variables
>> -
>>
>>*File D:\web2py2.1.1\web2py\gluon\contrib\login_methods\x509_auth.py
>>in get_user at line 91* 

Re: [web2py] Re: Problem in deploying ssl certificates to Rocket server.

2012-11-06 Thread Amit
I have used below link to generate server certificates, client certificates
and CA certificates,  imported client  and CA certificates to Mozilla
Firefox browser and then deploy server certificates and CA certificate to
the Rocket server :

D:\web2py2.1.1\web2py>web2py.py -a password -i 127.0.0.1 -p 8000 -c
C:\OpenSSL-Win32\bin\cirrusAwareCA\server\certificates\server.test.com.crt
-k C:\OpenSSL-Win32\bin\cirrusAwareCA\server\keys\server.test.com.key
--ca-cert=C:\OpenSSL-Win32\bin\cirrusAwareCA\CA\cirrusAwareCA.crt

Then Open browser type https://127.0.0.1:8000/MyApp/default/index

Now its giving error:
 reduce() of empty sequence with no initial
value Error snapshot [image: help]

(reduce() of empty sequence with no initial
value)

inspect attributes
 Frames

   -

   *File D:\web2py2.1.1\web2py\gluon\restricted.py in restricted at line 209
   * code arguments variables
-

   *File
   D:\web2py2.1.1\web2py\applications\AuthenticationApp\controllers\default.py
   in  at line 76* code arguments variables
-

   *File D:\web2py2.1.1\web2py\gluon\globals.py in  at line 187*
   code arguments variables
-

   *File
   D:\web2py2.1.1\web2py\applications\AuthenticationApp\controllers\default.py
   in user at line 38* code arguments variables
Code listing

   33.
   34.
   35.
   36.
   37.
   38.

   39.
   40.
   41.
   42.

   use @auth.requires_login()
   @auth.requires_membership('group name')
   @auth.requires_permission('read','table name',record_id)
   to decorate functions that need access control
   """
   return dict(form=auth())



   def download():
   """

-

   *File D:\web2py2.1.1\web2py\gluon\tools.py in __call__ at line 1205* code
   arguments variables
-

   *File D:\web2py2.1.1\web2py\gluon\tools.py in login at line 2016* code
   arguments variables
-

   *File D:\web2py2.1.1\web2py\gluon\contrib\login_methods\x509_auth.py in
   get_user at line 91* code arguments variables
Function argument list

   (self=)
Code listing

   86.
   87.
   88.
   89.
   90.
   91.

   92.
   93.
   94.
   95.


   p = profile = dict()

   username = p['username'] = reduce(lambda a,b: '%s | %s' %
(a,b), self.subject.CN or self.subject.commonName)
   p['first_name'] = reduce(lambda a,b: '%s | %s' %
(a,b),self.subject.givenName or username)
   p['last_name'] = reduce(lambda a,b: '%s | %s' %
(a,b),self.subject.surname)

   p['email'] = reduce(lambda a,b: '%s | %s' %
(a,b),self.subject.Email or self.subject.emailAddress)

   # IMPORTANT WE USE THE CERT SERIAL AS UNIQUE KEY FOR THE USER
   p['registration_id'] = self.serial

    Variables  a undefined  b undefined  builtinreduce   self.subject.surname []  self
  self.subject   p
{'first_name':
   'A | m | i | t', 'username': 'Amit'}


Regards,
Amit




On Tue, Nov 6, 2012 at 6:42 PM, Michele Comitini  wrote:

> https://github.com/web2py/web2py/blob/master/gluon/main.py#L824
>
> The log seems to say that your certificate file is not there, or not
> accessible
>
> mic
>
>
> 2012/11/6 Amit 
>
>> I am using Python 2.7.2.
>>
>> On Tue, Nov 6, 2012 at 6:33 PM, Michele Comitini <
>> michele.comit...@gmail.com> wrote:
>>
>>> What is your python version?
>>>
>>>
>>> 2012/11/6 Amit 
>>>
>>>> Hi Michele,
>>>> I used Simpatica to generates the certificates but failed to deploy to
>>>> the web2py server, please check once the first mail in this mail chain
>>>> where I explained the problem in details.
>>>>
>>>> Regards,
>>>> Amit
>>>>
>>>> On Tue, Nov 6, 2012 at 4:52 PM, Michele Comitini <
>>>> michele.comit...@gmail.com> wrote:
>>>>
>>>>>  I suggest looking at code gluon/contrib/login_methods/x509_auth.py.
>>>>>  Basically you can extract anything from client supplied cert and use it
>>>>> with the auth tables of web2py.  That is really simple.
>>>>> The tedious part id getting to know what stuff you can put in the
>>>>> cert.  That is more related to managing a CA than to web2py itself.
>>>>>
>>>>> I have written a simple but functional app for managing a little CA:
>>>>> simpatiCA <http://goo.gl/nrAhS> ; it is simple enough to be used as
>>>>> an example and extended to your needs.  If you need a real CA there are
>>>>> more featured solutions around...
>>>>>
>>>>> mic
>>>>>
>>>>>
>>>

Re: [web2py] Re: Problem in deploying ssl certificates to Rocket server.

2012-11-06 Thread Amit
I am using Python 2.7.2.

On Tue, Nov 6, 2012 at 6:33 PM, Michele Comitini  wrote:

> What is your python version?
>
>
> 2012/11/6 Amit 
>
>> Hi Michele,
>> I used Simpatica to generates the certificates but failed to deploy to
>> the web2py server, please check once the first mail in this mail chain
>> where I explained the problem in details.
>>
>> Regards,
>> Amit
>>
>> On Tue, Nov 6, 2012 at 4:52 PM, Michele Comitini <
>> michele.comit...@gmail.com> wrote:
>>
>>>  I suggest looking at code gluon/contrib/login_methods/x509_auth.py.
>>>  Basically you can extract anything from client supplied cert and use it
>>> with the auth tables of web2py.  That is really simple.
>>> The tedious part id getting to know what stuff you can put in the cert.
>>>  That is more related to managing a CA than to web2py itself.
>>>
>>> I have written a simple but functional app for managing a little CA:
>>> simpatiCA <http://goo.gl/nrAhS> ; it is simple enough to be used as an
>>> example and extended to your needs.  If you need a real CA there are more
>>> featured solutions around...
>>>
>>> mic
>>>
>>>
>>> > PS: the man behind X509 auth code in web2py is mcm, sadly for your
>>> it's documented how it works but not how to organize the certs (which in >
>>> theory you should know in advance)
>>>
>>> --
>>>
>>>
>>> 2012/11/6 Niphlod 
>>>
>>>> hem... one thing is helping you to create certs and key for a SSL
>>>> protected webserver, quite another to help you managing a credential store
>>>> (I really don't have time for that).
>>>> You have problems on finding out what OpenSSL is and want to manage
>>>> X509 ? Really ?
>>>> Maybe it's time to read some docs.
>>>>
>>>> http://www.cafesoft.com/products/cams/ps/docs30/admin/ConfiguringApache2ForSSLTLSMutualAuthentication.html
>>>>
>>>>
>>>> PS: the man behind X509 auth code in web2py is mcm, sadly for your it's
>>>> documented how it works but not how to organize the certs (which in theory
>>>> you should know in advance)
>>>>
>>>> --
>>>>
>>>>
>>>>
>>>>
>>>
>>>  --
>>>
>>>
>>>
>>>
>>
>>  --
>>
>>
>>
>>
>
>  --
>
>
>
>

-- 





Re: [web2py] Re: Problem in deploying ssl certificates to Rocket server.

2012-11-06 Thread Amit
Hi Michele,
I used Simpatica to generates the certificates but failed to deploy to the
web2py server, please check once the first mail in this mail chain where I
explained the problem in details.

Regards,
Amit

On Tue, Nov 6, 2012 at 4:52 PM, Michele Comitini  wrote:

>  I suggest looking at code gluon/contrib/login_methods/x509_auth.py.
>  Basically you can extract anything from client supplied cert and use it
> with the auth tables of web2py.  That is really simple.
> The tedious part id getting to know what stuff you can put in the cert.
>  That is more related to managing a CA than to web2py itself.
>
> I have written a simple but functional app for managing a little CA:
> simpatiCA <http://goo.gl/nrAhS> ; it is simple enough to be used as an
> example and extended to your needs.  If you need a real CA there are more
> featured solutions around...
>
> mic
>
>
> > PS: the man behind X509 auth code in web2py is mcm, sadly for your it's
> documented how it works but not how to organize the certs (which in >
> theory you should know in advance)
>
> --
>
>
> 2012/11/6 Niphlod 
>
>> hem... one thing is helping you to create certs and key for a SSL
>> protected webserver, quite another to help you managing a credential store
>> (I really don't have time for that).
>> You have problems on finding out what OpenSSL is and want to manage X509
>> ? Really ?
>> Maybe it's time to read some docs.
>>
>> http://www.cafesoft.com/products/cams/ps/docs30/admin/ConfiguringApache2ForSSLTLSMutualAuthentication.html
>>
>>
>> PS: the man behind X509 auth code in web2py is mcm, sadly for your it's
>> documented how it works but not how to organize the certs (which in theory
>> you should know in advance)
>>
>> --
>>
>>
>>
>>
>
>  --
>
>
>
>

-- 





Re: [web2py] Re: Problem in deploying ssl certificates to Rocket server.

2012-11-06 Thread Amit
You are right Niphold, I am able to deploy the certificate and start the
web server without using --ca-cert option,But I have to use X509
authentication and for that I have written below code  :

*db.py :*
from gluon.contrib.login_methods.x509_auth import X509Auth
auth.settings.actions_disabled=['register','change_password',
'request_reset_password','profile']
auth.settings.login_form = X509Auth()

*default.py:*
@auth.requires_login()
def index():
response.flash = T("Welcome to web2py!")
return dict(message=T('Hello World'))

And when I am calling application's index function through browser, its
giving error saying *"Login not allowed. No valid x509 crentials"*



On Tue, Nov 6, 2012 at 2:43 PM, Niphlod  wrote:

> too much certificates there for ssl. one key, one cert.
> ca-cert is used if you're willing to auth users through x509, but given
> that your understanding on certificates is basic I'd say you don't need it.
>
> Il giorno martedì 6 novembre 2012 04:00:37 UTC+1, Amit ha scritto:
>>
>> Thanks for your response Ales, I used the openssl command to generate the
>> certificates which Niphold has suggested me but when i tried to deploy it
>> to Rocket sever using below command :
>>
>> *web2py.py --ssl_certificate=D:\certificates\server.crt
>> --ssl_private_key=D:\certificates\server_key.key
>> --ca-cert=D:\certificates\server.crt
>>
>>
>> *It gives* * following warning on command prompt:
>>
>> *WARNING:web2py:unable to open SSL certificate. SSL is OFF
>>
>> *And below error on Mozilla Firefox browser:*
>> *
>> *SSL received a record that exceeded the maximum permissible length.
>>
>> (Error code: ssl_error_rx_record_too_long)
>>
>> *Hope this will help you to understand the problem.*
>>
>> *Thanks,
>> Amit*
>> *
>> On Mon, Nov 5, 2012 at 5:17 PM, LightDot  wrote:
>>
>>> One way I know of is the same Niphlod told you in his previous post -
>>> use openssl to generate the certificate. He gave you the complete command
>>> example, I don't know how to be clearer than that...
>>>
>>> http://www.openssl.org/**related/binaries.html<http://www.openssl.org/related/binaries.html>
>>>
>>> Regards,
>>> Ales
>>>
>>>
>>>
>>> On Monday, November 5, 2012 12:40:28 PM UTC+1, Amit wrote:
>>>
>>>> I run the command to generate certificates:
>>>>
>>>> *web2py.py --ssl_certificate=D:\certificates\server.crt
>>>> --ssl_private_key=D:\certificates\server_key.key
>>>> --ca-cert=D:\certificates\server.crt*
>>>>
>>>> And when I run this, It gives warning message on command prompt:
>>>>
>>>> *WARNING:web2py:unable to open SSL certificate. SSL is OFF*
>>>>
>>>> and on browser it display following error message:
>>>>
>>>> *SSL received a record that exceeded the maximum permissible length.
>>>>
>>>> (Error code: ssl_error_rx_record_too_long)*
>>>>
>>>>
>>>> So no idea, how to resolve this?
>>>>
>>>> Thanks,
>>>> Amit
>>>>
>>>>
>>>>
>>>> On Mon, Nov 5, 2012 at 4:10 PM, Niphlod  wrote:
>>>>
>>>>> the usual
>>>>>
>>>>> openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mysitename
>>>>> .key -out mysitename.crt
>>>>>
>>>>> works ok.
>>>>>
>>>>> Il giorno lunedì 5 novembre 2012 03:48:43 UTC+1, Amit ha scritto:
>>>>>>
>>>>>> Thanks Niphold for replying. How can I create server cetificate, CA
>>>>>> certificate and client certificate without password? I am using simpatica
>>>>>> application to create all these certificates on windows XP machine and 
>>>>>> this
>>>>>> application doesn't allow to create certificates without password so if 
>>>>>> you
>>>>>> know any other way to create these certificates without password on 
>>>>>> windows
>>>>>> then please do share me.
>>>>>>
>>>>>> waiting for your response.
>>>>>>
>>>>>> Thanks,
>>>>>> Amit
>>>>>>
>>>>>> On Fri, Nov 2, 2012 at 6:23 PM, Niphlod  wrote:
>>>>>>
>>>>>>> certs are 

[web2py] Getting error "Login not allowed. No valid x509 crentials"

2012-11-06 Thread Amit
 

Hi,

I generate the CA certificate and private key using OpenSSL on my Windows 
XP machine: 

 openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout  
private_key.key -out server.crt


and able to deploy to Rocket server :

web2py.py -a password -i 127.0.0.1 -p 8000 -c  D:\certificates\sever.crt  
-k D:\certificates\private_key.key


and added the below code to db.py:

from gluon.contrib.login_methods.x509_auth import X509Auth

 

auth.settings.actions_disabled=[*'register'*,*'change_password'*,

*'request_reset_password'*,*'profile'*]

auth.settings.login_form = X509Auth()

 

And added below function in default.py:

 

*@auth.requires_login*()

def *index*():

return dict(message=*T*(*'Welcome to My Application'*))

 

But when I am calling this function from browser using below:

 

https://127.0.0.1:8000/MyApp/default/index

 

It is displaying below message on the browser:

 

*Login not allowed. No valid x509 crentials*

* *

Please guide me what I am doing wrong.

Regards,

Amit

-- 





Re: [web2py] Re: Problem in deploying ssl certificates to Rocket server.

2012-11-05 Thread Amit
Thanks for your response Ales, I used the openssl command to generate the
certificates which Niphold has suggested me but when i tried to deploy it
to Rocket sever using below command :

*web2py.py --ssl_certificate=D:\certificates\server.crt
--ssl_private_key=D:\certificates\server_key.key
--ca-cert=D:\certificates\server.crt


*It gives* * following warning on command prompt:

*WARNING:web2py:unable to open SSL certificate. SSL is OFF

*And below error on Mozilla Firefox browser:*
*
*SSL received a record that exceeded the maximum permissible length.

(Error code: ssl_error_rx_record_too_long)

*Hope this will help you to understand the problem.*

*Thanks,
Amit*
*
On Mon, Nov 5, 2012 at 5:17 PM, LightDot  wrote:

> One way I know of is the same Niphlod told you in his previous post - use
> openssl to generate the certificate. He gave you the complete command
> example, I don't know how to be clearer than that...
>
> http://www.openssl.org/related/binaries.html
>
> Regards,
> Ales
>
>
>
> On Monday, November 5, 2012 12:40:28 PM UTC+1, Amit wrote:
>
>> I run the command to generate certificates:
>>
>> *web2py.py --ssl_certificate=D:\certificates\server.crt
>> --ssl_private_key=D:\certificates\server_key.key
>> --ca-cert=D:\certificates\server.crt*
>>
>> And when I run this, It gives warning message on command prompt:
>>
>> *WARNING:web2py:unable to open SSL certificate. SSL is OFF*
>>
>> and on browser it display following error message:
>>
>> *SSL received a record that exceeded the maximum permissible length.
>>
>> (Error code: ssl_error_rx_record_too_long)*
>>
>>
>> So no idea, how to resolve this?
>>
>> Thanks,
>> Amit
>>
>>
>>
>> On Mon, Nov 5, 2012 at 4:10 PM, Niphlod  wrote:
>>
>>> the usual
>>>
>>> openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mysitename.key
>>> -out mysitename.crt
>>>
>>> works ok.
>>>
>>> Il giorno lunedì 5 novembre 2012 03:48:43 UTC+1, Amit ha scritto:
>>>>
>>>> Thanks Niphold for replying. How can I create server cetificate, CA
>>>> certificate and client certificate without password? I am using simpatica
>>>> application to create all these certificates on windows XP machine and this
>>>> application doesn't allow to create certificates without password so if you
>>>> know any other way to create these certificates without password on windows
>>>> then please do share me.
>>>>
>>>> waiting for your response.
>>>>
>>>> Thanks,
>>>> Amit
>>>>
>>>> On Fri, Nov 2, 2012 at 6:23 PM, Niphlod  wrote:
>>>>
>>>>> certs are supposed to be generated without passwords. Even in apache,
>>>>> etc, if you protect them with a password it will be asked every time the
>>>>> process is started, and web2py (rocket) doesn't support that.
>>>>>
>>>>>
>>>>> On Friday, November 2, 2012 6:21:00 AM UTC+1, Amit wrote:
>>>>>>
>>>>>> Hi ,
>>>>>>
>>>>>> I generated CA certificates, private key, server certificate and
>>>>>> client certificate using “Simpatica” application developed in web2py.
>>>>>>
>>>>>> But when I tried to deploy the certificates to rocket server using
>>>>>> below command on windows XP machine:
>>>>>>
>>>>>>
>>>>>>
>>>>>> D:\web2py2.1.1\web2py>web2py.**py --ssl_certificate=D:\**
>>>>>> certificates\server\cert.pe
>>>>>>
>>>>>> m --ssl_private_key=D:\**certificates\private_key\**cacert.key
>>>>>> --ca-cert=D:\certific
>>>>>>
>>>>>> ates\CA_certificate\cacrt.pem
>>>>>>
>>>>>>
>>>>>>
>>>>>> It starts web2py server dialog asking about password and after giving
>>>>>> password, it displays below information on the command prompt:
>>>>>>
>>>>>>
>>>>>>
>>>>>> No handlers could be found for logger "web2py"
>>>>>>
>>>>>> web2py Web Framework
>>>>>>
>>>>>> Created by Massimo Di Pierro, Copyright 2007-2012
>>>>>>
>>>>>> Version 2.1.1 (2012-10-15 12:44:40) stable
>>>>>>
>>>>>> D

Re: [web2py] Re: Problem in deploying ssl certificates to Rocket server.

2012-11-05 Thread Amit
I run the command to generate certificates:

*web2py.py --ssl_certificate=D:\certificates\server.crt
--ssl_private_key=D:\certificates\server_key.key
--ca-cert=D:\certificates\server.crt*

And when I run this, It gives warning message on command prompt:

*WARNING:web2py:unable to open SSL certificate. SSL is OFF*

and on browser it display following error message:

*SSL received a record that exceeded the maximum permissible length.

(Error code: ssl_error_rx_record_too_long)*


So no idea, how to resolve this?

Thanks,
Amit



On Mon, Nov 5, 2012 at 4:10 PM, Niphlod  wrote:

> the usual
>
> openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mysitename.key
> -out mysitename.crt
>
> works ok.
>
> Il giorno lunedì 5 novembre 2012 03:48:43 UTC+1, Amit ha scritto:
>>
>> Thanks Niphold for replying. How can I create server cetificate, CA
>> certificate and client certificate without password? I am using simpatica
>> application to create all these certificates on windows XP machine and this
>> application doesn't allow to create certificates without password so if you
>> know any other way to create these certificates without password on windows
>> then please do share me.
>>
>> waiting for your response.
>>
>> Thanks,
>> Amit
>>
>> On Fri, Nov 2, 2012 at 6:23 PM, Niphlod  wrote:
>>
>>> certs are supposed to be generated without passwords. Even in apache,
>>> etc, if you protect them with a password it will be asked every time the
>>> process is started, and web2py (rocket) doesn't support that.
>>>
>>>
>>> On Friday, November 2, 2012 6:21:00 AM UTC+1, Amit wrote:
>>>>
>>>> Hi ,
>>>>
>>>> I generated CA certificates, private key, server certificate and client
>>>> certificate using “Simpatica” application developed in web2py.
>>>>
>>>> But when I tried to deploy the certificates to rocket server using
>>>> below command on windows XP machine:
>>>>
>>>>
>>>>
>>>> D:\web2py2.1.1\web2py>web2py.**p**y --ssl_certificate=D:\**certifica**
>>>> tes\server\cert.pe
>>>>
>>>> m --ssl_private_key=D:\**certifica**tes\private_key\**cacert.key
>>>> --ca-cert=D:\certific
>>>>
>>>> ates\CA_certificate\cacrt.pem
>>>>
>>>>
>>>>
>>>> It starts web2py server dialog asking about password and after giving
>>>> password, it displays below information on the command prompt:
>>>>
>>>>
>>>>
>>>> No handlers could be found for logger "web2py"
>>>>
>>>> web2py Web Framework
>>>>
>>>> Created by Massimo Di Pierro, Copyright 2007-2012
>>>>
>>>> Version 2.1.1 (2012-10-15 12:44:40) stable
>>>>
>>>> Database drivers available: SQLite(sqlite3), MySQL(pymysql),
>>>> PostgreSQL(pg8000),
>>>>
>>>>  IMAP(imaplib)
>>>>
>>>> please visit:
>>>>
>>>> https://127.0.0.1:8000
>>>>
>>>> starting browser...
>>>>
>>>> Enter PEM pass phrase:
>>>>
>>>> Enter PEM pass phrase:
>>>>
>>>> Enter PEM pass phrase:
>>>>
>>>>
>>>>
>>>> As per the sequence of certificates on command line, I gave password
>>>> for e.g. for cert.pem(server certificate file) , I have given Server@123,
>>>> and for cacert.key(CA private key) and cacert.pem(CA certificate) , I have
>>>> given test123.
>>>>
>>>> NOTE: These passwords are used while generating the respective
>>>> certificates means for generating cert.pem , I used Server@123 and so
>>>> on.
>>>>
>>>> So on above scenario , I have given password Server@123,test123 and
>>>> test123 on command prompt but it is giving following error on browser:
>>>>
>>>>
>>>>
>>>> *Secure Connection Failed
>>>>
>>>>  An error occurred during a connection to 127.0.0.1:8000.
>>>>
>>>> Cannot communicate securely with peer: no common encryption
>>>> algorithm(s).
>>>>
>>>> (Error code: ssl_error_no_cypher_overlap)
>>>>
>>>>   The page you are trying to view cannot be shown because the
>>>> authenticity of the received data could not be verified.
>>>>   Please contact the website owners to inform them of this problem.
>>>> Alternatively, use the command found in the help menu to report this broken
>>>> site.*
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Could anyone please help me out to resolve this issue?
>>>>
>>>>
>>>>
>>>> Regards,
>>>>
>>>> Amit
>>>>
>>>  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Re: Problem in deploying ssl certificates to Rocket server.

2012-11-04 Thread Amit
Thanks Niphold for replying. How can I create server cetificate, CA
certificate and client certificate without password? I am using simpatica
application to create all these certificates on windows XP machine and this
application doesn't allow to create certificates without password so if you
know any other way to create these certificates without password on windows
then please do share me.

waiting for your response.

Thanks,
Amit

On Fri, Nov 2, 2012 at 6:23 PM, Niphlod  wrote:

> certs are supposed to be generated without passwords. Even in apache, etc,
> if you protect them with a password it will be asked every time the process
> is started, and web2py (rocket) doesn't support that.
>
>
> On Friday, November 2, 2012 6:21:00 AM UTC+1, Amit wrote:
>>
>> Hi ,
>>
>> I generated CA certificates, private key, server certificate and client
>> certificate using “Simpatica” application developed in web2py.
>>
>> But when I tried to deploy the certificates to rocket server using below
>> command on windows XP machine:
>>
>>
>>
>> D:\web2py2.1.1\web2py>web2py.**py --ssl_certificate=D:\**
>> certificates\server\cert.pe
>>
>> m --ssl_private_key=D:\**certificates\private_key\**cacert.key
>> --ca-cert=D:\certific
>>
>> ates\CA_certificate\cacrt.pem
>>
>>
>>
>> It starts web2py server dialog asking about password and after giving
>> password, it displays below information on the command prompt:
>>
>>
>>
>> No handlers could be found for logger "web2py"
>>
>> web2py Web Framework
>>
>> Created by Massimo Di Pierro, Copyright 2007-2012
>>
>> Version 2.1.1 (2012-10-15 12:44:40) stable
>>
>> Database drivers available: SQLite(sqlite3), MySQL(pymysql),
>> PostgreSQL(pg8000),
>>
>>  IMAP(imaplib)
>>
>> please visit:
>>
>> https://127.0.0.1:8000
>>
>> starting browser...
>>
>> Enter PEM pass phrase:
>>
>> Enter PEM pass phrase:
>>
>> Enter PEM pass phrase:
>>
>>
>>
>> As per the sequence of certificates on command line, I gave password for
>> e.g. for cert.pem(server certificate file) , I have given Server@123,
>> and for cacert.key(CA private key) and cacert.pem(CA certificate) , I have
>> given test123.
>>
>> NOTE: These passwords are used while generating the respective
>> certificates means for generating cert.pem , I used Server@123 and so on.
>>
>> So on above scenario , I have given password Server@123,test123 and
>> test123 on command prompt but it is giving following error on browser:
>>
>>
>>
>> *Secure Connection Failed
>>
>>  An error occurred during a connection to 127.0.0.1:8000.
>>
>> Cannot communicate securely with peer: no common encryption algorithm(s).
>>
>> (Error code: ssl_error_no_cypher_overlap)
>>
>>   The page you are trying to view cannot be shown because the
>> authenticity of the received data could not be verified.
>>   Please contact the website owners to inform them of this problem.
>> Alternatively, use the command found in the help menu to report this broken
>> site.*
>>
>>
>>
>>
>>
>> Could anyone please help me out to resolve this issue?
>>
>>
>>
>> Regards,
>>
>> Amit
>>
>  --
>
>
>
>

-- 





[web2py] Problem in deploying ssl certificates to Rocket server.

2012-11-01 Thread Amit
 

Hi ,

I generated CA certificates, private key, server certificate and client 
certificate using “Simpatica” application developed in web2py. 

But when I tried to deploy the certificates to rocket server using below 
command on windows XP machine:

 

D:\web2py2.1.1\web2py>web2py.py 
--ssl_certificate=D:\certificates\server\cert.pe

m --ssl_private_key=D:\certificates\private_key\cacert.key 
--ca-cert=D:\certific

ates\CA_certificate\cacrt.pem

 

It starts web2py server dialog asking about password and after giving 
password, it displays below information on the command prompt:

 

No handlers could be found for logger "web2py"

web2py Web Framework

Created by Massimo Di Pierro, Copyright 2007-2012

Version 2.1.1 (2012-10-15 12:44:40) stable

Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
PostgreSQL(pg8000),

 IMAP(imaplib)

please visit:

https://127.0.0.1:8000

starting browser...

Enter PEM pass phrase:

Enter PEM pass phrase:

Enter PEM pass phrase:

 

As per the sequence of certificates on command line, I gave password for 
e.g. for cert.pem(server certificate file) , I have given Server@123, and 
for cacert.key(CA private key) and cacert.pem(CA certificate) , I have 
given test123.

NOTE: These passwords are used while generating the respective certificates 
means for generating cert.pem , I used Server@123 and so on.

So on above scenario , I have given password Server@123,test123 and test123 
on command prompt but it is giving following error on browser:

 

*Secure Connection Failed
   
 An error occurred during a connection to 127.0.0.1:8000.

Cannot communicate securely with peer: no common encryption algorithm(s).

(Error code: ssl_error_no_cypher_overlap)

  The page you are trying to view cannot be shown because the authenticity 
of the received data could not be verified.
  Please contact the website owners to inform them of this problem. 
Alternatively, use the command found in the help menu to report this broken 
site.*

 

 

Could anyone please help me out to resolve this issue?

 

Regards,

Amit

-- 





[web2py] Problem in SQLFORM.grid()

2012-10-28 Thread Amit
 

Hi ,

 I have one specific problem in grid UI which describes below:

 I am having one table called “device_config_info”:

db.define_table(

*'device_config_info'*,

*Field(**'mac_id'**,requires=IS_NOT_EMPTY(),readable=**True*
*,writable=**False**),***

*Field*(*'serial_no'*,requires=*IS_NOT_EMPTY*()),

*Field*(*'name'*,requires=*IS_NOT_EMPTY*()),

*Field*(*'email_ids'*,*'text'*,requires=*IS_NOT_EMPTY*())

   )) 

And corresponding controller function which will generates grid view:

*@auth.requires_login*()

def device():

mac_id=*get_mac_id*(*auth*.user.email)

query=(*db*.device_config_info.mac_id == mac_id)

grid = *SQLFORM*.grid(query)

return locals()

Here, get_mac_id() function will return the gateway mac id registered for 
the logged-in user.

This function will lists all devices info which are registered by a 
particular user,and  we can see set of buttons like View,Edit,Delete,Add 
etc… and upon clicking on these buttons, everything is working as expected 
except Add button.

When I click on Add button it displays Screen with all fields of  
device_config_info table where user can fill the info and create new record 
but here I am facing problem regarding mac_id.

In this screen, problem is Mac Id is displaying as “None”, please note that 
This field is disabled on UI and on database level it has made as Writable 
= False. I want to display the mac id for the user who has currently logged 
in, so how can I pass and display mac id on the screen upon click of Add 
button on the Grid view?Means, when user clicks on Add button on grid view 
,somehow I need to display the mac_id to the mac_id field of Add screen.

Second problem is : How can I make “Email Ids” field to accept only email 
ids and maximum number of email ids should be allowed to enter is 5?

Please help me resolve this issue.

Regards,

Amit

-- 





Re: [web2py] Re: How to call controller function upon onClick from html?

2012-09-02 Thread Amit
Thanks Anthony :)

Regards,
Amit

On Fri, Aug 31, 2012 at 4:47 PM, Anthony  wrote:

> On Thursday, August 30, 2012 10:44:51 PM UTC-4, Amit wrote:
>>
>> As I told you I have created my own custom html without extending
>> layout.html.
>
>
> "I have created my own custom html" != "I have not loaded jQuery"
>
>   :-)
>
>
>> I am not sure how to load JQuery in that?
>>
>
> It's just a Javascript library, so can be loaded like any other Javascript
> library.
>
> To get it from Google's CDN:
>
>  >
>
> or if you have the version included with web2py:
>
>  >
>
> Anthony
>
> --
>
>
>
>

-- 





Re: [web2py] Re: How to call controller function upon onClick from html?

2012-08-30 Thread Amit
As I told you I have created my own custom html without extending
layout.html. I am not sure how to load JQuery in that?

Please check the whole html file in attachement once and suggest me how to
support JQuery in the html.

Regards,
Amit

On Thu, Aug 30, 2012 at 4:53 PM, Anthony  wrote:

> The query method works fine for me. Are you sure you have jquery loaded?
>
>
> On Thursday, August 30, 2012 7:13:26 AM UTC-4, Amit wrote:
>
>> Hi Anthony,
>>
>> I am able to achieve it through Javascript function like below:
>>
>> function submitVlaue(thisForm)
>> {
>> var recordName = thisForm.name_text_field.**value;
>>
>> window.location="{{=URL('**default', 'recordr_config') + '/'}}"
>> + recordName ;
>> }
>>
>> but if I use JQuery instead of directly putting record name, its not
>> working.Please suggest is it a proper way to send the parameters to the
>> controller function.
>>
>> Regards,
>> Amit
>>
>> On Thu, Aug 30, 2012 at 2:44 PM, Amit  wrote:
>>
>>> Anthony,
>>> I observe one more thing, as I have launched record Info page from other
>>> page using below statement:
>>>
>>> >> disabled="disabled"
>>> onClick = 'window.location="{{=URL('**default', 'record_config',
>>> args=[row.record_id])}}";'>
>>>
>>>
>>> So upon clicking on button , it is launching record_config page , first
>>> it will call record_config() function and I am passing record_id to fetch
>>> the data about the record and display on the record_config page , so
>>> record_config page will display all data about the record( for e.g
>>> record_id, record_name etc...)
>>>
>>> Now what is my observation is : the URL of record_config page, it is
>>> showing like:
>>>
>>> http://127.0.0.1:8000/record_**App/default/record_config/**45326699<http://127.0.0.1:8000/record_App/default/record_config/45326699>
>>>
>>> where the number (45326699) indicates the record_id.
>>>
>>> One test i have done :
>>> I have written one javascript function with alert message and calling
>>> from onclick of the save button on the record_config page, but it is not
>>> invoking the javascript function so I am suspecting the above URL is
>>> different from record_config page, may be some temporary page is getting
>>> created with these values.
>>>
>>> what I understood is this page is not record_config page that's why it
>>> is not calling onclick of the button , hence not calling javascript, JQuery
>>> stuffs also.
>>>
>>> Please provide your inputs on this.
>>>
>>> Regards,
>>> Amit
>>>
>>>
>>> On Thu, Aug 30, 2012 at 2:11 PM, Amit  wrote:
>>>
>>>> Still the same issue :(  , its not calling record_config() function...
>>>> how to check whether JQuery is supported or not? I have created my own
>>>> custom html page without mentioning {{extend 'layout.html'}} statement,
>>>> means simple html page withe labels and text fields, so do I need to add
>>>> some statement in my html file to support JQuery?
>>>>
>>>>
>>>> On Thu, Aug 30, 2012 at 12:40 PM, Anthony  wrote:
>>>>
>>>>> Replace the single quotes with double quotes inside the jQuery():
>>>>>
>>>>> onClick='window.location="{{=**URL('default', 'record_config') + '/'}}"
>>>>> +
>>>>>  jQuery("input[name=name_text_**
>>>>> field]").val();'
>>>>>
>>>>> The value will be available as request.args(0) in the record_config()
>>>>> function.
>>>>>
>>>>> Anthony
>>>>>
>>>>>
>>>>> On Thursday, August 30, 2012 2:41:40 AM UTC-4, Amit wrote:
>>>>>>
>>>>>> Hi Anthony,
>>>>>> I used the code which you have suggested but it's not working at all,
>>>>>> it is not calling record_config() function of controller.
>>>>>>
>>>>>> >>>>>onClick='window.location="{{=URL('default', 'record_config')
>>>>>> + '/'}}" + jQuery('input[name=name_text_**f**ield]').val();'>
>>>>>>
&g

Re: [web2py] Re: How to call controller function upon onClick from html?

2012-08-30 Thread Amit
Hi Anthony,

I am able to achieve it through Javascript function like below:

function submitVlaue(thisForm)
{
var recordName = thisForm.name_text_field.value;

window.location="{{=URL('default', 'recordr_config') + '/'}}" +
recordName ;
}

but if I use JQuery instead of directly putting record name, its not
working.Please suggest is it a proper way to send the parameters to the
controller function.

Regards,
Amit

On Thu, Aug 30, 2012 at 2:44 PM, Amit  wrote:

> Anthony,
> I observe one more thing, as I have launched record Info page from other
> page using below statement:
>
>  disabled="disabled"
> onClick = 'window.location="{{=URL('default', 'record_config',
> args=[row.record_id])}}";'>
>
>
> So upon clicking on button , it is launching record_config page , first it
> will call record_config() function and I am passing record_id to fetch the
> data about the record and display on the record_config page , so
> record_config page will display all data about the record( for e.g
> record_id, record_name etc...)
>
> Now what is my observation is : the URL of record_config page, it is
> showing like:
>
> http://127.0.0.1:8000/record_App/default/record_config/45326699
>
> where the number (45326699) indicates the record_id.
>
> One test i have done :
> I have written one javascript function with alert message and calling from
> onclick of the save button on the record_config page, but it is not
> invoking the javascript function so I am suspecting the above URL is
> different from record_config page, may be some temporary page is getting
> created with these values.
>
> what I understood is this page is not record_config page that's why it is
> not calling onclick of the button , hence not calling javascript, JQuery
> stuffs also.
>
> Please provide your inputs on this.
>
> Regards,
> Amit
>
>
> On Thu, Aug 30, 2012 at 2:11 PM, Amit  wrote:
>
>> Still the same issue :(  , its not calling record_config() function...
>> how to check whether JQuery is supported or not? I have created my own
>> custom html page without mentioning {{extend 'layout.html'}} statement,
>> means simple html page withe labels and text fields, so do I need to add
>> some statement in my html file to support JQuery?
>>
>>
>> On Thu, Aug 30, 2012 at 12:40 PM, Anthony  wrote:
>>
>>> Replace the single quotes with double quotes inside the jQuery():
>>>
>>> onClick='window.location="{{=URL('default', 'record_config') + '/'}}" +
>>>  jQuery("input[name=name_text_field]").val();'
>>>
>>> The value will be available as request.args(0) in the record_config()
>>> function.
>>>
>>> Anthony
>>>
>>>
>>> On Thursday, August 30, 2012 2:41:40 AM UTC-4, Amit wrote:
>>>>
>>>> Hi Anthony,
>>>> I used the code which you have suggested but it's not working at all,
>>>> it is not calling record_config() function of controller.
>>>>
>>>> >>>onClick='window.location="{{=**URL('default', 'record_config') + '/'}}"
>>>> + jQuery('input[name=name_text_**field]').val();'>
>>>>
>>>>
>>>> second point is if the above approach is successful then how would I
>>>> retrieve the value in controller side:
>>>>
>>>> def record_config():
>>>>  print 'inside record_config'
>>>>  print request.input['name']
>>>>
>>>> Do I need to use Input list to retrieve the value? OR is there any
>>>> other way to retrieve?
>>>>
>>>>
>>>> On Wednesday, 29 August 2012 19:50:15 UTC+5:30, Anthony wrote:
>>>>>
>>>>>  >>>>> onclick = 'window.location="{{=URL('defa**ult', 'record_config',
>>>>>> args=[name_text_field.value])}**}";'>
>>>>>>
>>>>>
>>>>> You cannot refer to name_text_field the way you have. Everything
>>>>> inside {{..}} is Python and must be available on the server before the 
>>>>> HTML
>>>>> is rendered and sent to the browser. The input field value is available on
>>>>> the client side and must be retrieved via Javascript. You could do:
>>>>>
>>>>> onclick='window.location="{{=**URL('default', 'record_config') + '/'}}"
>>>>> + jQuery('input[name=name_text_**field]').val();'
>>>>>
>>>>> Anthony
>>>>>
>>>>  --
>>>
>>>
>>>
>>>
>>
>>
>

-- 





Re: [web2py] Re: How to call controller function upon onClick from html?

2012-08-30 Thread Amit
Anthony,
I observe one more thing, as I have launched record Info page from other
page using below statement:




So upon clicking on button , it is launching record_config page , first it
will call record_config() function and I am passing record_id to fetch the
data about the record and display on the record_config page , so
record_config page will display all data about the record( for e.g
record_id, record_name etc...)

Now what is my observation is : the URL of record_config page, it is
showing like:

http://127.0.0.1:8000/record_App/default/record_config/45326699

where the number (45326699) indicates the record_id.

One test i have done :
I have written one javascript function with alert message and calling from
onclick of the save button on the record_config page, but it is not
invoking the javascript function so I am suspecting the above URL is
different from record_config page, may be some temporary page is getting
created with these values.

what I understood is this page is not record_config page that's why it is
not calling onclick of the button , hence not calling javascript, JQuery
stuffs also.

Please provide your inputs on this.

Regards,
Amit

On Thu, Aug 30, 2012 at 2:11 PM, Amit  wrote:

> Still the same issue :(  , its not calling record_config() function...
> how to check whether JQuery is supported or not? I have created my own
> custom html page without mentioning {{extend 'layout.html'}} statement,
> means simple html page withe labels and text fields, so do I need to add
> some statement in my html file to support JQuery?
>
>
> On Thu, Aug 30, 2012 at 12:40 PM, Anthony  wrote:
>
>> Replace the single quotes with double quotes inside the jQuery():
>>
>> onClick='window.location="{{=URL('default', 'record_config') + '/'}}" +
>>  jQuery("input[name=name_text_field]").val();'
>>
>> The value will be available as request.args(0) in the record_config()
>> function.
>>
>> Anthony
>>
>>
>> On Thursday, August 30, 2012 2:41:40 AM UTC-4, Amit wrote:
>>>
>>> Hi Anthony,
>>> I used the code which you have suggested but it's not working at all, it
>>> is not calling record_config() function of controller.
>>>
>>> >>onClick='window.location="{{=**URL('default', 'record_config') + '/'}}"
>>> + jQuery('input[name=name_text_**field]').val();'>
>>>
>>>
>>> second point is if the above approach is successful then how would I
>>> retrieve the value in controller side:
>>>
>>> def record_config():
>>>  print 'inside record_config'
>>>  print request.input['name']
>>>
>>> Do I need to use Input list to retrieve the value? OR is there any other
>>> way to retrieve?
>>>
>>>
>>> On Wednesday, 29 August 2012 19:50:15 UTC+5:30, Anthony wrote:
>>>>
>>>>  >>>> onclick = 'window.location="{{=URL('defa**ult', 'record_config',
>>>>> args=[name_text_field.value])}**}";'>
>>>>>
>>>>
>>>> You cannot refer to name_text_field the way you have. Everything inside
>>>> {{..}} is Python and must be available on the server before the HTML is
>>>> rendered and sent to the browser. The input field value is available on the
>>>> client side and must be retrieved via Javascript. You could do:
>>>>
>>>> onclick='window.location="{{=**URL('default', 'record_config') + '/'}}"
>>>> + jQuery('input[name=name_text_**field]').val();'
>>>>
>>>> Anthony
>>>>
>>>  --
>>
>>
>>
>>
>
>

-- 





Re: [web2py] Re: How to call controller function upon onClick from html?

2012-08-30 Thread Amit
Still the same issue :(  , its not calling record_config() function...
how to check whether JQuery is supported or not? I have created my own
custom html page without mentioning {{extend 'layout.html'}} statement,
means simple html page withe labels and text fields, so do I need to add
some statement in my html file to support JQuery?

On Thu, Aug 30, 2012 at 12:40 PM, Anthony  wrote:

> Replace the single quotes with double quotes inside the jQuery():
>
> onClick='window.location="{{=URL('default', 'record_config') + '/'}}" +
>  jQuery("input[name=name_text_field]").val();'
>
> The value will be available as request.args(0) in the record_config()
> function.
>
> Anthony
>
>
> On Thursday, August 30, 2012 2:41:40 AM UTC-4, Amit wrote:
>>
>> Hi Anthony,
>> I used the code which you have suggested but it's not working at all, it
>> is not calling record_config() function of controller.
>>
>> >onClick='window.location="{{=**URL('default', 'record_config') + '/'}}"
>> + jQuery('input[name=name_text_**field]').val();'>
>>
>>
>> second point is if the above approach is successful then how would I
>> retrieve the value in controller side:
>>
>> def record_config():
>>  print 'inside record_config'
>>  print request.input['name']
>>
>> Do I need to use Input list to retrieve the value? OR is there any other
>> way to retrieve?
>>
>>
>> On Wednesday, 29 August 2012 19:50:15 UTC+5:30, Anthony wrote:
>>>
>>> >>> onclick = 'window.location="{{=URL('defa**ult', 'record_config',
>>>> args=[name_text_field.value])}**}";'>
>>>>
>>>
>>> You cannot refer to name_text_field the way you have. Everything inside
>>> {{..}} is Python and must be available on the server before the HTML is
>>> rendered and sent to the browser. The input field value is available on the
>>> client side and must be retrieved via Javascript. You could do:
>>>
>>> onclick='window.location="{{=**URL('default', 'record_config') + '/'}}"
>>> + jQuery('input[name=name_text_**field]').val();'
>>>
>>> Anthony
>>>
>>  --
>
>
>
>

-- 





Re: [web2py] Re: How to call controller function upon onClick from html?

2012-08-29 Thread Amit
Hi Anthony, 
I used the code which you have suggested but it's not working at all, it is 
not calling record_config() function of controller.




second point is if the above approach is successful then how would I 
retrieve the value in controller side:

def record_config():
 print 'inside record_config' 
 print request.input['name']

Do I need to use Input list to retrieve the value? OR is there any other 
way to retrieve?


On Wednesday, 29 August 2012 19:50:15 UTC+5:30, Anthony wrote:
>
> > onclick = 'window.location="{{=URL('default', 'record_config', 
>> args=[name_text_field.value])}}";'>
>>
>
> You cannot refer to name_text_field the way you have. Everything inside 
> {{..}} is Python and must be available on the server before the HTML is 
> rendered and sent to the browser. The input field value is available on the 
> client side and must be retrieved via Javascript. You could do:
>
> onclick='window.location="{{=URL('default', 'record_config') + '/'}}" + 
> jQuery('input[name=name_text_field]').val();'
>
> Anthony 
>

-- 





Re: [web2py] Re: How to pass html text field value to the controller function?

2012-08-29 Thread Amit
Thanks Anthony to provide the solution in my old post, let me try then will
let you know whether it is working or not.


On Wed, Aug 29, 2012 at 7:50 PM, Anthony  wrote:

> See https://groups.google.com/d/msg/web2py/z8-jyLTy-_w/0fJ34fL8JysJ.
>
> Anthony
>
>
> On Wednesday, August 29, 2012 6:18:57 AM UTC-4, Amit wrote:
>>
>> Hi,
>> I have to send textfield value from html to controller function, how to
>> achieve it, please see the code below :
>>
>> >
>>onClick = 'window.location="{{=URL('defa**ult', 'record_config
>> ',args[])}}";'>
>>
>>
>>
>> I have one text field on html page named record name, user can input the
>> name of the record which I want to pass to the record_config() function of
>> default.py but i am unable to do so because if I directly put in args
>> something like this args[record_txt_field.value] it is throwing error
>> saying "name record_txt_field not defined", it seems like we can't use
>> directly text field name inside python code so how to pass the value of
>> text field as an argument to the record_config function.
>>
>> Please help me resolve this issue.
>>
>  --
>
>
>
>

-- 





Re: [web2py] How to pass html text field value to the controller function?

2012-08-29 Thread Amit
Richard,
I only have to pass user input value to controller function which will
further save or update to the database, like in this case i want to
save/update record name value which user can change from UI so i need to
pass this updated value back to controller and controller function will
save back this value to db.

On Wed, Aug 29, 2012 at 7:26 PM, Richard Vézina  wrote:

> You need to make ajax call... There is web2py ajax, but you may need
> something more powerfull : jQuery.ajax().
>
> I assume that if you need to pass data back to controller function it
> because you want to display or modified your form base on the input value...
>
> I will need more information in order to help you and I may be not the
> best at this, but there is surely more experienced user that will help.
>
> Would you show you call back function and explain what you want to do once
> you have pass the input value to this function.
>
> Richard
>
>
> On Wed, Aug 29, 2012 at 6:18 AM, Amit  wrote:
>
>> Hi,
>> I have to send textfield value from html to controller function, how to
>> achieve it, please see the code below :
>>
>> >
>>onClick = 'window.location="{{=URL('default', 'record_config
>> ',args[])}}";'>
>>
>>
>>
>> I have one text field on html page named record name, user can input the
>> name of the record which I want to pass to the record_config() function of
>> default.py but i am unable to do so because if I directly put in args
>> something like this args[record_txt_field.value] it is throwing error
>> saying "name record_txt_field not defined", it seems like we can't use
>> directly text field name inside python code so how to pass the value of
>> text field as an argument to the record_config function.
>>
>> Please help me resolve this issue.
>>
>> --
>>
>>
>>
>>
>
>  --
>
>
>
>

-- 





[web2py] How to pass html text field value to the controller function?

2012-08-29 Thread Amit
Hi,
I have to send textfield value from html to controller function, how to 
achieve it, please see the code below :
 




I have one text field on html page named record name, user can input the 
name of the record which I want to pass to the record_config() function of 
default.py but i am unable to do so because if I directly put in args 
something like this args[record_txt_field.value] it is throwing error 
saying "name record_txt_field not defined", it seems like we can't use 
directly text field name inside python code so how to pass the value of 
text field as an argument to the record_config function.

Please help me resolve this issue.

-- 





Re: [web2py] Re: How to call controller function upon onClick from html?

2012-08-28 Thread Amit
Anthony,
 I am facing one more problem, I have one text Field called Name where user
can input the name , i need to pass the entered name to controller function
but if I use like:



it is flashing error saying "name name_text_field is not defined" , even
text field is there in same form ,inside same table but still it is giving
same error so how to get the text field value and pass it to the args?

Regards,
Amit

On Mon, Aug 27, 2012 at 7:21 PM, Anthony  wrote:

> The onclick property of an HTML element must be Javascript. You cannot
> call a server-side Python function directly from the browser. If you want
> the button to work like a regular link and simply load a new page in place
> of the current page, you can do:
>
>  onclick = 'window.location="{{=URL('default', 'record_config',
> args=[record_id])}}";'>
>
> In that case, you would need Python code in the view to get the record_id
> for each link (presumably the buttons would be generated in a for loop that
> cycles through the record id's).
>
> Anthony
>
>
> On Monday, August 27, 2012 7:27:20 AM UTC-4, Amit wrote:
>>
>> Hi,
>> I have created one html file with list of records, each records are there
>> in a row of table in
>>
>> html and there is one corresponding button (type as button) for each
>> record so when user clicks
>>
>> on it , it should take the id of that record from the html call
>> controller function which will
>>
>> further use id to fetch the complete records from the database and
>> rendered the data onto the new
>>
>> html page.
>>
>> below is the button creation code in html:
>>
>> 
>>
>> > >
>>
>> 
>>
>> 
>>
>>
>>
>> here record_config() function defined in controller (default.py) which
>> will fetch data from db
>>
>> and display to another html page named "record_config.html".
>>
>> Problem:
>> record_config() function is not getting called upon clicking on the
>> button, can anyone please
>>
>> suggest me the possible way to achieve the same?
>>
>  --
>
>
>
>

-- 





[web2py] Re: How to call controller function upon onClick from html?

2012-08-27 Thread Amit
Thanks Anthony, its working as expected :)

regards,
Amit

On Monday, 27 August 2012 19:21:46 UTC+5:30, Anthony wrote:
>
> The onclick property of an HTML element must be Javascript. You cannot 
> call a server-side Python function directly from the browser. If you want 
> the button to work like a regular link and simply load a new page in place 
> of the current page, you can do:
>
>  onclick = 'window.location="{{=URL('default', 'record_config', 
> args=[record_id])}}";'>
>
> In that case, you would need Python code in the view to get the record_id 
> for each link (presumably the buttons would be generated in a for loop that 
> cycles through the record id's).
>
> Anthony
>
> On Monday, August 27, 2012 7:27:20 AM UTC-4, Amit wrote:
>>
>> Hi,
>> I have created one html file with list of records, each records are there 
>> in a row of table in 
>>
>> html and there is one corresponding button (type as button) for each 
>> record so when user clicks 
>>
>> on it , it should take the id of that record from the html call 
>> controller function which will 
>>
>> further use id to fetch the complete records from the database and 
>> rendered the data onto the new 
>>
>> html page.
>>
>> below is the button creation code in html:
>>
>> 
>>
>> > >
>>
>> 
>>
>> 
>>
>>
>>
>> here record_config() function defined in controller (default.py) which 
>> will fetch data from db 
>>
>> and display to another html page named "record_config.html".
>>
>> Problem:
>> record_config() function is not getting called upon clicking on the 
>> button, can anyone please 
>>
>> suggest me the possible way to achieve the same?
>>
>

-- 





[web2py] Re: how to send function arguments value from redirect()?

2012-08-27 Thread Amit
Found the solution :), please find below the working code:

redirect(URL(r=request,f='record_config',vars={'record_id':recordId}))

def record_config():
recordid = request.vars.record_id


it will give you the value of record id inside function redirect().




On Tuesday, 28 August 2012 11:09:56 UTC+5:30, Amit wrote:
>
> hi,
> I have to send the arguments value from redirect to the target function, 
> for e.g:
>
> redirect(URL(r=request,f='record_config'))
>
> def record_config(record_id):
> 
>
> I have to send the value of record_id from the redirect() to the 
> record_config() function OR is it some other way to send value of record_id 
> and access it inside record_config() function So i can avoid defining 
> argument in the function?
>
>

-- 





[web2py] how to send function arguments value from redirect()?

2012-08-27 Thread Amit
hi,
I have to send the arguments value from redirect to the target function, 
for e.g:

redirect(URL(r=request,f='record_config'))

def record_config(record_id):


I have to send the value of record_id from the redirect() to the 
record_config() function OR is it some other way to send value of record_id 
and access it inside record_config() function So i can avoid defining 
argument in the function?

-- 





[web2py] How to call controller function upon onClick from html?

2012-08-27 Thread Amit
Hi,
I have created one html file with list of records, each records are there 
in a row of table in 

html and there is one corresponding button (type as button) for each record 
so when user clicks 

on it , it should take the id of that record from the html call controller 
function which will 

further use id to fetch the complete records from the database and rendered 
the data onto the new 

html page.

below is the button creation code in html:











here record_config() function defined in controller (default.py) which will 
fetch data from db 

and display to another html page named "record_config.html".

Problem:
record_config() function is not getting called upon clicking on the button, 
can anyone please 

suggest me the possible way to achieve the same?

-- 





Re: [web2py] Re: how to use javascript code in web2py html pages?

2012-08-26 Thread Amit
Thanks Anthony to finding the issue, after modifying the code as per your
suggestion,its working fine now.

Regards,
Amit

On Fri, Aug 24, 2012 at 5:01 PM, Anthony  wrote:

> Also, a tip -- if you think web2py is causing a problem with your code,
> try the code in a page not served by web2py (e.g., just a static HTML
> page), and see if it works.
>
> Anthony
>
>
> On Friday, August 24, 2012 7:29:16 AM UTC-4, Anthony wrote:
>>
>> Yes, web2py supports Javascript functions (you can do whatever you want
>> on the client side). In a couple places, your code has the wrong kind of
>> quotes -- instead of " you have ”. In particular:
>>
>> onSubmit=”return textFieldValidation();”
>>
>> should be:
>>
>> onSubmit="return textFieldValidation();"
>>
>> and
>>
>> 
>>
>> should be:
>>
>> <SCRIPT LANGUAGE="javascript">
>>
>> Actually, the language attribute has been deprecated -- so it should
>> really just be:
>>
>> <script>
>>
>> Anthony
>>
>> On Friday, August 24, 2012 2:35:52 AM UTC-4, Amit wrote:
>>>
>>> Hi,
>>> I have html file with one text field with submit button inside form.I
>>> added javascript code to validate the textfield but its not working at all,
>>> why is it so? does web2py not support javascript function?
>>>
>>> please check below the code :
>>>
>>> <SCRIPT LANGUAGE=”javascript”>
>>> function textFieldValidation()
>>> {
>>> var x=document.forms["text_form"][**"test_textField"].value
>>> if (x==null || x==""||x=="00:00:00:00:00:00")
>>>   {
>>>   alert("text field should not be empty");
>>>   return false;
>>>   }
>>> }
>>> 
>>>
>>>
>>> In form tag:
>>>
>>> >> textFieldValidation();”>
>>> 
>>> 
>>>   Enter value:
>>>   >> "17"
>>> name=test_textField>
>>>
>>> 
>>> >> align=middle>>> >
>>> 
>>> 
>>>
>>>
>>>
>>>  --
>
>
>
>

-- 





[web2py] how to use javascript code in web2py html pages?

2012-08-23 Thread Amit
Hi,
I have html file with one text field with submit button inside form.I added 
javascript code to validate the textfield but its not working at all, why 
is it so? does web2py not support javascript function?

please check below the code :


function textFieldValidation()
{
var x=document.forms["text_form"]["test_textField"].value
if (x==null || x==""||x=="00:00:00:00:00:00")
  {
  alert("text field should not be empty");
  return false;
  }
}



In form tag:




  Enter value:
  








-- 





Re: [web2py] Re: how to parse xml in web2py?

2012-08-23 Thread Amit
Thanks guys for helping me to write xml parsing in python..I will use
ElementTree Or cElementTree to extract data from xml and let you people
know about the outcome.

@Anthony: My mistatke :( , I manually written the xml so did mistake on
matching opening and closing tags.

Thanks once again
Amit

On Thu, Aug 23, 2012 at 8:48 PM, villas  wrote:

> If the XML is not well-formed, take a look at beautiful soup.   I have
> never found a parser so tolerant and forgiving.
>
>
> On Thursday, August 23, 2012 2:59:25 PM UTC+1, Anthony wrote:
>>
>> For simple parsing, you can also use the built-in TAG() helper -- see
>> http://web2py.com/books/**default/chapter/29/5#Parsing<http://web2py.com/books/default/chapter/29/5#Parsing>
>> .
>>
>> FYI, in your example, some of the closing tags do not match their
>> associated opening tags.
>>
>> Anthony
>>
>> On Thursday, August 23, 2012 5:53:32 AM UTC-4, Amit wrote:
>>>
>>> Hi,
>>> I have web service method in my application which will receive xml file
>>> from the request, i need to parse it and save the extracted data to the
>>> database. Please suggest me the best way to parse xml in web2py.
>>>
>>> xml format would be like below:
>>>
>>> 
>>> 
>>>   
>>> 123456
>>> 2012-06-30
>>> 1
>>> **adadafdfdgfgfhggjghjjj
>>>   
>>> 
>>>
>>  --
>
>
>
>

-- 





[web2py] how to parse xml in web2py?

2012-08-23 Thread Amit
Hi,
I have web service method in my application which will receive xml file 
from the request, i need to parse it and save the extracted data to the 
database. Please suggest me the best way to parse xml in web2py.

xml format would be like below:



  
123456
2012-06-30
1
adadafdfdgfgfhggjghjjj
  


-- 





Re: [web2py] Re: Help me to write SQL query in web2py

2012-08-23 Thread Amit
It should work from inside select() also, i used it only for convenient.

Regards,
Amit

On Wed, Aug 22, 2012 at 5:33 PM, mcamel  wrote:

> Amit,
>
> Does it works if you use tbl.created_on.max() inside the select(), instead
> of max_created_on?.
>
> I mean, is it necessary to define max_created_on or just convenient for
> short.
>
> Thanks.
>
>
>
> On Wednesday, August 22, 2012 8:32:23 AM UTC+2, Amit wrote:
>>
>> Hi mcamel,
>>
>> Please find below the working code:
>>
>> from gluon.dal import Expression
>>
>> tbl = db.abc_tbl
>> max_created_on = tbl.created_on.max()
>> query = Expression(db,"date_sub(now(), interval interval_time minute) >
>> created_on")rows=db(query).select(tbl.**device_id,tbl.sensor_id,tbl.*
>> *interval_time,max_created_on,**groupby=tbl.device_id|tbl.**sensor_id)
>>
>> Regards,
>> Amit
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Database interaction with custom html in web2py.

2012-08-23 Thread Amit
Thanks Anthony for your response, it looks like this will generate UI based
on the record but I have my own custom html on which I have to perform
submit operation , second thing i have to display all inserted records in
different custom html with some extra information also how to achieve it in
web2py?
For example:
I have employe table filled with some employee records and i have to read
the table and display the employees on one html page , in addition to that
i have to provide provision to the user that they can modify the record
from there means there will be one modify button available  for each
employee record so user can click which can open employee edit html page
and from there user can change employee details and save it to the
database, what is the best way to achieve it in web2py?

Regards,
Amit

On Wed, Aug 22, 2012 at 8:38 PM, Anthony  wrote:

> Note, you don't necessarily need to do this with two separate actions:
>
> def copy_record():
> form = FORM('Enter record ID:', INPUT(_name='id', _type='integer'),
> INPUT(_type='submit', _value='Submit'))
> if request.post_vars.id:
> record = db.table1(request.post_vars.id)
> if record:
> db.table2.insert(**db.table2._filter_fields(record))
> response.flash = 'The record was copied'
> else:
> response.flash = 'A record with ID %s does not exist.' %request
> .post_vars.id
> return dict(form=form)
>
> Then in the copy_record.html view, you just need:
>
> {{=form}}
>
> Anthony
>
> On Wednesday, August 22, 2012 2:12:45 AM UTC-4, Khalil KHAMLICHI wrote:
>
>> 1) controller page1: controllers/default.py
>>
>> def page1:
>> return dict()
>>
>> 2) view page1: views/default/page1.html
>>
>> page1.html content :
>>
>> 
>>  Please Enter ID: 
>> 
>> 
>>
>> 3) controller page2: controllers/default.py
>>
>> def page2():
>> EnteredID = request.vars['EnteredID']
>> # 1 - check if record exists
>> record = db(db.YourTableNameHere.ID == EnteredID).select()[0]
>> if len(record):
>> # 2 insert it into a second table
>> db(db.SecondTableName).insert(**field1=record.field1,
>> field2=record.field2, field3=record.field3 )
>> return dict( result='Success' )
>> else:
>> return dict( result='Record Not Found')
>>
>> I believe you can build on top of this.
>>
>>
>> On Wed, Aug 22, 2012 at 6:52 AM, Amit  wrote:
>>
>>> Hi,
>>> I generated one custom html file which is having one text field where
>>> user has to enter id and one submit button.
>>>
>>> I have to use it in following manner:
>>> 1. User has to enter the id and press the submit button
>>> 2. after pressing submit button, id value has to be validated in xyz
>>> table.
>>> 3. first it has to validate whether entered id is available in xyz table
>>> or not, if not available then it has to notify the user about it
>>> 4. if id is available in xyz table then it will fetch the record of id
>>> from xyz table and insert it to another table called abc table.
>>>
>>> problem facing:
>>> I have to add this html to my web2py project and achieve the above
>>> functionality  , Can anybody help me to provide the solution how to use
>>> custom html and database interaction with it?
>>>
>>> --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Database interaction with custom html in web2py.

2012-08-21 Thread Amit
Thanks Khalil for providing solution with example..I will write as per
below instruction and let you know the result.

Thanks once again :)

Amit

On Wed, Aug 22, 2012 at 11:42 AM, Khalil KHAMLICHI <
khamlichi.kha...@gmail.com> wrote:

> 1) controller page1: controllers/default.py
>
> def page1:
> return dict()
>
> 2) view page1: views/default/page1.html
>
> page1.html content :
>
> 
>  Please Enter ID: 
> 
> 
>
> 3) controller page2: controllers/default.py
>
> def page2():
> EnteredID = request.vars['EnteredID']
> # 1 - check if record exists
> record = db(db.YourTableNameHere.ID == EnteredID).select()[0]
> if len(record):
> # 2 insert it into a second table
> db(db.SecondTableName).insert(field1=record.field1, field2=record.field2,
> field3=record.field3 )
> return dict( result='Success' )
> else:
> return dict( result='Record Not Found')
>
> I believe you can build on top of this.
>
>
>
> On Wed, Aug 22, 2012 at 6:52 AM, Amit  wrote:
>
>> Hi,
>> I generated one custom html file which is having one text field where
>> user has to enter id and one submit button.
>>
>> I have to use it in following manner:
>> 1. User has to enter the id and press the submit button
>> 2. after pressing submit button, id value has to be validated in xyz
>> table.
>> 3. first it has to validate whether entered id is available in xyz table
>> or not, if not available then it has to notify the user about it
>> 4. if id is available in xyz table then it will fetch the record of id
>> from xyz table and insert it to another table called abc table.
>>
>> problem facing:
>> I have to add this html to my web2py project and achieve the above
>> functionality  , Can anybody help me to provide the solution how to use
>> custom html and database interaction with it?
>>
>> --
>>
>>
>>
>>
>
>  --
>
>
>
>

-- 





Re: [web2py] Re: Help me to write SQL query in web2py

2012-08-21 Thread Amit
Hi mcamel,

Please find below the working code:

from gluon.dal import Expression

tbl = db.abc_tbl
max_created_on = tbl.created_on.max()
query = Expression(db,"date_sub(now(), interval interval_time minute) >
created_on")
rows=db(query).select(tbl.device_id,tbl.sensor_id,tbl.interval_time,max_created_on,groupby=tbl.device_id|tbl.sensor_id)

Regards,
Amit

On Wed, Aug 22, 2012 at 11:44 AM, mcamel  wrote:

> Hi Amit,
>
> Could you post the final code that works?.
>
> Thanks.
>
> --
>
>
>
>

-- 





[web2py] Database interaction with custom html in web2py.

2012-08-21 Thread Amit
Hi,
I generated one custom html file which is having one text field where user 
has to enter id and one submit button.

I have to use it in following manner:
1. User has to enter the id and press the submit button
2. after pressing submit button, id value has to be validated in xyz table.
3. first it has to validate whether entered id is available in xyz table or 
not, if not available then it has to notify the user about it
4. if id is available in xyz table then it will fetch the record of id from 
xyz table and insert it to another table called abc table.

problem facing:
I have to add this html to my web2py project and achieve the above 
functionality  , Can anybody help me to provide the solution how to use 
custom html and database interaction with it?

-- 





Re: [web2py] Re: NameError: global name 'requests' is not defined

2012-08-21 Thread Amit
I resolved the issue, somehow after installing it to Lib/site-packages of
python installation path , it has not added to PYTHONPATH, because of that
requests is not recognized, i have explicitly added it to the PYTHONPATH
then its working fine.

Thanks,
Amit

On Tue, Aug 21, 2012 at 4:02 PM, Amit  wrote:

> Thanks Niphold :), I installed requests libraries using easy install and
> able to see requests folder named "requests-0.13.8-py2.7.egg" in
> site-packages folder and used import statement like :
> from requests import *
>
> but still getting same error :(
>
> what I observed is : there is no module name "requests" in the library but
> there is a folder name "requests" available inside
> "requests-0.13.8-py2.7.egg" folder, so not sure what to import from this
> libray?
>
>
>
>
> On Tue, Aug 21, 2012 at 3:43 PM, Niphlod  wrote:
>
>> requests is a cool library (don't confuse that with the request object
>> (without the s) that is available in web2py).
>>
>> Their examples lacks of the import line (import requests).
>> Of course you need to install that to be able to use it with pip install
>> requests.
>>
>> Il giorno martedì 21 agosto 2012 12:09:24 UTC+2, Amit ha scritto:
>>>
>>> Hi,
>>> I am using mailgun libraries to send mail from my web2py application,I
>>> followed example given in mailgun site mailgun.com:
>>>
>>>
>>>1. 
>>> requests.post(("https://api.**mailgun.net/v2/samples.**mailgun.org/messages 
>>> <https://api.mailgun.net/v2/samples.mailgun.org/messages>"),
>>>2. auth=("api", "key-**3ax6xnjp29jd6fds4gc373sgvjxteo**l0"),
>>>3. data={
>>>4. "from": "Excited User ",
>>>5. "to": ["du...@mailgun.net",
>>>6."de...@mailgun.net"],
>>>7. "subject": "Hello",
>>>8. "text": "Testing some Mailgun awesomeness!"})
>>>
>>>
>>> but when i am using the above code, web2py gives error "NameError:
>>> global name 'requests' is not defined", what is this requests variable and
>>> how to initialize it?OR do i need to use some other libraries which already
>>> has this variable to make use of it.
>>>
>>> Please guide me to resolve this issue.
>>>
>>>
>>  --
>>
>>
>>
>>
>
>

-- 





Re: [web2py] Re: NameError: global name 'requests' is not defined

2012-08-21 Thread Amit
Thanks Niphold :), I installed requests libraries using easy install and
able to see requests folder named "requests-0.13.8-py2.7.egg" in
site-packages folder and used import statement like :
from requests import *

but still getting same error :(

what I observed is : there is no module name "requests" in the library but
there is a folder name "requests" available inside
"requests-0.13.8-py2.7.egg" folder, so not sure what to import from this
libray?



On Tue, Aug 21, 2012 at 3:43 PM, Niphlod  wrote:

> requests is a cool library (don't confuse that with the request object
> (without the s) that is available in web2py).
>
> Their examples lacks of the import line (import requests).
> Of course you need to install that to be able to use it with pip install
> requests.
>
> Il giorno martedì 21 agosto 2012 12:09:24 UTC+2, Amit ha scritto:
>>
>> Hi,
>> I am using mailgun libraries to send mail from my web2py application,I
>> followed example given in mailgun site mailgun.com:
>>
>>
>>1. 
>> requests.post(("https://api.**mailgun.net/v2/samples.**mailgun.org/messages 
>> <https://api.mailgun.net/v2/samples.mailgun.org/messages>"),
>>2. auth=("api", "key-**3ax6xnjp29jd6fds4gc373sgvjxteo**l0"),
>>3. data={
>>4. "from": "Excited User ",
>>5. "to": ["du...@mailgun.net",
>>6."de...@mailgun.net"],
>>7. "subject": "Hello",
>>8. "text": "Testing some Mailgun awesomeness!"})
>>
>>
>> but when i am using the above code, web2py gives error "NameError: global
>> name 'requests' is not defined", what is this requests variable and how to
>> initialize it?OR do i need to use some other libraries which already has
>> this variable to make use of it.
>>
>> Please guide me to resolve this issue.
>>
>>
>  --
>
>
>
>

-- 





[web2py] NameError: global name 'requests' is not defined

2012-08-21 Thread Amit
Hi,
I am using mailgun libraries to send mail from my web2py application,I 
followed example given in mailgun site mailgun.com:


   1. requests.post(("https://api.mailgun.net/v2/samples.mailgun.org/messages";),
   2. auth=("api", "key-3ax6xnjp29jd6fds4gc373sgvjxteol0"),
   3. data={
   4. "from": "Excited User ",
   5. "to": ["d...@mailgun.net",
   6."d...@mailgun.net"],
   7. "subject": "Hello",
   8. "text": "Testing some Mailgun awesomeness!"})


but when i am using the above code, web2py gives error "NameError: global 
name 'requests' is not defined", what is this requests variable and how to 
initialize it?OR do i need to use some other libraries which already has 
this variable to make use of it.

Please guide me to resolve this issue.
 

-- 





Re: [web2py] Re: Help me to write SQL query in web2py

2012-08-20 Thread Amit
Thanks a lot Massimo and mcamel, its working as expected :)

Regards,
Amit
On Sat, Aug 18, 2012 at 7:04 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> My bad. It should be
>
> t.created_on.max()
>
>
> On Saturday, 18 August 2012 04:26:37 UTC-5, mcamel wrote:
>>
>> Hi,
>>
>> Massimo, i really like your framework. Thank you very much for your
>> dedication.
>>
>> I'm newbie and don't want to bother but... i think some details are
>> missing in the manual so that we can build this kind of selects by our own,
>> or even understand the query below.
>>
>> Are there references to 'created_on' missing?. I mean, i expected your
>> 3rd line to be:
>> max_created_on = t.max(created_on)
>>
>> and then use one of the two sides of the expression on the 5th line:
>> db(query).select(t.device_id,**t.sensor_id,t.max(created_on),**...
>> or
>> db(query).select(t.device_id,**t.sensor_id,max_created_on,...
>>
>> also 4th line souldn't be...?:
>> query = Expression(db,"date_sub(now(), interval interval_time minute)
>> > created_on")
>>
>>
>> Hope not to bother.
>> Many thanks.
>>
>>
>> BTW, i offer myself to help to improve some parts of the manual from the
>> point of view of someone who is yet learning.
>>
>> Best regards,
>> mcamel.
>>
>>
>> On Friday, August 17, 2012 4:26:39 PM UTC+2, Massimo Di Pierro wrote:
>>>
>>> You can try this:
>>>
>>> from gluon.dal import Expression
>>> t = db.abc_tbl
>>> max_created_on = t.max()
>>> query = Expression(db,"date_sub(now(), interval interval_time minute)")
>>> db(query).select(t.device_id,**t.sensor_id,t.max(),group_by=**
>>> t.device_id|t.sensor_id)
>>>
>>> On Thursday, 16 August 2012 23:01:44 UTC-5, Amit wrote:
>>>>
>>>> I have written one sql query:
>>>>
>>>> select device_id, sensor_id, max(created_on) from test.abc_tbl where
>>>> date_sub(now(), interval interval_time minute) > created_on group by
>>>> device_id, sensor_id;
>>>
>>>
>>>> How to write it in web2py?
>>>>
>>>> Please help me to do the same.
>>>>
>>>> Thanks.
>>>>
>>>  --
>
>
>
>

-- 





[web2py] Help me to write SQL query in web2py

2012-08-16 Thread Amit
I have written one sql query:

select device_id, sensor_id, max(created_on) from test.abc_tbl where 
date_sub(now(), interval interval_time minute) > created_on group by 
device_id, sensor_id;

How to write it in web2py?

Please help me to do the same.

Thanks.

-- 





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

2012-08-09 Thread Amit
Hi,
Migrated to MySql from Sqlite and tested the purging feature, its working
as intended :)

Thanks a lot you guys for assisting me to resolve it :)

Regards,
Amit

On Thu, Aug 9, 2012 at 10:05 AM, Amit  wrote:

> 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 <
>>> massimo@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.**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: 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: 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] How to keep database connection alive ?

2012-08-07 Thread Amit

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] WARNING:web2py:unable to open SSL certificate. SSL is OFF in web2py 1.99.7

2012-08-02 Thread Amit
Hi,
I have installed web2py 1.99.7 stable version,python2.7.2, 
pyOpenSSL-0.13.winxp32-py2.7,M2Crypto-0.20.2-py2.7.egg-info and 
pycurl-7.19.0.win32-py2.7 in my pc. When i start Rocket server it is 
showing warning message *"WARNING:web2py:unable to open SSL certificate. 
SSL is OFF "*.

does PyOpenSSL-0.13 not supported by Web2py 1.99.7 version OR is there any 
other problem?

Can anyone please help me out how to resolve this issue?

Regards,
Amit

-- 





Re: [web2py] Re: how to achieve public/private key authentication for web service in web2py?

2012-07-31 Thread Amit
Problem facing to generate client and server certificates and key files:
I am not able to generate following files using simpatica:
1. server pem encoded cert file
2. server pem encoded key file
3. client pem encoded cert file
4. server pem encoded key file

I am able to create certificate using Public-->Require new certificate
option and it is listed on CA--> List pending request option , when i clcik
on any individual certificate listed on List pending request page , it is
asking for CA private key password and usage (client Auth,server Auth),
after submitting it will list in CA--> List signed certificates option.If I
have to choose one client Auth and one server Auth, it will listed in the
above page but how to download these two certificates and are these two be
server pem encoded cert file and client pem encoded cert file, if yes then
how to download these two and where is other two client and server pem
encoded key files , how to generate them?

On Tue, Jul 31, 2012 at 3:17 PM, Amit  wrote:

> Hi Michele,
> Still I am not able to achieve X509 authentication, I am able to generate
> following files using CA menu:
> cacert.key (CA private key)
> CA certificate request (cacsr.pem)
> CA self signed certificate(cacrt.pem)
>
> there is one more menu called Public  which is having options "Get CA
> certificate","Get CA certificate revocation list" and "Require New
> certificate"
>
> I tried using Required New certificate option and it generates some
> certificate something like below:
>  Certificate Request for
>
> /C=ZZ/CN=ffdfdf/L=Y/O=ACME/ST=X/emailAddress=rt...@dfgdg.com/SN=jhjhjhj/GN=fghfhfh/OU=Certification
>  Authority
>
>  -BEGIN CERTIFICATE REQUEST-
> MIIC+DCCAeACADCBszELMAkGA1UEBhMCWloxDzANBgNVBAMTBmZmZGZkZjEOMAwG
> A1UEBxMFWVlZWVkxDTALBgNVBAoTBEFDTUUxDjAMBgNVBAgTBVhYWFhYMR4wHAYJ
> KoZIhvcNAQkBFg9ydGVldEBkZmdkZy5jb20xEDAOBgNVBAQTB2poamhqaGoxEDAO
> BgNVBCoTB2ZnaGZoZmgxIDAeBgNVBAsTF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5
> MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo9PxvzHv/NAqYsUxm3YD
> MvW6GohKWPrHAP8XftRthBu4hDWUKT0IjOF6Sva4Pi7PkRuA9z2HfKVDETs5wy3o
> InvPcmjhUSTGynNI95AkXrGoBsiIlQwPNbBtRNLRA870OPDAlM04LQEj4+tIndtE
> jrNliOseAp286opRqQbA3bnB2wY4HKHxe3c118qeTmuv2B5g8fwbmADkp8N/PKk5
> Ami7d31Ava41m8x4k1hJ9SBitimmiOLs0Ua37BY/rtm57g6m0PqXhlPWvaBtnfr7
> 6q+E9ram6t9zWGFdNedfQjhGvyCUEMieXlRhCOC9J/6/al0WJ3mln02gY/sSS3TF
> 8QIDAQABoAAwDQYJKoZIhvcNAQEFBQADggEBAJIKf7kwxVGvlrATk6DPhu7dqEjw
> iAL41XTNjlR2780/wDBR5yUiCTtXFFuqAPagAn9i/qjb2gC5jZZmbUOhgYSyZpp/
> qznZFTg9MsVdszC/LBLkRpDCxqLm1m61WCi5qmHGq9nN55rtdwiJsglQkUwvFeUK
> SaMY95U+qakWqveCGzcmCoWir9zWKpBH1/Z89r5ktAsi7CdH9RdGQJeM8K8lBK3F
> fqhakKXiA+afPFnhwK+KSisJGJl573ocHXGL/obhuOPj0uunfgxIBxION4nVDPCn
> CTz7or24EltIZ5/e6T9PgvBbfUeMJ8WQEKVFlaqaJ+gAtl7FDHfOQmmUXN4= -END
> CERTIFICATE REQUEST-
>
>
> what is this certificate and where it is stored because i checked in
> private/ssl folder and i din't find any other certificate generated ?
> How to generate server and client private keys and certificates? as per
> your previous mail simaptica should generate following certificates:
>
> 1. generate ca priv key + self signed certificate
> 2. generate server priv keys +  certificates signed by the above ca
> certificate
> 3.  generate client priv keys + certificates signed by the above ca
>  certificate
>
>
> but I am not able to generate above 2. and 3. so pleae guide me to
> generate the same.
>
>
> Thanks,
> Amit
>
>
>>
>>
>> On Thu, Jul 26, 2012 at 10:50 AM, Amit  wrote:
>>
>>> Thanks Michele,I am going to generate keys using simpatica, I will let
>>> you know if i face any problem.
>>>
>>> Thanks,
>>> Amit
>>>
>>>
>>> On Wed, Jul 25, 2012 at 7:01 PM, Michele Comitini <
>>> michele.comit...@gmail.com> wrote:
>>>
>>>> 2012/7/25 Amit :
>>>> > Michele,
>>>> >
>>>> > I have gone through the X509_Auth class and its methods :
>>>> >
>>>> > login_form
>>>> >
>>>> > login_url
>>>> > get_user
>>>> >
>>>> > But not able to visualize how to use this class in my
>>>> model/controller, I
>>>> > just write below what I understood, please confirm
>>>> > whether I understood correctly or not.
>>>> >
>>>> >
>>>> > My requirement is : I have one web service method add() in controller
>>>> > default.py , I just want to enable x509 authentication
>>>> > so for that purpose i will use simpatica to generate keys and
>>>> certificates
>&g

Re: [web2py] Re: how to achieve public/private key authentication for web service in web2py?

2012-07-31 Thread Amit
Hi Michele,
Still I am not able to achieve X509 authentication, I am able to generate
following files using CA menu:
cacert.key (CA private key)
CA certificate request (cacsr.pem)
CA self signed certificate(cacrt.pem)

there is one more menu called Public  which is having options "Get CA
certificate","Get CA certificate revocation list" and "Require New
certificate"

I tried using Required New certificate option and it generates some
certificate something like below:
Certificate Request for

/C=ZZ/CN=ffdfdf/L=Y/O=ACME/ST=X/emailAddress=rt...@dfgdg.com/SN=jhjhjhj/GN=fghfhfh/OU=Certification
Authority

 -BEGIN CERTIFICATE REQUEST-
MIIC+DCCAeACADCBszELMAkGA1UEBhMCWloxDzANBgNVBAMTBmZmZGZkZjEOMAwG
A1UEBxMFWVlZWVkxDTALBgNVBAoTBEFDTUUxDjAMBgNVBAgTBVhYWFhYMR4wHAYJ
KoZIhvcNAQkBFg9ydGVldEBkZmdkZy5jb20xEDAOBgNVBAQTB2poamhqaGoxEDAO
BgNVBCoTB2ZnaGZoZmgxIDAeBgNVBAsTF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo9PxvzHv/NAqYsUxm3YD
MvW6GohKWPrHAP8XftRthBu4hDWUKT0IjOF6Sva4Pi7PkRuA9z2HfKVDETs5wy3o
InvPcmjhUSTGynNI95AkXrGoBsiIlQwPNbBtRNLRA870OPDAlM04LQEj4+tIndtE
jrNliOseAp286opRqQbA3bnB2wY4HKHxe3c118qeTmuv2B5g8fwbmADkp8N/PKk5
Ami7d31Ava41m8x4k1hJ9SBitimmiOLs0Ua37BY/rtm57g6m0PqXhlPWvaBtnfr7
6q+E9ram6t9zWGFdNedfQjhGvyCUEMieXlRhCOC9J/6/al0WJ3mln02gY/sSS3TF
8QIDAQABoAAwDQYJKoZIhvcNAQEFBQADggEBAJIKf7kwxVGvlrATk6DPhu7dqEjw
iAL41XTNjlR2780/wDBR5yUiCTtXFFuqAPagAn9i/qjb2gC5jZZmbUOhgYSyZpp/
qznZFTg9MsVdszC/LBLkRpDCxqLm1m61WCi5qmHGq9nN55rtdwiJsglQkUwvFeUK
SaMY95U+qakWqveCGzcmCoWir9zWKpBH1/Z89r5ktAsi7CdH9RdGQJeM8K8lBK3F
fqhakKXiA+afPFnhwK+KSisJGJl573ocHXGL/obhuOPj0uunfgxIBxION4nVDPCn
CTz7or24EltIZ5/e6T9PgvBbfUeMJ8WQEKVFlaqaJ+gAtl7FDHfOQmmUXN4= -END
CERTIFICATE REQUEST-


what is this certificate and where it is stored because i checked in
private/ssl folder and i din't find any other certificate generated ?
How to generate server and client private keys and certificates? as per
your previous mail simaptica should generate following certificates:

1. generate ca priv key + self signed certificate
2. generate server priv keys +  certificates signed by the above ca
certificate
3.  generate client priv keys + certificates signed by the above ca
 certificate


but I am not able to generate above 2. and 3. so pleae guide me to generate
the same.

Thanks,
Amit


>
>
> On Thu, Jul 26, 2012 at 10:50 AM, Amit  wrote:
>
>> Thanks Michele,I am going to generate keys using simpatica, I will let
>> you know if i face any problem.
>>
>> Thanks,
>> Amit
>>
>>
>> On Wed, Jul 25, 2012 at 7:01 PM, Michele Comitini <
>> michele.comit...@gmail.com> wrote:
>>
>>> 2012/7/25 Amit :
>>> > Michele,
>>> >
>>> > I have gone through the X509_Auth class and its methods :
>>> >
>>> > login_form
>>> >
>>> > login_url
>>> > get_user
>>> >
>>> > But not able to visualize how to use this class in my
>>> model/controller, I
>>> > just write below what I understood, please confirm
>>> > whether I understood correctly or not.
>>> >
>>> >
>>> > My requirement is : I have one web service method add() in controller
>>> > default.py , I just want to enable x509 authentication
>>> > so for that purpose i will use simpatica to generate keys and
>>> certificates
>>> > then in model class db.py I will use below code:
>>> >
>>> >
>>> > """
>>> > Login using x509 cert from client.
>>> >
>>> > from gluon.contrib.login_methods.x509_auth import X509Account
>>> > auth.settings.actions_disabled=['register','change_password',
>>> >
>>> > 'request_reset_password','profile']
>>> > auth.settings.login_form = X509Account()
>>> >
>>> > """
>>> >
>>> >
>>> > and then in add method I will put @auth.requires_login() annotation .
>>> >
>>> > My doubt:
>>> > 1. how to configure certificate with Rocket and apache server?
>>> > 2. how to make call of web service method with private keys from the
>>> client?
>>> >
>>> > 3. I din't find X509Account class instead of that I found X509Auth
>>> class, so
>>> > is it the same, if yes then I need to create
>>> >
>>>
>>> 1 rocket:
>>>  python web2py.py  --ssl_certificate=
>>> --ssl_private_key= --ca-cert=>> certificate pem encoded file>
>>>  apache see mod_ssl config:
>>

[web2py] how to use pycurl in web2py?

2012-07-30 Thread Amit
Hi,
I want to use pycurl in my web2py app to send Post request to the server, I 
added Pycurl path(path to pycurl.c file ---> pycurl-7.19.0\src) to 
pythonpath and tried to import pycurl in default.py class but it throws 
error "
 No module named pycurl"

even i tried to add pycurl.c file in mudule but it shows "pycurl.c.py", so 
not sure how to add pycurl.c file in web2py project and use it?

Please assist me to resolve this issue.



-- 





[web2py] Re: Facing problem of settingup web2py project in Eclipse.

2012-07-29 Thread Amit
Does anyone having any idea how to resolve those incorrect errors in 
eclipse?
problem:
I set up web2py project in eclipse and having one project inside 
applications folder but when i opened any file of project all import 
statement are showing in Red underline saying "Unresolved import" for e.g. 
in project's model class db.py , I am using below import statement:

*from gluon.tools import Auth, Crud, Service, PluginManager, prettydate*
and every imports are displaying in red underline saying "Unresolved 
import", but when i deployed this application in web2py server , its 
working fine, so not sure why eclipse is displaying import errors.
Can anybody help me to resolve this problem?

Thanks,
Amit


On Friday, 20 July 2012 10:49:29 UTC+5:30, Amit wrote:
>
> Hi,
> I followed below link to configure Web2py project in eclipse:
>
> http://allisterx.blogspot.in/2009/06/using-web2py-framework-on-eclipse.html
>
> but after setting up when i open my application which is there inside 
> application folder of web2py_src folder, I saw so many errors on the module.
> once i open default.py module, it showing error on import modules which 
> are inside Modules folder(for e.g.: i have userconf.py module inside 
> modules but when i import it in default.controller it giving error saying 
> "Unresolved import:userconf") , similar problem with when i am trying to 
> use function of db.py, its giving error "undefined variable".
>
> can anyone please help me to figure out what wrong i did?
>

-- 





Re: [web2py] Getting error: DLL load failed: The operating system cannot run %1

2012-07-27 Thread Amit
Found the problem :), I was using wrong version of M2Crypto so uninstalled
it and install M2Crypto-0.20.2.win32-py2.7 version and its working fine.

On Fri, Jul 27, 2012 at 12:02 PM, Amit  wrote:

> I Have installed python 2.7.2 and M2Crypto-0.21.1-py2.7.egg-info in my
> Windows XP SP3 machine and wherever i am using import statement:
>
> from M2Crypto import X509,ASN1,Rand,EVP,RSA its throwing error
>
> * DLL load failed: The operating system cannot run %1.*
>
> it seems like M2Crypto version is not supported with Python2.7.2 and
> windows XP SP3. In addition to that I am using
> pyOpenSSL-0.13.winxp32-py2.7.msi for openSSL.
>
> Can anybody help me resolve this problem?
>
> --
>
>
>
>

-- 





[web2py] Getting error: DLL load failed: The operating system cannot run %1

2012-07-26 Thread Amit
 

I Have installed python 2.7.2 and M2Crypto-0.21.1-py2.7.egg-info in my 
Windows XP SP3 machine and wherever i am using import statement:

from M2Crypto import X509,ASN1,Rand,EVP,RSA its throwing error 

* DLL load failed: The operating system cannot run %1.*

it seems like M2Crypto version is not supported with Python2.7.2 and 
windows XP SP3. In addition to that I am using 
pyOpenSSL-0.13.winxp32-py2.7.msi for openSSL.

Can anybody help me resolve this problem?

-- 





Re: [web2py] Re: how to achieve public/private key authentication for web service in web2py?

2012-07-26 Thread Amit
Michele,
I tried to use simpatica, but getting error :
 DLL load failed: The operating system
cannot run %1.what i observed is this error coming wherever M2Crypto import
statement is there:

 File 
"D:/Softwares/Python2.7/web2py_src/web2py/applications/simpatica/controllers/ca.py"
<http://127.0.0.1:8000/admin/default/edit/simpatica/controllers/ca.py>,
line 27, in 
from M2Crypto import X509, RSA, EVP

File 
"D:/Softwares/Python2.7/web2py_src/web2py/applications/simpatica/controllers/public.py"
<http://127.0.0.1:8000/admin/default/edit/simpatica/controllers/public.py>,
line 28, in 
from M2Crypto import X509, ASN1, Rand, EVP, RSA

So not able to execute it :(. I have installed
M2Crypto-0.21.1-py2.7.egg-info for windows .

I couldn't able to identify what is the exact problem, so can you
please help me to resolve it?

Thanks,
Amit



On Thu, Jul 26, 2012 at 10:50 AM, Amit  wrote:

> Thanks Michele,I am going to generate keys using simpatica, I will let you
> know if i face any problem.
>
> Thanks,
> Amit
>
>
> On Wed, Jul 25, 2012 at 7:01 PM, Michele Comitini <
> michele.comit...@gmail.com> wrote:
>
>> 2012/7/25 Amit :
>> > Michele,
>> >
>> > I have gone through the X509_Auth class and its methods :
>> >
>> > login_form
>> >
>> > login_url
>> > get_user
>> >
>> > But not able to visualize how to use this class in my model/controller,
>> I
>> > just write below what I understood, please confirm
>> > whether I understood correctly or not.
>> >
>> >
>> > My requirement is : I have one web service method add() in controller
>> > default.py , I just want to enable x509 authentication
>> > so for that purpose i will use simpatica to generate keys and
>> certificates
>> > then in model class db.py I will use below code:
>> >
>> >
>> > """
>> > Login using x509 cert from client.
>> >
>> > from gluon.contrib.login_methods.x509_auth import X509Account
>> > auth.settings.actions_disabled=['register','change_password',
>> >
>> > 'request_reset_password','profile']
>> > auth.settings.login_form = X509Account()
>> >
>> > """
>> >
>> >
>> > and then in add method I will put @auth.requires_login() annotation .
>> >
>> > My doubt:
>> > 1. how to configure certificate with Rocket and apache server?
>> > 2. how to make call of web service method with private keys from the
>> client?
>> >
>> > 3. I din't find X509Account class instead of that I found X509Auth
>> class, so
>> > is it the same, if yes then I need to create
>> >
>>
>> 1 rocket:
>>  python web2py.py  --ssl_certificate=
>> --ssl_private_key= --ca-cert=> certificate pem encoded file>
>>  apache see mod_ssl config:
>>  http://httpd.apache.org/docs/2.2/mod/mod_ssl.html
>>
>> You can use a single file pem encoded containing: server cert, server
>> key, CA cert.  Pass it to all the options.
>>
>> 2 What is the client?  With curl:
>> curl --cert   ...
>>
>> With python:
>> you can use pycurl or httplib
>> (http://docs.python.org/library/httplib.html) see their docs.
>>
>>
>> 3 You did the right thing using X509_Auth.  The error in the comment
>> is corrected in trunk.
>>The interesting part that you may want to override in a child class
>> is the get_user() method.  Look how certificate properties are mapped
>> to the auth.user record (the profile variable that).  You may override
>> those to fit your needs.
>>
>> mic
>>
>>
>>
>> >
>> >  auth.settings.login_form = X509Auth() instance ?
>> >
>> >
>> >
>> > Thanks,
>> > Amit
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Wed, Jul 25, 2012 at 2:28 PM, Michele Comitini
>> >  wrote:
>> >>
>> >> 
>> >> simpatica
>> >>
>> >> - generate ca priv key + self signed certificate
>> >> - generate server priv keys +  certificates signed by the above ca
>> >> certificate
>> >> - generate client priv keys + certificates signed by the above ca
>> >> certificate
>> >>
>> &

Re: [web2py] Re: how to achieve public/private key authentication for web service in web2py?

2012-07-25 Thread Amit
Thanks Michele,I am going to generate keys using simpatica, I will let you
know if i face any problem.

Thanks,
Amit

On Wed, Jul 25, 2012 at 7:01 PM, Michele Comitini <
michele.comit...@gmail.com> wrote:

> 2012/7/25 Amit :
> > Michele,
> >
> > I have gone through the X509_Auth class and its methods :
> >
> > login_form
> >
> > login_url
> > get_user
> >
> > But not able to visualize how to use this class in my model/controller, I
> > just write below what I understood, please confirm
> > whether I understood correctly or not.
> >
> >
> > My requirement is : I have one web service method add() in controller
> > default.py , I just want to enable x509 authentication
> > so for that purpose i will use simpatica to generate keys and
> certificates
> > then in model class db.py I will use below code:
> >
> >
> > """
> > Login using x509 cert from client.
> >
> > from gluon.contrib.login_methods.x509_auth import X509Account
> > auth.settings.actions_disabled=['register','change_password',
> >
> > 'request_reset_password','profile']
> > auth.settings.login_form = X509Account()
> >
> > """
> >
> >
> > and then in add method I will put @auth.requires_login() annotation .
> >
> > My doubt:
> > 1. how to configure certificate with Rocket and apache server?
> > 2. how to make call of web service method with private keys from the
> client?
> >
> > 3. I din't find X509Account class instead of that I found X509Auth
> class, so
> > is it the same, if yes then I need to create
> >
>
> 1 rocket:
>  python web2py.py  --ssl_certificate=
> --ssl_private_key= --ca-cert= certificate pem encoded file>
>  apache see mod_ssl config:
>  http://httpd.apache.org/docs/2.2/mod/mod_ssl.html
>
> You can use a single file pem encoded containing: server cert, server
> key, CA cert.  Pass it to all the options.
>
> 2 What is the client?  With curl:
> curl --cert   ...
>
> With python:
> you can use pycurl or httplib
> (http://docs.python.org/library/httplib.html) see their docs.
>
>
> 3 You did the right thing using X509_Auth.  The error in the comment
> is corrected in trunk.
>The interesting part that you may want to override in a child class
> is the get_user() method.  Look how certificate properties are mapped
> to the auth.user record (the profile variable that).  You may override
> those to fit your needs.
>
> mic
>
>
>
> >
> >  auth.settings.login_form = X509Auth() instance ?
> >
> >
> >
> > Thanks,
> > Amit
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Wed, Jul 25, 2012 at 2:28 PM, Michele Comitini
> >  wrote:
> >>
> >> 
> >> simpatica
> >>
> >> - generate ca priv key + self signed certificate
> >> - generate server priv keys +  certificates signed by the above ca
> >> certificate
> >> - generate client priv keys + certificates signed by the above ca
> >> certificate
> >>
> >> The client and server certificate are generated after compilation of a
> >> form that requires the user to assign a password to protect the
> >> private key.
> >> The certificate + private keys are encoded in pkcs12 format
> >> downloadable to a browser or to be unpacked with openssl or similar
> >> tools after providing the above password.  Remeber that if you loose
> >> the password you cannot open the pkcs12.  There is a recovery
> >> mechanism in simpatica since the private keys are also encoded with a
> >> randomly generated secret that is crypted with the ca private key.
> >> It also send emails to email associated with the client informing that
> >> a certificate is ready to download.
> >>
> >> -
> >> Sample code
> >>
> >>  Just look at gluon/contrib/login_methods/x509_auth.py. Look at the
> >> docstring in the X509_Auth class and put that code in your model to
> >> configure authentication with x509.
> >>
> >> Use the @auth.requires_login() annotation as you would with any action
> >> requiring authentication. It is explained in:
> >>
> >>
> http://web2py.com/books/default/chapter/29/10?search=rest#Access-Control
> >>
> >>
> >> mic
> >>
> >>
> &

Re: [web2py] Re: how to achieve public/private key authentication for web service in web2py?

2012-07-25 Thread Amit
Michele,

I have gone through the *X509_Auth *class and its methods :

login_form
login_url
get_user

But not able to visualize how to use this class in my
model/controller, I just write below what I understood, please confirm
whether I understood correctly or not.

My requirement is : I have one web service method add() in controller
default.py , I just want to enable x509 authentication
so for that purpose i will use simpatica to generate keys and
certificates then in model class db.py I will use below code:

"""
Login using x509 cert from client.

from gluon.contrib.login_methods.x509_auth import X509Account
auth.settings.actions_disabled=['register','change_password',
'request_reset_password','profile']
auth.settings.login_form = X509Account()

"""

and then in add method I will put @auth.requires_login() annotation .

My doubt:
1. how to configure certificate with Rocket and apache server?
2. how to make call of web service method with private keys from the client?
3. I din't find X509Account class instead of that I found X509Auth
class, so is it the same, if yes then I need to create

 auth.settings.login_form = X509Auth() instance ?


Thanks,
Amit















On Wed, Jul 25, 2012 at 2:28 PM, Michele Comitini <
michele.comit...@gmail.com> wrote:

> 
> simpatica
>
> - generate ca priv key + self signed certificate
> - generate server priv keys +  certificates signed by the above ca
> certificate
> - generate client priv keys + certificates signed by the above ca
> certificate
>
> The client and server certificate are generated after compilation of a
> form that requires the user to assign a password to protect the
> private key.
> The certificate + private keys are encoded in pkcs12 format
> downloadable to a browser or to be unpacked with openssl or similar
> tools after providing the above password.  Remeber that if you loose
> the password you cannot open the pkcs12.  There is a recovery
> mechanism in simpatica since the private keys are also encoded with a
> randomly generated secret that is crypted with the ca private key.
> It also send emails to email associated with the client informing that
> a certificate is ready to download.
>
> -
> Sample code
>
>  Just look at gluon/contrib/login_methods/x509_auth.py. Look at the
> docstring in the X509_Auth class and put that code in your model to
> configure authentication with x509.
>
> Use the @auth.requires_login() annotation as you would with any action
> requiring authentication. It is explained in:
>
> http://web2py.com/books/default/chapter/29/10?search=rest#Access-Control
>
>
> mic
>
>
> 2012/7/25 Amit :
> > sure Michele, let me go through the code,If i am not wrong simpatica is
> to
> > generate the certificate file for the client and if you are having any
> > sample code to use x509 in case of web service then please do share with
> me.
> >
> > Thanks,
> > Amit
> >
> >
> > On Wed, Jul 25, 2012 at 12:34 PM, Michele Comitini
> >  wrote:
> >>
> >> Amit
> >> If you need advice with simpatica don't worry to ask.  I never had time
> to
> >> write some documentation so you have to look at the code and/or ask...
> >>
> >> mic
> >>
> >>
> >> Il giorno mercoledì 25 luglio 2012 05:14:52 UTC+2, Amit ha scritto:
> >>>
> >>> Thanks Michele and Derek..nice post , i am looking exactly the same :)
> >>>
> >>> On Wed, Jul 25, 2012 at 4:09 AM, Michele Comitini
> >>>  wrote:
> >>>>
> >>>>
> >>>> This is very similar to what TSL accomplishes with x509 certificates.
> >>>> There is a slight difference, the server does not own a public key
> for each
> >>>> client: it verifies that the  client owns an x509 certificate signed
> by the
> >>>> correct certification authority. So no need to store public keys.  in
> any
> >>>> case AFAIK in public/private key algorithms the private key always
> allows
> >>>> generation of the corresponding public key, not the contrary of
> course.
> >>>>
> >>>> To accomplish what you need in the simplest way you have to:
> >>>>
> >>>> - create a certification authority with self signed certificate
> >>>> - create certificate for you webserver signed with the private key of
> >>>> the certification authority above.
> >>>> - configure your webserver to require a client certificate (with
> rocket
> >>>> look at --

Re: [web2py] Re: how to achieve public/private key authentication for web service in web2py?

2012-07-25 Thread Amit
sure Michele, let me go through the code,If i am not wrong simpatica is to
generate the certificate file for the client and if you are having any
sample code to use x509 in case of web service then please do share with me.

Thanks,
Amit

On Wed, Jul 25, 2012 at 12:34 PM, Michele Comitini <
michele.comit...@gmail.com> wrote:

> Amit
> If you need advice with simpatica don't worry to ask.  I never had time to
> write some documentation so you have to look at the code and/or ask...
>
> mic
>
>
> Il giorno mercoledì 25 luglio 2012 05:14:52 UTC+2, Amit ha scritto:
>
>> Thanks Michele and Derek..nice post , i am looking exactly the same :)
>>
>> On Wed, Jul 25, 2012 at 4:09 AM, Michele Comitini <
>> michele.comit...@gmail.com> wrote:
>>
>>>
>>> This is very similar to what TSL accomplishes with x509 certificates.
>>>  There is a slight difference, the server does not own a public key for
>>> each client: it verifies that the  client owns an x509 certificate signed
>>> by the correct certification authority. So no need to store public keys.
>>>  in any case AFAIK in public/private key algorithms the private key always
>>> allows generation of the corresponding public key, not the contrary of
>>> course.
>>>
>>> To accomplish what you need in the simplest way you have to:
>>>
>>> - create a certification authority with self signed certificate
>>> - create certificate for you webserver signed with the private key of
>>> the certification authority above.
>>> - configure your webserver to require a client certificate (with rocket
>>> look at --ca-cert option)
>>> - In case you need to know some infos about the connecting client as
>>> reported in its certificate you can use x509_auth.py to use x509
>>> authentication and configure your REST action with @auth.requires_login().
>>>  This will give you access to  information contained in the certificate
>>> such common name or serial id.  To customize you can extend the X509_Auth
>>> class.
>>>
>>> To generate test certificates fast you can use simpatica as Derek
>>> correctly suggests.
>>>
>>> mic
>>>
>>> Il giorno martedì 24 luglio 2012 10:33:48 UTC+2, Amit ha scritto:
>>>
>>>> Hi,
>>>> I have to provide public/private key authentication for accessing web
>>>> service (REST) from client in my web2py application.How to achieve it?
>>>>
>>>> Scenario:
>>>> 1.Each client will have unique private key which will be sent to the
>>>> server alongwith request.
>>>> 2. Server has to authenticate private key using public key(unique for
>>>> each client) and then allow to access the web service method. For e.g.
>>>> suppose one client say X has requested for web service "add()" so server
>>>> has to first validate the public key with client's private key and if
>>>> validation is successful then allow to access the web service "add()".
>>>>
>>>> Challenges:
>>>> where to store public key of each client?we can't store it in the db
>>>> because server can't access db before validation of web service method.So
>>>> will it be store somewhere in PC(where server is running)?if yes then how
>>>> and which format?
>>>>
>>>>
>>>> NOTE: Here Server will be completely written in web2py and client is
>>>> separate application running on the hardware device.
>>>>
>>>>  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Re: how to achieve public/private key authentication for web service in web2py?

2012-07-24 Thread Amit
Thanks Michele and Derek..nice post , i am looking exactly the same :)

On Wed, Jul 25, 2012 at 4:09 AM, Michele Comitini <
michele.comit...@gmail.com> wrote:

>
> This is very similar to what TSL accomplishes with x509 certificates.
>  There is a slight difference, the server does not own a public key for
> each client: it verifies that the  client owns an x509 certificate signed
> by the correct certification authority. So no need to store public keys.
>  in any case AFAIK in public/private key algorithms the private key always
> allows generation of the corresponding public key, not the contrary of
> course.
>
> To accomplish what you need in the simplest way you have to:
>
> - create a certification authority with self signed certificate
> - create certificate for you webserver signed with the private key of the
> certification authority above.
> - configure your webserver to require a client certificate (with rocket
> look at --ca-cert option)
> - In case you need to know some infos about the connecting client as
> reported in its certificate you can use x509_auth.py to use x509
> authentication and configure your REST action with @auth.requires_login().
>  This will give you access to  information contained in the certificate
> such common name or serial id.  To customize you can extend the X509_Auth
> class.
>
> To generate test certificates fast you can use simpatica as Derek
> correctly suggests.
>
> mic
>
> Il giorno martedì 24 luglio 2012 10:33:48 UTC+2, Amit ha scritto:
>
>> Hi,
>> I have to provide public/private key authentication for accessing web
>> service (REST) from client in my web2py application.How to achieve it?
>>
>> Scenario:
>> 1.Each client will have unique private key which will be sent to the
>> server alongwith request.
>> 2. Server has to authenticate private key using public key(unique for
>> each client) and then allow to access the web service method. For e.g.
>> suppose one client say X has requested for web service "add()" so server
>> has to first validate the public key with client's private key and if
>> validation is successful then allow to access the web service "add()".
>>
>> Challenges:
>> where to store public key of each client?we can't store it in the db
>> because server can't access db before validation of web service method.So
>> will it be store somewhere in PC(where server is running)?if yes then how
>> and which format?
>>
>>
>> NOTE: Here Server will be completely written in web2py and client is
>> separate application running on the hardware device.
>>
>>  --
>
>
>
>

-- 





[web2py] how to achieve public/private key authentication for web service in web2py?

2012-07-24 Thread Amit
Hi,
I have to provide public/private key authentication for accessing web 
service (REST) from client in my web2py application.How to achieve it?

Scenario: 
1.Each client will have unique private key which will be sent to the server 
alongwith request.
2. Server has to authenticate private key using public key(unique for each 
client) and then allow to access the web service method. For e.g. suppose 
one client say X has requested for web service "add()" so server has to 
first validate the public key with client's private key and if validation 
is successful then allow to access the web service "add()".

Challenges:
where to store public key of each client?we can't store it in the db 
because server can't access db before validation of web service method.So 
will it be store somewhere in PC(where server is running)?if yes then how 
and which format? 


NOTE: Here Server will be completely written in web2py and client is 
separate application running on the hardware device.

-- 





[web2py] how to use db connection multiple times with scheduler?

2012-07-19 Thread Amit
hi,
I have to implement one scenario where scheduler will make the query to 
database periodically to retrieve data(lets say every 10 mins), i have 
written function inside model db.py to retrieve the data, and from 
controller i am staring the scheduler and assign the job to get the data 
periodically.

Problem:
when i request the function of controller  where i am starting scheduler 
from web browser , its executing perfectly and display the data first time 
, after that it started throwing error "ProgrammingError: Cannot operate on 
a closed database." continuously and i found that for each request models 
are executed DAL(...) statement and when action is done it will commit and 
rollback the db connection so because of that when scheduler tries to 
retrieve data second time from database using db , its throwing above 
mentioned error.

Note: I am using sqlite databse and APScheduler..

How to implement  this scenario where request come very first time i need 
to start scheduler and assign the job so periodically it should query to db 
and retrieve the data(second time onwards to db instance should be alive) ?
 

-- 





[web2py] Facing problem of settingup web2py project in Eclipse.

2012-07-19 Thread Amit
Hi,
I followed below link to configure Web2py project in eclipse:

http://allisterx.blogspot.in/2009/06/using-web2py-framework-on-eclipse.html

but after setting up when i open my application which is there inside 
application folder of web2py_src folder, I saw so many errors on the module.
once i open default.py module, it showing error on import modules which are 
inside Modules folder(for e.g.: i have userconf.py module inside modules 
but when i import it in default.controller it giving error saying 
"Unresolved import:userconf") , similar problem with when i am trying to 
use function of db.py, its giving error "undefined variable".

can anyone please help me to figure out what wrong i did?

-- 





[web2py] how to compare date time in web2py?

2012-07-19 Thread Amit
Hi,
I have some records in a table and each record is having one field of type 
datetime [fromat : 2012-07-19 23:12:0 (-MM-DD HH:MM:SS)], table 
structure is:

Emp_ID
Emp_Name
Emp_Address
Emp_Salary
updated_on(Type: datetime)

periodically getting data against each Emp_ID and updating to the 
particular record, every 20 mins data has to be updated for each Emp_ID, 
for e.g : suppose for one Emp_ID data has updated on 2012-07-19 10:10:00 
then again it has to update on 2012-07-19 10:30:00 etc...

and if data is not updated in 20 mins then one scheduler will verify 
against the updated_on column value and inform user that data has not 
updated  for particular employee.

Problem facing:
How to compare current datetime with updated_on coulmn value in web2py? can 
anybody please share me the code to achieve the same?

-- 





Re: [web2py] Re: How to start a thread upon starting of webserver?

2012-07-18 Thread Amit
thanks for your response, I am going to use APScheduler to schedule certain
task on time interval, this scheduler has to start upon starting of
application/webserver first time and should continuously run till web
server stops.
Basic code here in below:

from apscheduler.scheduler import Scheduler
sched = Scheduler()
sched.add_interval_job(perform_task,hours=24)
sched.start()

as per above code scheduler has to execute perform_task every 24 hours,
irrespective of how many user accessing the application, so how to use it
in your suggested solution?

On Thu, Jul 19, 2012 at 11:41 AM, Cédric Mayer  wrote:

> Can't you use in a model.
> cache.ram('parallel_thread_name', , None)
> so that you have the thread created at first connection.
>
> I don't know how to close it afterwards though. Maybe using a cron job ?
>
> Le jeudi 19 juillet 2012 05:24:03 UTC+2, Amit a écrit :
>>
>> Hi Massimo,
>> could you please provide me the solution for this?
>>
>> On Wednesday, 18 July 2012 08:37:23 UTC+5:30, Amit wrote:
>>
>>> for development purpose I am using Rocket but  will deploy the
>>> application to ubuntu machine where web server will be apache, so please
>>> provide me solution for both.
>>>
>>> On Tue, Jul 17, 2012 at 8:41 PM, Massimo Di Pierro wrote:
>>>
>>>> Do you use rocket (the built-in web server) or apache?
>>>>
>>>>
>>>> On Monday, 16 July 2012 23:42:49 UTC-5, Amit wrote:
>>>>>
>>>>> Hi,
>>>>> I have one timer thread which has to start once when web sever starts
>>>>> very first time and stop when web server stops, means it should be running
>>>>> continuously irrespective of how many users interacting with the
>>>>> application so there is only one instance of this thread running though 
>>>>> out
>>>>> life of the application , it is common for all users who are accessing the
>>>>> application.
>>>>>
>>>>> How to achieve it in web2py?
>>>>>
>>>>>  --
>>>>
>>>>
>>>>
>>>>
>>>
>>>  --
>
>
>
>

-- 





Re: [web2py] Re: How to start a thread upon starting of webserver?

2012-07-18 Thread Amit
Hi Massimo,
could you please provide me the solution for this?

On Wednesday, 18 July 2012 08:37:23 UTC+5:30, Amit wrote:
>
> for development purpose I am using Rocket but  will deploy the application 
> to ubuntu machine where web server will be apache, so please provide me 
> solution for both.
>
> On Tue, Jul 17, 2012 at 8:41 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Do you use rocket (the built-in web server) or apache?
>>
>>
>> On Monday, 16 July 2012 23:42:49 UTC-5, Amit wrote:
>>>
>>> Hi,
>>> I have one timer thread which has to start once when web sever starts 
>>> very first time and stop when web server stops, means it should be running 
>>> continuously irrespective of how many users interacting with the 
>>> application so there is only one instance of this thread running though out 
>>> life of the application , it is common for all users who are accessing the 
>>> application.
>>>
>>> How to achieve it in web2py?
>>>
>>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: User Login/Logout authentication event

2012-07-17 Thread amit
For logout, I could not find logout_onaccept.
There is though: auth.settings.logout_onlogout
I am using v 1.99.7.

-- 





Re: [web2py] Re: How to start a thread upon starting of webserver?

2012-07-17 Thread Amit
for development purpose I am using Rocket but  will deploy the application
to ubuntu machine where web server will be apache, so please provide me
solution for both.

On Tue, Jul 17, 2012 at 8:41 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Do you use rocket (the built-in web server) or apache?
>
>
> On Monday, 16 July 2012 23:42:49 UTC-5, Amit wrote:
>>
>> Hi,
>> I have one timer thread which has to start once when web sever starts
>> very first time and stop when web server stops, means it should be running
>> continuously irrespective of how many users interacting with the
>> application so there is only one instance of this thread running though out
>> life of the application , it is common for all users who are accessing the
>> application.
>>
>> How to achieve it in web2py?
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM

2012-07-17 Thread Amit Kumar
On Tue, Jul 17, 2012 at 6:15 PM, Anthony  wrote:

> Sorry, I was referring to
>>
>> db.table.field.writable = False # change the field to writable false
>>
>>
>>> Second, even something like the above wouldn't be a problem for
>>> concurrent users, as the above would all happen within a single request and
>>> therefore only apply to that one request. Setting a field to writable in
>>> one request does not affect it another request.
>>>
>>
>> I am not sure if I understand this for db.table.field.writable. The
>> change is occurring within the shared DAL object. Is it not?
>>
>
> No, the DAL object is not shared. Each request happens in a new thread,
> and all the objects generated in the app code are specific to that request
> and thread. The database itself is shared and accessible from multiple
> requests, but the web2py objects defined in the app code are not. If the
> writable attribute of a field is set in one request, that does not affect
> its status in another request.
>

Got it! Thanks for clarifying.

>
>

-- 





Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM

2012-07-17 Thread amit


On Tuesday, July 17, 2012 5:29:51 PM UTC+8, Anthony wrote:
>
> I understand the proposed procedure is as follows:
>>
>> 1. change db table field to writable
>> 2. make the form as needed
>> 3. change back db table field to not writable
>>
>
> First, I don't think this is the proposal. The proposal was to manipulate 
> the form object itself after the form is created, but before it is 
> serialized in the view (i.e., set the HTML "readonly" attribute of the 
> input widget).
>

Yes, this will work fine. 

Sorry, I was referring to 

db.table.field.writable = False # change the field to writable false
 

> Second, even something like the above wouldn't be a problem for concurrent 
> users, as the above would all happen within a single request and therefore 
> only apply to that one request. Setting a field to writable in one request 
> does not affect it another request.
>

I am not sure if I understand this for db.table.field.writable. The change 
is occurring within the shared DAL object. Is it not? 

Best Regards
-Amit
 

-- 





Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM

2012-07-17 Thread Amit Kumar
I understand the proposed procedure is as follows:

1. change db table field to writable
2. make the form as needed
3. change back db table field to not writable

Suppose there are two concurrent users now, A and B, and they execute the
above procedure.
The concurrent scheduling is done by the server; one possible sequence is:

A 1, B 1, B 2, B 3,  A 2, A 3.

At the point of , the db field is not writable and so the
form will not be correct.

On Tue, Jul 17, 2012 at 12:46 PM, Anthony  wrote:

> Can you elaborate?
>
>
> On Tuesday, July 17, 2012 12:24:37 AM UTC-4, amit wrote:
>>
>> Old thread, but this would trigger a race condition in case of multiple
>> concurrent users.
>>
>> On Friday, June 17, 2011 5:12:27 AM UTC+8, JayShaffstall wrote:
>>>
>>> I'd been thinking I needed to do that between form creation and the
>>> accepts call, but you're right, it works even after that point.  I
>>> make the call to auth.register, and then modify the readonly
>>> attribute, and it works fine.
>>>
>>> Thanks!
>>> Jay
>>>
>>  --
>
>
>
>

-- 





[web2py] How to start a thread upon starting of webserver?

2012-07-16 Thread Amit
Hi,
I have one timer thread which has to start once when web sever starts very 
first time and stop when web server stops, means it should be running 
continuously irrespective of how many users interacting with the 
application so there is only one instance of this thread running though out 
life of the application , it is common for all users who are accessing the 
application.

How to achieve it in web2py?

-- 





Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM

2012-07-16 Thread amit
Old thread, but this would trigger a race condition in case of multiple 
concurrent users. 

On Friday, June 17, 2011 5:12:27 AM UTC+8, JayShaffstall wrote:
>
> I'd been thinking I needed to do that between form creation and the
> accepts call, but you're right, it works even after that point.  I
> make the call to auth.register, and then modify the readonly
> attribute, and it works fine.
>
> Thanks!
> Jay
>

-- 





Re: [web2py] Re: how to delete records from table older than 1 day?

2012-07-16 Thread Amit
Thanks Niphold, its working as intended :)

On Mon, Jul 16, 2012 at 3:55 PM, Niphlod  wrote:

> Why write such a query when DAL allows you to use a more (portable,
> concise) pythonic way ?
>
> import datetime
> yesterday = request.now - datetime.timedelta(days=1)
> db(db.employee.created_on < yesterday).delete()
>
>
>
> On Monday, July 16, 2012 12:12:56 PM UTC+2, Amit wrote:
>>
>> Hi,
>> I have created table Employe with following fields:
>> db.define_table(
>>'Employee',
>>Field('created_on','datetime', default=request.now),
>>Field('emp_id'),
>>Field('emp_age'),
>>Field('emp_address),
>> )
>>  inserting data into the table is working fine but when i am trying to
>> delete data one day older using below command:
>>
>> db.executesql('DELETE FROM db.Employee WHERE created_on < date_sub(now(),
>> INTERVAL 1 DAY);')
>>
>> It's not working and i am not getting any error also, so can anybody help
>> me resolve this issue.
>> NOTE: I am using Sqlite database.
>>
>>
>>

-- 





[web2py] how to delete records from table older than 1 day?

2012-07-16 Thread Amit
Hi,
I have created table Employe with following fields:
db.define_table(
   'Employee',
   Field('created_on','datetime', default=request.now),
   Field('emp_id'),
   Field('emp_age'),
   Field('emp_address),
)
 inserting data into the table is working fine but when i am trying to 
delete data one day older using below command:

db.executesql('DELETE FROM db.Employee WHERE created_on < date_sub(now(), 
INTERVAL 1 DAY);')

It's not working and i am not getting any error also, so can anybody help 
me resolve this issue.
NOTE: I am using Sqlite database.




  1   2   >