[web2py] Re: web2py 2.14.2

2016-03-30 Thread Gary Cowell
Hello

Running 2.14.3 - upgraded from 2.12.(something)

Seems all the btn-default are now almost invisible?

E.g. from the log in page:

Sign Up

Gives me



now.

I upgraded web2py, then copied the static/js and static/css from welcome 

I notice bootstrap version changed from 3.3.4 to 3.3.5. button style has 
changed also.

Did I do something wrong during upgrade? What might be the problem?

Thanks



On Thursday, 24 March 2016 22:56:23 UTC, Massimo Di Pierro wrote:
>
> http://web2py.com/
>
> First of all many many thanks to Simone (niphlod), Richard, and Leonel. 
> Most of the work is theirs.
>
> It is important that you upgrade because we fixed some serious security 
> bugs that may leak your admin password (if you use rocket and expose the 
> old example app).
>
> We fixed many many bug and in particular everything should work fine on 
> GAE now, including Datastore and Cloud SQL.
>
> ** IMPORTANT: We also strongly recommend that you do not expose the 
> examples app if you do not have to. Although all known security issue have 
> been fixed in the new examples app, there may be issue with your legacy 
> examples app.**
>
> CHANGELOG
>
> - fixed two major security issues that caused the examples app to leak 
> information
>
> - new Auth(…,host_names=[…]) to prevent host header injection
>
> - improved scheduler
>
> - pep8 enhancements
>
> - many bug fixes
>
> - restored GAE support that was broken in 2.13.*
>
> - improved fabfile for deployment
>
> - refactored examples with stupid.css
>
> - new JWT implementation (experimental)
>
> - new gluon.contrib.redis_scheduler
>
> - myconf.get
>
> - LDAP groups (experimental)
>
> - .flash -> .w2p_flash
>
> - Updated feedparser.py 5.2.1
>
> - Updated jQuery 1.12.2
>
> - welcome app now checks for version number
>
> - Redis improvements.
>
>
> BEFORE:
>
> from gluon.contrib.redis_cache import RedisCache
>
> cache.redis = RedisCache('localhost:6379',db=None, debug=True)
>
>
> NOW:
>
> from gluon.contrib.redis_utils import RConn
>
> from gluon.contrib.redis_cache import RedisCache
>
> rconn = RConn()
>
> # or RConn(host='localhost', port=6379,
>
> # db=0, password=None, socket_timeout=None,
>
> # socket_connect_timeout=None, .)
>
> # exactly as a redis.StrictRedis instance
>
> cache.redis = RedisCache(redis_conn=rconn, debug=True)
>
> BEFORE:
>
> from gluon.contrib.redis_session import RedisSession
>
> sessiondb = RedisSession('localhost:6379',db=0, session_expiry=False)
>
> session.connect(request, response, db = sessiondb)
>
>
> NOW:
>
> from gluon.contrib.redis_utils import RConn
>
> from gluon.contrib.redis_session import RedisSession
>
> rconn = RConn()
>
> sessiondb = RedisSession(redis_conn=rconn, session_expiry=False)
>
> session.connect(request, response, db = sessiondb)
>

-- 
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: Make variable available to all sessions in memory

2015-12-16 Thread Gary Cowell
No, it'd be one pass phrase for the whole thing. Like a vault key.

There'd be another page for entering two of them so you can change the 
phrase, decrypt, encrypt pass the whole thing.

cache.ram sounds a possibility, I'll look into that, I recall some 
discussions a while back that this wasn't suitable in all cases (apache?)



On Wednesday, 16 December 2015 15:35:52 UTC, Anthony wrote:
>
> Is there a passphrase per user, or just one for the whole app (perhaps 
> entered by an admin user)? In either case, I suppose you could use 
> cache.ram, but if there is a passphrase per user, you would need a unique 
> key for each user (e.g., the user ID), and you would also need to do some 
> occasional cleanup of old passphrases.
>
> Anthony
>
> On Wednesday, December 16, 2015 at 10:27:22 AM UTC-5, Gary Cowell wrote:
>>
>> Hello
>>
>> I want to encrypt fields in the database, because of reasons. I've been 
>> through the arguments, but there we have it.
>>
>> I look at this web2py slice:
>>
>>
>> http://www.web2pyslices.com/slice/show/2012/encrypt-information-into-the-database
>>
>> And it gives a good illustration of how to do it in model with a lambda. 
>> BUT...
>>
>> It has a hard coded symmetric key, which I don't want.
>>
>> What I want to do is have a form which accepts a pass phrase.
>>
>> I will salt and hash this, to come up with a hash to use as the symmetric 
>> key. I want to make this salty hash available to all subsequent sessions 
>> and requests, but I do not want it going to session files or a database.
>>
>> What would be the best way to do that?
>>
>> In this way, if the web2py is started up, no encrypted fields will be 
>> served via REST, until someone uses the pass phrase form and puts in the 
>> correct phrase (a canary column will be decrypted to check the valid key).
>>
>> Thus, we can avoid storing symmetric key either in code, or in config 
>> files, environment variables etc.  But of course, requires intervention 
>> from a human in the event of server/service restart. This is acceptable.
>>
>> Thanks for 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] Make variable available to all sessions in memory

2015-12-16 Thread Gary Cowell
Hello

I want to encrypt fields in the database, because of reasons. I've been 
through the arguments, but there we have it.

I look at this web2py slice:

http://www.web2pyslices.com/slice/show/2012/encrypt-information-into-the-database

And it gives a good illustration of how to do it in model with a lambda. 
BUT...

It has a hard coded symmetric key, which I don't want.

What I want to do is have a form which accepts a pass phrase.

I will salt and hash this, to come up with a hash to use as the symmetric 
key. I want to make this salty hash available to all subsequent sessions 
and requests, but I do not want it going to session files or a database.

What would be the best way to do that?

In this way, if the web2py is started up, no encrypted fields will be 
served via REST, until someone uses the pass phrase form and puts in the 
correct phrase (a canary column will be decrypted to check the valid key).

Thus, we can avoid storing symmetric key either in code, or in config 
files, environment variables etc.  But of course, requires intervention 
from a human in the event of server/service restart. This is acceptable.

Thanks for 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] Re: web2py as an API provider

2015-12-16 Thread Gary Cowell
I'm using it to build REST services atop legacy data.

So, it certainly can be used in a 'professional' way, whatever that means. 
I find that DAL is useful, and JSON and REST are easy to implement and as 
you say, can concentrate on the API rather than the nuts and bolts to a 
great extent.

If you know it and like it, why not use it?  Of course you will stress test 
and measure, so you will have confidence that the solution will be okay 
with your workload.

Updates you will test on a test system of course, so no risk to production. 
At least, no unknown risk at any rate.

On Wednesday, 16 December 2015 15:02:38 UTC, desta wrote:
>
> I am thinking of using web2py to build a REST API project. I believe that 
> features like authentication and authorization will save me a lot of 
> development time and I will be able to focus on building the API. I already 
> know that web2py is a great and reliable platform but I would like to hear 
> your opinion whether web2py is suitable for a professional level API.
>
> I am wondering whether the overhead of using web2py as compared to using 
> Tornado for example will cause me problems in terms of performance. Another 
> thing that I consider is the updating. In one of my previous projects, a 
> web2py update 'broke' the application and if it was live it would have 
> caused me a long downtime.
>
> Thank you for reading and I am looking forward for your comments.
>

-- 
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: Scheduler - Worker node heartbeats stop randomly

2015-11-12 Thread Gary Cowell
I use supervisord because it brings the configuration of daemon services 
within a consistent configuration.

I can write one supervisord.conf, and so long as the supervisor is 
installed in any given distro, I can run my services. 

No need to then worry about upstart vs systemd vs SysV init vs ... whatever.

Plus, supervisor plays nice with python.

On Friday, 6 November 2015 13:47:07 UTC, Niphlod wrote:
>
> workers "check in" every heartbeat seconds. You can enable all sorts of 
> logs to trace the exact second they died.
>
> That being said, there's no way for a died process to check if it's alive. 
> That's why EVERY "daemon" should be handled by each platform's "daemon" 
> system (or a process specifically made for it): in windows it's nssm, on 
> unix it can be upstart or systemd, or a 3rd party solution like supervisord.
>
> On Friday, November 6, 2015 at 2:20:43 AM UTC+1, Benson Myrtil wrote:
>>
>> Good morning,
>>
>> I am sure this is a noob question but I cant seem to find a solid answer. 
>> I have started a worker nodes using the 'python web2py.py -K [app]' 
>> command. Everything appears to work fine for a while. My scheduled task 
>> need to run once a day but I am noticing that the worker node randomly 
>> 'dies' after a couple of hours.
>>
>> Is there some setting I am missing to prevent the worker nodes from dying 
>> even if they are idle for several hours?
>>
>

-- 
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: REST service POST responses

2015-11-10 Thread Gary Cowell
Thanks for your help, I got the GET and POST methods working. 

PUT for updating and DELETE don't seem to work though.

I changed my API on your suggestion to wrap dict() around the DAL calls:

@request.restful()
def secapi():
response.view = 'generic.'+request.extension
print "args ",request.args
print "vars ",request.vars
#pprint.pprint(request, indent=4)
def GET(*args,**vars):
patterns = 'auto'
parser = db.parse_as_rest(patterns,args,vars)
if parser.status == 200:
return dict(content=parser.response)
else:
raise HTTP(parser.status,parser.error)
def POST(table_name,**vars):
return dict(db[table_name].validate_and_insert(**vars))
def PUT(table_name,record_id,**vars):
return dict(db(db[table_name]._id==record_id).update(**vars))
def DELETE(table_name,record_id):
return dict(db(db[table_name]._id==record_id).delete())
return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)


But, I see this:

curl -X GET http://localhost:8007/apitest/default/secapi/secrets/id/21.json

{"content": [{"datavalue": "othertest", "id": 21}]}

Can do my get, then I try:

curl -X PUT -d "datavalue=updated" http:
//localhost:8007/apitest/default/secapi/secrets/id/21
invalid arguments

I see "invalid arguments" and the row is not updated:


curl -X GET http://localhost:8007/apitest/default/secapi/secrets/id/21.json

{"content": [{"datavalue": "othertest", "id": 21}]}


Is my use of curl incorrect, or is the api function for PUT coded 
incorrectly?

Sorry if it's a simple thing 

Thanks





On Monday, 9 November 2015 17:34:27 UTC, Anthony wrote:
>
> The book is incorrect. If you want to rely on the generic.json view to 
> generate the JSON response, then you must return a dictionary (otherwise, 
> no view will be called, and whatever you return will be returned directly). 
> In this case, the .validate_and_insert method returns a DAL Row object (not 
> a database record, just a Row object that contains "error" and "id" keys). 
> Apparently, when you return a Row object, the response body ends up being 
> just a concatenation of its keys, so in this case, we get "errorid" as the 
> response.
>
> You have a few options:
>
> 1. Put the result in a dictionary:
>
> return dict(result=db[table_name].validate_and_insert(**vars))
>
> 2. Convert the Row object itself to a dictionary:
>
> return db[table_name].validate_and_insert(**vars).as_dict()
>
> 3. Return JSON directly:
>
> from gluon.serializers import json
> return json(db[table_name].validate_and_insert(**vars))
>
> Anthony
>
> On Monday, November 9, 2015 at 10:50:21 AM UTC-5, Gary Cowell wrote:
>>
>> Lookint at providing simple REST API to database tables through web2py. I 
>> used this example from the book:
>> @request.restful()
>> def secapi():
>> response.view = 'generic.'+request.extension
>> def GET(*args,**vars):
>> patterns = 'auto'
>> parser = db.parse_as_rest(patterns,args,vars)
>> if parser.status == 200:
>> return dict(content=parser.response)
>> else:
>> raise HTTP(parser.status,parser.error)
>> def POST(table_name,**vars):
>> return db[table_name].validate_and_insert(**vars)
>> def PUT(table_name,record_id,**vars):
>> return db(db[table_name]._id==record_id).update(**vars)
>> def DELETE(table_name,record_id):
>> return db(db[table_name]._id==record_id).delete()
>> return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)
>>
>>
>> Now the GET methods work, I can get json responses with curl:
>>
>> curl http://localhost:8007/apitest/default/secapi/secrets.json
>> {"content": [{"datavalue": "foobar", "id": 1}, ... ]}
>>
>>
>> When I POST though:
>>
>> $ curl --data "datavalue=sometest" http:
>> //localhost:8007/apitest/default/secapi/secrets.json
>>
>> I get the response:
>>
>> errorsid
>>
>> When I really want the resource URL of the created thing.
>>
>> It did actually create the row:
>>
>> curl http://localhost:8007/apitest/default/secapi/secrets/id/20.json
>> {"content": [{"datavalue": "sometest", "id": 20}]}
>>
>> So my question  is, how do I code the POST such that it returns the 
>> resource URL that was created?  
>>
>> Thanks
>>
>

-- 
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] REST service POST responses

2015-11-09 Thread Gary Cowell
Lookint at providing simple REST API to database tables through web2py. I 
used this example from the book:
@request.restful()
def secapi():
response.view = 'generic.'+request.extension
def GET(*args,**vars):
patterns = 'auto'
parser = db.parse_as_rest(patterns,args,vars)
if parser.status == 200:
return dict(content=parser.response)
else:
raise HTTP(parser.status,parser.error)
def POST(table_name,**vars):
return db[table_name].validate_and_insert(**vars)
def PUT(table_name,record_id,**vars):
return db(db[table_name]._id==record_id).update(**vars)
def DELETE(table_name,record_id):
return db(db[table_name]._id==record_id).delete()
return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)


Now the GET methods work, I can get json responses with curl:

curl http://localhost:8007/apitest/default/secapi/secrets.json
{"content": [{"datavalue": "foobar", "id": 1}, ... ]}


When I POST though:

$ curl --data "datavalue=sometest" http:
//localhost:8007/apitest/default/secapi/secrets.json

I get the response:

errorsid

When I really want the resource URL of the created thing.

It did actually create the row:

curl http://localhost:8007/apitest/default/secapi/secrets/id/20.json
{"content": [{"datavalue": "sometest", "id": 20}]}

So my question  is, how do I code the POST such that it returns the 
resource URL that was created?  

Thanks

-- 
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: Oracle perfomance issues with version 2.12.3

2015-11-09 Thread Gary Cowell
If it was me, I'd eneable oracle events trace and look at the plans and 
wait times for the two executions.

There are a few ways to do this, don't know of a web2py DAL specific one, 
but look for

This article explains.

https://oracle-base.com/articles/misc/sql-trace-10046-trcsess-and-tkprof



On Sunday, 8 November 2015 05:16:31 UTC, tomt wrote:
>
> Hi,
>
> I encountered really slow responses when I was using my web2py app to 
> access an oracle database.  I tried to use dbstats in response.toolbar to 
> measure this, but it wouldn't show the sql or any timing information.  I 
> decided to try downgrading to an older web2py version, 2.11.2, and noticed 
> a dramatic change.
>
> web2py 2.11.2   query took 4 seconds
> web2py 2.12.3   query took > 2 minutes
>
> I've tried this several times, with the same result. Were there any 
> changes in web2py that could account for this?
>
> The query I am running was passed to sqlform.grid
>
> soequery = ( (db2.soe_tdb.utctime > fromdate)&\
>  (db2.soe_tdb.utctime < todate)&\
>  (db2.soe_tdb.stationname.belongs(stationlist))&\
>  (db2.soe_tdb.pointnumber == db2.statuspoint.pointnumber)&\
>  (db2.statuspoint.pointaccessarea == 
> db2.accessareaassignment.setnumber)&\
>  (db2.accessareaassignment.referencename == 'SOE')&\
>  ~(db2.statuspoint.pointname.like('%@%')) )
>
> orderby = [db2.soe_tdb.utctime]
>
> grid=SQLFORM.grid(
> query=soequery,
> deletable=False,editable=False,details=False,
> searchable=True,fields=fields,headers=headers,
> paginate=10,csv=False,maxtextlengths=maxtextlengths,
> orderby=orderby,
> )
>
> Please let me know if there is any other information that I could provide 
> to try to resolve this.
>
> Thanks in advance, - Tom
>

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


Re: [web2py] bootstrap3 formstyle checkboxes

2015-11-06 Thread Gary Cowell
Okay, I see that now. 

Thank you and everyone else for the input.


On Friday, 6 November 2015 07:06:34 UTC, Annet wrote:
>
>
> That the labels for boolean fields are consistent in appearance with the 
>> labels for other classes of field.
>>
>> So, emboldened and on the left.
>>
>
> That's not the way Bootstrap styles a boolean checkbox see the Remember me 
> input for both
> http://getbootstrap.com/css/#forms-inline and  
> http://getbootstrap.com/css/#forms-horizontal
>
> Web2py styles the boolean checkbox correctly. If you want it styled 
> differently you have to
> code your own widget.
>
>
> Kind regards,
>
> Annet
>

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


Re: [web2py] bootstrap3 formstyle checkboxes

2015-11-04 Thread Gary Cowell
Ah, I see that my 'checkbox' is actually this widget by default:

SQLFORM.widgets.boolean.widget

So then it's in fact the boolean.widget that isn't being correctly styled.

Still trying to work out where the styling for boolean.widget comes from. 

Still think it's something that will be relvealed by sqlhtml.py , but not 
nailed it yet.

At least now I know which widget my form is using.

It has consistent styling in the stacked formstyle, just not in the inine 
formstyle.



On Wednesday, 4 November 2015 14:52:39 UTC, Richard wrote:
>
> In the book it mention that radio and checkboxes widget have different 
> style attribute, your issue is probably related to this particularity of 
> these widget ?
>
> Quote from the book :
> Widgets are helper factories and their first two arguments are always 
> field and value. The other arguments can include normal helper attributes 
> such as _style, _class, etc. Some widgets also take special arguments. In 
> particular SQLFORM.widgets.radio and SQLFORM.widgets.checkboxestake a 
> style argument (not to be confused with _style) which can be set to 
> "table", "ul", or "divs" in order to match the formstyle of the 
> containing form.
>
> On Wed, Nov 4, 2015 at 2:27 AM, Gary Cowell <gary@gmail.com 
> > wrote:
>
>> That the labels for boolean fields are consistent in appearance with the 
>> labels for other classes of field.
>>
>> So, emboldened and on the left. 
>>
>> On Tuesday, 3 November 2015 16:28:15 UTC, Richard wrote:
>>>
>>> What is the expected behavior?
>>>
>>> On Tue, Nov 3, 2015 at 4:50 AM, Gary Cowell <gary@gmail.com> wrote:
>>>
>>>> Web2py version:
>>>> >>> import gluon.widget
>>>> >>> print gluon.widget.ProgramVersion
>>>> Version 2.12.3-stable+timestamp.2015.08.19.00.18.03
>>>>
>>>>
>>>> When using bootstrap3_inline for forms, the checkbox lables are not 
>>>> correctly styled:
>>>>
>>>>
>>>>
>>>>
>>>> This is my form code:
>>>>
>>>> form=SQLFORM.factory(
>>>> Field('SystemName',label='System Name', length=80, required=
>>>> True, requires=IS_NOT_EMPTY()),
>>>> Field('Image',label='Base System', requires=IS_IN_SET(imageList
>>>> ,zero='Choose Base System')),
>>>> Field('Customer',label='Customer', requires=IS_IN_DB(dbcccs,
>>>> dbcccs.v_clients.cc_customer_id,'%(cc_name)s (%(cc_customer_id)s)',zero
>>>> ='Choose Customer')),
>>>> Field('publicsystem','boolean',label='Public', default='False'
>>>> ),
>>>> Field('customports','boolean',label='Custom Ports?', default=
>>>> 'False'),
>>>> Field('customportlist',label='Custom Port List', required=False
>>>> , requires=IS_MATCH('^(\d+(,\d+)*)?$', error_message="Comma delimited 
>>>> port list, e.g. 5001,5050,9127")),
>>>> formstyle='bootstrap3_inline'
>>>> )
>>>>
>>>>
>>>> And this code looks suspicious in gluon/sqlhtml.py:
>>>>
>>>> def formstyle_bootstrap3_inline_factory(col_label_size=3):
>>>> """ bootstrap 3 horizontal form layout
>>>>
>>>> Note:
>>>> Experimental!
>>>> """
>>>> def _inner(form, fields):
>>>> form.add_class('form-horizontal')
>>>> label_col_class = "col-sm-%d" % col_label_size
>>>> col_class = "col-sm-%d" % (12 - col_label_size)
>>>> offset_class = "col-sm-offset-%d" % col_label_size
>>>> parent = CAT()
>>>> for id, label, controls, help in fields:
>>>> # wrappers
>>>> _help = SPAN(help, _class='help-block')
>>>> # embed _help into _controls
>>>> _controls = DIV(controls, _help, _class=col_class)
>>>> if isinstance(controls, INPUT):
>>>> if controls['_type'] == 'submit':
>>>> controls.add_class('btn btn-primary')
>>>> _controls = DIV(controls, _class="%s %s" % (
>>>> col_class, offset_class))
>>>> if controls['_type'] == 'button':
>>>> controls.add_class('btn btn-default')
>>>> elif controls['_type'] == 'fil

[web2py] bootstrap3 formstyle checkboxes

2015-11-03 Thread Gary Cowell
Web2py version:
>>> import gluon.widget
>>> print gluon.widget.ProgramVersion
Version 2.12.3-stable+timestamp.2015.08.19.00.18.03


When using bootstrap3_inline for forms, the checkbox lables are not 
correctly styled:




This is my form code:

form=SQLFORM.factory(
Field('SystemName',label='System Name', length=80, required=True, 
requires=IS_NOT_EMPTY()),
Field('Image',label='Base System', requires=IS_IN_SET(imageList,zero
='Choose Base System')),
Field('Customer',label='Customer', requires=IS_IN_DB(dbcccs,dbcccs.
v_clients.cc_customer_id,'%(cc_name)s (%(cc_customer_id)s)',zero='Choose 
Customer')),
Field('publicsystem','boolean',label='Public', default='False'),
Field('customports','boolean',label='Custom Ports?', default='False'
),
Field('customportlist',label='Custom Port List', required=False, 
requires=IS_MATCH('^(\d+(,\d+)*)?$', error_message="Comma delimited port 
list, e.g. 5001,5050,9127")),
formstyle='bootstrap3_inline'
)


And this code looks suspicious in gluon/sqlhtml.py:

def formstyle_bootstrap3_inline_factory(col_label_size=3):
""" bootstrap 3 horizontal form layout

Note:
Experimental!
"""
def _inner(form, fields):
form.add_class('form-horizontal')
label_col_class = "col-sm-%d" % col_label_size
col_class = "col-sm-%d" % (12 - col_label_size)
offset_class = "col-sm-offset-%d" % col_label_size
parent = CAT()
for id, label, controls, help in fields:
# wrappers
_help = SPAN(help, _class='help-block')
# embed _help into _controls
_controls = DIV(controls, _help, _class=col_class)
if isinstance(controls, INPUT):
if controls['_type'] == 'submit':
controls.add_class('btn btn-primary')
_controls = DIV(controls, _class="%s %s" % (col_class, 
offset_class))
if controls['_type'] == 'button':
controls.add_class('btn btn-default')
elif controls['_type'] == 'file':
controls.add_class('input-file')
elif controls['_type'] in ('text', 'password'):
controls.add_class('form-control')
elif controls['_type'] == 'checkbox':
label['_for'] = None
label.insert(0, controls)
_controls = DIV(DIV(label, _help, _class="checkbox"),
_class="%s %s" % (offset_class, 
col_class))
label = ''
elif isinstance(controls, (SELECT, TEXTAREA)):
controls.add_class('form-control')

The checkbox control type is doing something odd with labels.




-- 
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: Has somebody used codenvy for web2py application deployment?

2015-11-03 Thread Gary Cowell
No, but could you not use pythonanywhere free app, and host mercurial (or, 
git, if you must) on bitbucket?

Small projects on bitbucket can have up to five users. 

On Monday, 2 November 2015 16:55:02 UTC, at wrote:
>
> Hi,
>
> I was looking for a place where I can deploy a database driven web2py 
> application free of cost. This small application is for personal use. I am 
> familiar with deployments of such applications on AWS, DigitalOcean, 
> pythonanywhere and other hosting services. But along-with hosting I was 
> looking for git repository integration so that one of my friend can also 
> collaborate in this project. Is codenvy the right thing for my needs?
>
> Thanks,
> AT
>

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


Re: [web2py] bootstrap3 formstyle checkboxes

2015-11-03 Thread Gary Cowell
That the labels for boolean fields are consistent in appearance with the 
labels for other classes of field.

So, emboldened and on the left. 

On Tuesday, 3 November 2015 16:28:15 UTC, Richard wrote:
>
> What is the expected behavior?
>
> On Tue, Nov 3, 2015 at 4:50 AM, Gary Cowell <gary@gmail.com 
> > wrote:
>
>> Web2py version:
>> >>> import gluon.widget
>> >>> print gluon.widget.ProgramVersion
>> Version 2.12.3-stable+timestamp.2015.08.19.00.18.03
>>
>>
>> When using bootstrap3_inline for forms, the checkbox lables are not 
>> correctly styled:
>>
>>
>>
>>
>> This is my form code:
>>
>> form=SQLFORM.factory(
>> Field('SystemName',label='System Name', length=80, required=True, 
>> requires=IS_NOT_EMPTY()),
>> Field('Image',label='Base System', requires=IS_IN_SET(imageList,
>> zero='Choose Base System')),
>> Field('Customer',label='Customer', requires=IS_IN_DB(dbcccs,
>> dbcccs.v_clients.cc_customer_id,'%(cc_name)s 
>> (%(cc_customer_id)s)',zero='Choose 
>> Customer')),
>> Field('publicsystem','boolean',label='Public', default='False'),
>> Field('customports','boolean',label='Custom Ports?', default=
>> 'False'),
>> Field('customportlist',label='Custom Port List', required=False, 
>> requires=IS_MATCH('^(\d+(,\d+)*)?$', error_message="Comma delimited port 
>> list, e.g. 5001,5050,9127")),
>> formstyle='bootstrap3_inline'
>> )
>>
>>
>> And this code looks suspicious in gluon/sqlhtml.py:
>>
>> def formstyle_bootstrap3_inline_factory(col_label_size=3):
>> """ bootstrap 3 horizontal form layout
>>
>> Note:
>> Experimental!
>> """
>> def _inner(form, fields):
>> form.add_class('form-horizontal')
>> label_col_class = "col-sm-%d" % col_label_size
>> col_class = "col-sm-%d" % (12 - col_label_size)
>> offset_class = "col-sm-offset-%d" % col_label_size
>> parent = CAT()
>> for id, label, controls, help in fields:
>> # wrappers
>> _help = SPAN(help, _class='help-block')
>> # embed _help into _controls
>> _controls = DIV(controls, _help, _class=col_class)
>> if isinstance(controls, INPUT):
>> if controls['_type'] == 'submit':
>> controls.add_class('btn btn-primary')
>> _controls = DIV(controls, _class="%s %s" % (col_class
>> , offset_class))
>> if controls['_type'] == 'button':
>> controls.add_class('btn btn-default')
>> elif controls['_type'] == 'file':
>> controls.add_class('input-file')
>> elif controls['_type'] in ('text', 'password'):
>> controls.add_class('form-control')
>> elif controls['_type'] == 'checkbox':
>> label['_for'] = None
>> label.insert(0, controls)
>> _controls = DIV(DIV(label, _help, _class="checkbox"),
>> _class="%s %s" % (offset_class, 
>> col_class))
>> label = ''
>> elif isinstance(controls, (SELECT, TEXTAREA)):
>> controls.add_class('form-control')
>>
>> The checkbox control type is doing something odd with labels.
>>
>>
>>
>>
>> -- 
>> 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+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


[web2py] Re: How to provide feedback on button in LINKS section of sqlform.grid ?

2015-10-16 Thread Gary Cowell
Oh yes!

I was so close. Thanks for the help, you solved it :)


On Friday, 16 October 2015 04:34:04 UTC+1, DenesL wrote:
>
> Change that to
>
>   el.text = "Working...";
>
>
>
>
>
> On Sunday, October 11, 2015 at 4:20:58 AM UTC-4, Gary Cowell wrote:
>>
>> Hello. 
>>
>> I'm trying to give the user some feedback when they click on a links 
>> (link button) in the links section of a sqlform grid.
>>
>> I have this button code:
>>
>>button = A(
>> SPAN(_class="icon play icon-play glyphicon glyphicon-play")
>> ,"Start"
>> ,_id="startstop"
>> ,_class="button btn btn-success"
>> ,_title="Start"
>> ,_onclick="return change(this);"
>> ,_href=URL("dynamic","startstop",
>> args=[system.id, buttonURL, buttonTitle, db.e5system] , 
>> user_signature=True )
>> )
>>
>>
>> And this script in my view:
>>
>> 
>> function change( el )
>> {
>> el.value = "Working...";
>> }
>> 
>>
>>
>> But nothing happens when I click the button.
>>
>> I've tried many bits of javascript over the last few days and I'm getting 
>> nowhere fast.
>>
>> Can someone kindly give me a steer on what to do ?
>>
>> Thanks
>>
>

-- 
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: Pretty printing a string in a view

2015-10-13 Thread Gary Cowell
When I'm presenting for example log data from a process execution with 
web2py, I'll use PRE and put it in a textarea.

On Monday, 12 October 2015 11:07:52 UTC+1, Callum Daw wrote:
>
> Thank you so much, the  tag worked a charm, the issue I was facing is 
> that it returns XML to my unit which connects to it so having a  
> would have caused problems. Thanks again!
>
> On Monday, 12 October 2015 10:50:49 UTC+1, Leonel Câmara wrote:
>>
>> This is just how HTML works. For instance if you put this in your view:
>>
>> 
>> {{=mystring}}
>> 
>>
>> You will see the newlines and spacing.
>>
>> Otherwise, if you don't want it showing like that, you need to prepare 
>> your string better (for instance replacing \n in the string with ).
>>
>
>
> Isys Group Ltd is a wholly owned subsidiary of Capita Plc 
> .
>
>
>
>

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


[web2py] How to provide feedback on button in LINKS section of sqlform.grid ?

2015-10-11 Thread Gary Cowell
Hello. 

I'm trying to give the user some feedback when they click on a links (link 
button) in the links section of a sqlform grid.

I have this button code:

   button = A(
SPAN(_class="icon play icon-play glyphicon glyphicon-play")
,"Start"
,_id="startstop"
,_class="button btn btn-success"
,_title="Start"
,_onclick="return change(this);"
,_href=URL("dynamic","startstop",
args=[system.id, buttonURL, buttonTitle, db.e5system] , 
user_signature=True )
)


And this script in my view:


function change( el )
{
el.value = "Working...";
}



But nothing happens when I click the button.

I've tried many bits of javascript over the last few days and I'm getting 
nowhere fast.

Can someone kindly give me a steer on what to do ?

Thanks

-- 
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: Don't laugh but I like the admin editor ;o)

2015-10-10 Thread Gary Cowell
I like it too. It makes it possible to work on sites with just a browser, 
like on a Chromebook. Which in fact, I do.

On Saturday, 10 October 2015 13:06:32 UTC+1, Edward Shave wrote:
>
> Only thing is I can't find much by way of instructions for it so if anyone 
> can point me in the right direction.
>
> I'm particularly interested in search and replace and any short-cut keys...
>
> Also any nifty undocumented features you may know about.
>
> best regards
> Ed
>

-- 
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: Make custom SQLFORM grid LINKS buttons give feedback like regular web2py form buttons?

2015-10-09 Thread Gary Cowell
I'm revisiting this again.

Think it should be possible with a javascript onclick action, but how can I 
do this from within my A( helper ?

My problem with using web2py I think, is that I'm a python programmer who's 
trying to write apps that run on web pages, but I know very little 
html/javascript.

Going to keep trying for a solution to this.

On Saturday, 25 July 2015 01:40:53 UTC+1, Anthony wrote:
>
> I think that is set up to work only with links that fire Ajax requests or 
> submit buttons in forms.
>
> On Friday, July 24, 2015 at 4:52:24 PM UTC-4, Gary Cowell wrote:
>>
>> I have a SQLFORM grid with some buttons in the LINKS :
>>
>>
>> <https://lh3.googleusercontent.com/-USA-OMFbJNY/VbKb1nosPcI/2Vc/usFqvdAFyiI/s1600/links.png>
>> They are generated thus:
>>
>> def makeButton( ... )
>>
>>
>> ...
>>
>>
>> if result == 0:
>> status = 'Up'
>> buttonTitle='Stop'
>> buttonURL='stop'
>> buttonClass='button btn btn-danger'
>> buttonIcon='icon stop icon-stop glyphicon glyphicon-stop'
>> elif result == 2:
>> status = 'Not Built'
>> buttonTitle='Not Built'
>> buttonURL='build'
>> buttonClass='button btn btn-info'
>> buttonIcon='icon play icon-play glyphicon glyphicon-play'
>> else:
>> status = 'Down'
>> buttonTitle='Start'
>> buttonURL='start'
>> buttonClass='button btn btn-success'
>> buttonIcon='icon play icon-play glyphicon glyphicon-play'
>> button = A(
>> SPAN(_class=buttonIcon)
>> ,buttonTitle
>> ,_class=buttonClass
>> ,_title=buttonTitle
>> ,_href=URL("dynamic","startstop",
>> args=[system.id, buttonURL, buttonTitle, db.e5system] , 
>> user_signature=True )
>> )
>> return button
>>
>>
>>
>>
>> What do I need to add so that when I press my buttons, it (they) change 
>> to dim and show 'Working' like with other web2py buttons?
>>
>> Thank you for 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] Re: Grid without consulting database

2015-09-22 Thread Gary Cowell
The need to represent data from web services inside a web2py app must be a 
fairly common requirement, I think. I certainly need(ed) to for a project.

I used a sqlite mem db for each page (I was calling Amazon AWS through 
boto, get lists of stuff, etc.). I did three things to represent my data.

Firstly, I called some aws APIs and store the result in dicts and lists in 
session.

Secondly, I used sqlite mem db DAL object , iterated inserts to these from 
the dicts/lists , and built sqlform.grid from these.

Thirdly, I used sqlform factory with IS_IN_SET for my lists and dicts in 
session, so I could provide drop down lists of AWS responses in forms.

This was a small, but useful app, which was used by no more than about 6 
people, so it worked well. Don't know how well this will scale with the 
sqlite mem db (probably not well).

I'd love a component that would populate grids and lists from arbitrary 
data, such as from boto or indeed any other web service call.

On Thursday, 10 September 2015 22:42:30 UTC+1, Luis Valladares wrote:
>
> Hello! I'm trying to use SQLFORM.grid (or something like this) to my 
> website, but this page doesnt have a database because it consumes all the 
> data form a service, so i ask the service for the list of records in a 
> table and i recieve it in json format and transform to dictionary.
>
> What i want to do is use this dictionary to create a grid (Like the 
> SQLFORM.grid) but the grid doesnt work if i dont specify a query, there is 
> a way to create a grid without query and instead with a dictionary?
>
> Thanks for any help you can give!
>

-- 
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] Make custom SQLFORM grid LINKS buttons give feedback like regular web2py form buttons?

2015-07-24 Thread Gary Cowell
I have a SQLFORM grid with some buttons in the LINKS :

https://lh3.googleusercontent.com/-USA-OMFbJNY/VbKb1nosPcI/2Vc/usFqvdAFyiI/s1600/links.png
They are generated thus:

def makeButton( ... )


...


if result == 0:
status = 'Up'
buttonTitle='Stop'
buttonURL='stop'
buttonClass='button btn btn-danger'
buttonIcon='icon stop icon-stop glyphicon glyphicon-stop'
elif result == 2:
status = 'Not Built'
buttonTitle='Not Built'
buttonURL='build'
buttonClass='button btn btn-info'
buttonIcon='icon play icon-play glyphicon glyphicon-play'
else:
status = 'Down'
buttonTitle='Start'
buttonURL='start'
buttonClass='button btn btn-success'
buttonIcon='icon play icon-play glyphicon glyphicon-play'
button = A(
SPAN(_class=buttonIcon)
,buttonTitle
,_class=buttonClass
,_title=buttonTitle
,_href=URL(dynamic,startstop,
args=[system.id, buttonURL, buttonTitle, db.e5system] , 
user_signature=True )
)
return button




What do I need to add so that when I press my buttons, it (they) change to 
dim and show 'Working' like with other web2py buttons?

Thank you for 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] Re: listen on all interfaces 0.0.0.0 or specific interface - how ?

2015-07-16 Thread Gary Cowell
Thanks Massimo. 



On Thursday, 16 July 2015 00:49:32 UTC+1, Massimo Di Pierro wrote:

 This is not valid syntax: 

 /web2py.py --ip 10.2.1.15:8000 #WRONG

 supposed to be

 /web2py.py --ip 10.2.1.15 --port 8000 http://10.2.1.15:8000/




 On Wednesday, 15 July 2015 18:36:58 UTC-5, Gary Cowell wrote:

 I'm trying to get the web2py.py to listen on all interfaces in 
 development.

 I'm sure I've done this before. I know I have. But I can't make this work 
 at all now. I get this:

 $ ./web2py.py --ip 10.2.1.15:8000
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2015
 Version 2.11.2-stable+timestamp.2015.05.30.16.33.24
 Database drivers available: sqlite3, imaplib, cx_Oracle, pymysql, pg8000
 WARNING:web2py:GUI not available because Tk library is not installed
 choose a password:

 please visit:
 http://[10.2.1.15:8000]:8000/
 use kill -SIGTERM 6380 to shutdown the web2py server


 ERROR:Rocket.Errors.Port8000:Socket 10.2.1.15:8000:8000 in use by other 
 process and it won't share.
 WARNING:Rocket.Errors.Port8000:Listener started when not ready.

 The please visit line looks odd, and the Rocket.Erros.Port line too. 
 Why is the port there twice?

 The only way I can get it to start, is by omitting the --ip option all 
 together so it starts on 127.0.0.1:8000 , I can't even specify --ip 
 127.0.0.1:8000 because I get the same style of error.

 I'm prepared to kick myself when I find out what silly thing I'm doing 
 wrong :/

 Thanks



-- 
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] listen on all interfaces 0.0.0.0 or specific interface - how ?

2015-07-15 Thread Gary Cowell
I'm trying to get the web2py.py to listen on all interfaces in development.

I'm sure I've done this before. I know I have. But I can't make this work 
at all now. I get this:

$ ./web2py.py --ip 10.2.1.15:8000
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2015
Version 2.11.2-stable+timestamp.2015.05.30.16.33.24
Database drivers available: sqlite3, imaplib, cx_Oracle, pymysql, pg8000
WARNING:web2py:GUI not available because Tk library is not installed
choose a password:

please visit:
http://[10.2.1.15:8000]:8000/
use kill -SIGTERM 6380 to shutdown the web2py server


ERROR:Rocket.Errors.Port8000:Socket 10.2.1.15:8000:8000 in use by other 
process and it won't share.
WARNING:Rocket.Errors.Port8000:Listener started when not ready.

The please visit line looks odd, and the Rocket.Erros.Port line too. Why 
is the port there twice?

The only way I can get it to start, is by omitting the --ip option all 
together so it starts on 127.0.0.1:8000 , I can't even specify --ip 
127.0.0.1:8000 because I get the same style of error.

I'm prepared to kick myself when I find out what silly thing I'm doing 
wrong :/

Thanks

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


Re: [web2py] Re: Web2py mobile app using Kivy

2015-06-04 Thread Gary Cowell
This UI independence is the most important thing, actually (for me)

There's the 'Visual Basic' way of coding, where each control component will 
contain the business logic for the thing that happens when you press the 
button. I see this so often.

But better, is to have a module, or modules, that perform the business 
logic, interact with other web services, and have web2py call upon these 
module functions when UI interactions take place. In this way, you can 
build useful things using your business rules, from command line admin 
tools, to web apps using 'framework of the day', to desktop or mobile GUI 
apps in Kivy or anything else, and you're always leveraging your module 
code.

Example, I was working on a tool to interact with Amazon Web Services, 
cloudformation stack creation etc. Originally I built the app using pyqt, 
but then I switched to pyside, not a huge change there, but still.   Then I 
built a new UI in kivy and deployed an android version. Finally the 
production version I built with web2py and it's there still.  I could have 
used django at that point, or turbogears, or whatever (although I most like 
web2py for web development in python).  Point is though, I didn't have to 
rewrite 80% of my code each time. Just the UI parts, and learning things 
like ajax reloading in web2py. 

This was developing the entire app on a new platform.

If I'd started with web2py, and built and deployed the first version on 
that platform as you have done, then any mobile development would most 
likely have used web services exposed by my web2py app, and interacted with 
those.  Seeing you already have a web2py app running, exposing some 
services you want to access via mobile seems like the way to do it to me.


On Tuesday, 2 June 2015 00:36:09 UTC+1, Encompass solutions wrote:

 The best thing to do here is abstract your interface.  Web2py does a fine 
 job of it.
 Most likely your wanting to make the app and then communicate over json 
 objects in post requests.
 With Kivy you should be able to make something pretty interesting and you 
 can use the same skills you have learned in python there. And then QML is 
 pretty awesome stuff.  I used to work for Qt so I would know. :)
 I haven't seen Kivy in production code yet, but you can be a first. :)


 On Mon, Jun 1, 2015 at 9:04 PM eric cuver amihaco...@gmail.com 
 javascript: wrote:

 good question I am also interested in the answer


 Le lundi 1 juin 2015 16:19:56 UTC+2, Joe a écrit :

 I developed a web app with Web2py. It works great, I thing Web2py is 
 fantastic.

 I want to create a mobile app from my web app and I am not sure what is 
 the best approach.
 Does anyone have any experience using Kivy? Does it work with Web2py? 
 Or, is there a alternative solution to Kivy?

  -- 
 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+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.



-- 
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: Best way to load password at startup.

2015-04-28 Thread Gary Cowell
For one of my apps, I added extra fields to auth to hold some Amazon AWS 
credentials for the logged in user.

This means that I can access the required API keys when logged in , but 
because it's part of the database, it doesn't get committed to source 
control.

For accessing external database legacy database in another app, my web2py 
app was using postgresql, but I needed to access some tables in a legacy 
Oracle database.

So, I stored the location and access credentials in a table in postgres, 
and used those when opening the DAL for the legacy Oracle system.

Interesting to see if there's a canonical or best way to do this. 
Environmental variables, config files, database tables, all have weaknesses 
if used to store credentials.

On Monday, 27 April 2015 15:40:06 UTC+1, hiro wrote:

 I connect to an external DB in one of my models:

 my_model.db:

 my_db = DAL(
 'postgres://user:password@url/database',
 pool_size=20,
 after_connection=lambda self: self.execute('set search_path to 
 my_schema, other_schema, public; set statement_timeout to 6;'),
 migrate=False
 )

 Now we are planning to adding the project to a git repository and I would 
 now like to store our password there. 

 I though about just creating the connection string by reading the .pgpass 
 file. It will probably work but it seems unnecessary to read .pgpass every 
 request. What is the best way to load the password at startup but not all 
 other requests? Maybe just create in if statement?


-- 
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: AJAX div reload indicator

2015-04-25 Thread Gary Cowell
I've tried twice before to post my solution on this, but here's a third try:

So I solved this for my app, in the following way. For reference for 
others, and for comment if I'm doing something stupid. But, this works for 
me:

In my view:
{{=LOAD('tenant','stackList.load',ajax=True, target=stackList,vars={
'reload_div':'stackList'},content=CENTER(IMG(_src=URL(request.application,
'static','images/ajax_loader_blue_256.gif'}}

I'm using my 'tenant' 'stackList' controller. This content= tag, handles 
the AJAX preload spinner upon page load.   When the component is told to 
refresh, using (in another controller):

spinner=CENTER(IMG(_src=URL(request.application,'static',
'images/ajax_loader_blue_256.gif')))
response.js = 
jQuery('#stackList').html('{0}');jQuery('#stackList').get(0).reload().
format(spinner)

I define my image to use, and then my response has two jQuery calls, the 
first replaces my #stackList div with the spinner image, and the second 
calls the ajax reload.

So when I click the refresh action on the page, the div is replaced 
immedialey with a preload spinner, and then some seconds later, the data 
appears.  It would look more elegant perhaps if I were to fade out the div 
instead. I don't know, but if you can do it with jQuery, you could do it 
like this.

Actually I think my solution ended up being much simpler than almost any 
example of this I've seen so perhaps it can help some people.

On Tuesday, 21 April 2015 16:05:32 UTC+1, Gary Cowell wrote:

 Hello

 I have a DIV component I'm reloading using another controller , so I end 
 up calling:

response.js = jQuery('#stackList').get(0).reload()

 Problem is, my stackList controller function does a lot of work to rebuild 
 the grid, it makes many AWS api calls, to populate the grid.

 The reload works, and the grid eventually updates, but there is no 
 indication that it's doing anything, it has the old values for ages (well, 
 10 seconds or so, seems like ages) after the other form is submitted then 
 it snaps to its new output.

 How can I make the div update immediately with a spinning 'progress' , or 
 maybe fade it out at the start of the refresh, and in at the end? Anything 
 to provide a visual clue that the controller function is running, and that 
 the display is stale

 Thanks


-- 
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: AJAX div reload indicator

2015-04-25 Thread Gary Cowell
I found that I can use:

{{=LOAD('tenant','stackList.load',ajax=True, target=stackList,vars={
'reload_div':'stackList'},content=CENTER(IMG(_src=URL(request.application,
'static','images/ajax_loader_blue_256.gif'}}

So this gives me a spinner gif inside my component div on page reload.

It doesn't give me a spinner though, when 

response.js = jQuery('#stackList').get(0).reload()

is called.

So my question still stands, the reload time for my stackList controller is 
quite long, looks okay on page load, but spinner is missing on refresh.

Do I have to do something more to get the spinner to work on refresh, or 
should I be doing my component refresh a different way?



On Tuesday, 21 April 2015 16:05:32 UTC+1, Gary Cowell wrote:

 Hello

 I have a DIV component I'm reloading using another controller , so I end 
 up calling:

response.js = jQuery('#stackList').get(0).reload()

 Problem is, my stackList controller function does a lot of work to rebuild 
 the grid, it makes many AWS api calls, to populate the grid.

 The reload works, and the grid eventually updates, but there is no 
 indication that it's doing anything, it has the old values for ages (well, 
 10 seconds or so, seems like ages) after the other form is submitted then 
 it snaps to its new output.

 How can I make the div update immediately with a spinning 'progress' , or 
 maybe fade it out at the start of the refresh, and in at the end? Anything 
 to provide a visual clue that the controller function is running, and that 
 the display is stale

 Thanks


-- 
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: AJAX div reload indicator

2015-04-25 Thread Gary Cowell
I think I found my solution, in my controlling function when I send the 
response.js for the reload, I'm doing it like this now:

spinner=CENTER(IMG(_src=URL(request.application,'static',
'images/ajax_loader_blue_256.gif')))
response.js = 
jQuery('#stackList').html('{0}');jQuery('#stackList').get(0).reload().
format(spinner)



So instead of just sending the div a reload, I'm using a JQUERY call to 
replace the DIV with a CENTER IMG of my spinner.

It seems to work, can anyone think why this is a bad idea?


On Tuesday, 21 April 2015 16:05:32 UTC+1, Gary Cowell wrote:

 Hello

 I have a DIV component I'm reloading using another controller , so I end 
 up calling:

response.js = jQuery('#stackList').get(0).reload()

 Problem is, my stackList controller function does a lot of work to rebuild 
 the grid, it makes many AWS api calls, to populate the grid.

 The reload works, and the grid eventually updates, but there is no 
 indication that it's doing anything, it has the old values for ages (well, 
 10 seconds or so, seems like ages) after the other form is submitted then 
 it snaps to its new output.

 How can I make the div update immediately with a spinning 'progress' , or 
 maybe fade it out at the start of the refresh, and in at the end? Anything 
 to provide a visual clue that the controller function is running, and that 
 the display is stale

 Thanks


-- 
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] AJAX div reload indicator

2015-04-21 Thread Gary Cowell
Hello

I have a DIV component I'm reloading using another controller , so I end up 
calling:

   response.js = jQuery('#stackList').get(0).reload()

Problem is, my stackList controller function does a lot of work to rebuild 
the grid, it makes many AWS api calls, to populate the grid.

The reload works, and the grid eventually updates, but there is no 
indication that it's doing anything, it has the old values for ages (well, 
10 seconds or so, seems like ages) after the other form is submitted then 
it snaps to its new output.

How can I make the div update immediately with a spinning 'progress' , or 
maybe fade it out at the start of the refresh, and in at the end? Anything 
to provide a visual clue that the controller function is running, and that 
the display is stale

Thanks

-- 
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: question about components

2015-04-20 Thread Gary Cowell
Thanks for the opinions. I'm looking at ractive

On Monday, 20 April 2015 04:30:32 UTC+1, Ramkrishan Bhatt wrote:

 I am agree with Massimo you must try angular or reactive to make SPA. It 
 will surly solve your problem.

-- 
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] question about components

2015-04-18 Thread Gary Cowell
Hello

I'm struggling with components, with ajax. I've been trying to follow 
examples in the book and blog and not getting very far. 

I have an application that's based on five controller functions, with a 
page each. Each page has the same header at the top, and the bottom two 
thirds of the page holds the form for that page. This clearly means that 
when I choose a new menu option, I get a page refresh.

So what I thought I wanted to do, was have the bottom two thirds of the 
page hold a div and component, but a generic div into which I would load my 
required form for the menu option that was just selected.

So my menu options would cause a different form to load in the bottom of 
the page, and process it as it does now. This would allow me also to 
refresh sqlform.grid contents without a page reload too.

So instead of five pages, I'd have one page, and five components, but only 
one div for them to go in

Does this sound like something possible? A reasonable way to construct an 
app? The page reloads look kind of ugly at the moment.

I'm struggling though with the examples,  could someone please give a 
couple of pointers about how this might be accomplished?

Thanks

-- 
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] HTML helpers to build a bootstrap dropdown button?

2015-04-15 Thread Gary Cowell
Hello

I use code such as this:

status = 'Delete'
buttonTitle='Delete'
buttonURL='deleteStack'
buttonClass='button btn btn-danger'
buttonIcon='icon trash icon-trash glyphicon glyphicon-trash'
button = A(
 SPAN(_class=buttonIcon)
 ,buttonTitle
 ,_class=buttonClass
 ,_title=buttonTitle
 ,_onclick = return confirm('Are you sure? Really delete 
{0}?');.format(tenant)
 ,_enabled=False
 ,_href=URL(tenant,deleteStack,args=[tenant] , 
user_signature=True )
 )
 return button

To return a button to a SQLFORM.grid, that has bootstrap style and this 
works well.

What I'd like to do is get rid of all the buttons in my links= parameter, 
and replace with one single dropdown button.

I've been trying to follow this 
http://getbootstrap.com/components/#btn-groups:

div class=btn-group role=group aria-label=...
  button type=button class=btn btn-default1/button
  button type=button class=btn btn-default2/button

  div class=btn-group role=group
button type=button class=btn btn-default dropdown-toggle 
data-toggle=dropdown aria-expanded=false
  Dropdown
  span class=caret/span
/button
ul class=dropdown-menu role=menu
  lia href=#Dropdown link/a/li
  lia href=#Dropdown link/a/li
/ul
  /div
/div


To create a drop down, but I'm trying myself in knots trying to work out 
how to nest the necessary DIV, SPAN, UL, and LI  HTML helpers.  It seems 
similar to how the menu dropdowns work.

Can this idea even work as q SQLFORM.grid links button?

Thanks :)


-- 
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: Bug in SQLFORM.factory bootstrap3 formstyles ?

2015-04-15 Thread Gary Cowell
It makes it end up looking like this when using a dropdown:

Wide Dropdown http://i.imgur.com/qKRRpST.png



On Monday, 13 April 2015 06:35:05 UTC+1, Gary Cowell wrote:

 Hi

 Running with:


 2.10.3-stable+timestamp.2015.04.02.21.42.07

 (Running on Rocket 1.2.6, Python 2.7.5) 


 I find that this code:

 xadb = DAL('sqlite:memory:')
 xadb.define_table('regiontable', Field('region', length=20,label=
 'Region'))

 form = SQLFORM.factory(SQLField('Region', label='Select a region', 
 length=20,
requires=IS_IN_DB(xadb,'regiontable.region',orderby=xadb.
 regiontable.region)),
formstyle='bootstrap3_inline'
 )

 Produces a drop-down that is the entire width of the page when viewed in 
 Firefox.  Same for bootstrap3_stacked

 The 'classic' formstyles, of table2cols, table3cols etc. don't look as 
 nice, don't have the bootstrap button, but they produce fields of the 
 correct width.

 Is this a bug in the bootstrap3 , or did I need to do more to my 
 SQLFORM.factory to get the correct width?

 Thanks


-- 
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: Run linux ssh script

2015-04-15 Thread Gary Cowell
I might be inclined (have done, in fact) to use a python ssh implementation 
to do this, rather than using shell.

paramiko would be one such module, 'spur' module is easier to use.  Not 
using shell gives the python greater control over error handling and 
recovery, among other things.

Of course, if it's a complex shell script, there's reimplementation to do.  



On Tuesday, 14 April 2015 21:51:31 UTC+1, Andreea Gheorghiu wrote:


 Hello!

 I want to run a Linux script which uses ssh to connect to another server .
 The script is correctly implemented ( i tested on Putty) ,  but when i 
 execute it with Web2py nothing is happening.



 My module is:
 from gluon import *
 import subprocess
 import os
 import shlex
 def ssh_script():
 return subprocess.call(['/home/web2py/../demo/modules/ssh.sh'], shell 
 = True)

 the linux script:
 #!/usr/bin/expect

 spawn ssh test@serverip 'ls' '-l'ssh.log
 expect password
 send mypassword
 interact

 do you have any idea what i'm missing?






-- 
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] Bug in SQLFORM.factory bootstrap3 formstyles ?

2015-04-12 Thread Gary Cowell
Hi

Running with:


2.10.3-stable+timestamp.2015.04.02.21.42.07

(Running on Rocket 1.2.6, Python 2.7.5) 


I find that this code:

xadb = DAL('sqlite:memory:')
xadb.define_table('regiontable', Field('region', length=20,label=
'Region'))

form = SQLFORM.factory(SQLField('Region', label='Select a region', 
length=20,
   requires=IS_IN_DB(xadb,'regiontable.region',orderby=xadb.regiontable.
region)),
   formstyle='bootstrap3_inline'
)

Produces a drop-down that is the entire width of the page when viewed in 
Firefox.  Same for bootstrap3_stacked

The 'classic' formstyles, of table2cols, table3cols etc. don't look as 
nice, don't have the bootstrap button, but they produce fields of the 
correct width.

Is this a bug in the bootstrap3 , or did I need to do more to my 
SQLFORM.factory to get the correct width?

Thanks

-- 
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] w2p_clone broke web2py installation

2015-04-05 Thread Gary Cowell

Hello

I installed web2py from pip, I think it's at 2.1.1

Then ran w2p_clone to bring in latest version. On launch I get the 
following error:


Traceb

Traceback (most recent call last):
  File web2py.py, line 18, in module
import gluon.widget
  File /home/gary/python/web2py/web2py/gluon/__init__.py, line 37, in module
from sqlhtml import SQLFORM, SQLTABLE
  File /home/gary/python/web2py/web2py/gluon/sqlhtml.py, line 34, in module
from gluon.dal import _default_validators
ImportError: cannot import name _default_validators



What did I do wrong? I'm working in a virtualenv, wanted to deploy the 
latest version, the pip one is quite the age now it seems.

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


[web2py] How to approach presenting API data in web2py ?

2015-03-28 Thread Gary Cowell
Hello

Looking at writing a front end to an AWS orchestration tool in web2py, I 
already have the functionality required coded in python defs, so just 
looking at presenting things nicely.

One thing I'll have to do a lot of, is present grids and dropdowns of data 
that have come from lists and dictionaries returned by boto module, for 
example in my controller, I tested this:

@auth.requires_login()
def stacklist():
xadb = DAL('sqlite:memory:')
xadb.define_table('stacks', Field('stack_name', label='Stack Name'),
Field('stack_status', label='Status'))
xadb.stacks.truncate()
awskey=auth.user['AWSKey']
awssec=auth.user['AWSSecret']
e2conn = boto.ec2.connect_to_region('eu-west-1',
 aws_access_key_id=awskey,
 aws_secret_access_key=awssec)
cfconn = boto.cloudformation.connect_to_region('eu-west-1',
 aws_access_key_id=awskey,
 aws_secret_access_key=awssec)
regions = boto.ec2.regions(aws_access_key_id=awskey, 
aws_secret_access_key=awssec)  #
# get and populate cloudformer stacks
#
stackList = cfconn.list_stacks()

for stackSummary in stackList:
xadb.stacks.insert(stack_name=stackSummary.stack_name, stack_status=
stackSummary.stack_status)

form = SQLFORM.grid(xadb.stacks,orderby=[xadb.stacks.stack_status,])
return dict(form=form)

This works, but if I wanted to create a dropdown for regions instead of 
hard coding eu-west-1, I'd be doing this sort of thing again with a 
different temporary db. And then there's lists for RDS snapshots, ec2 
images, ec2 snapshots etc. Lots of lists of AWS resources to be presented.

Am I going about this the best way ? What other options exist for me to 
present lists and dropdowns of data returned from third party API calls?

Thanks

-- 
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: IMPORTANT - DROPPING SUPPORT FOR PYTHON 2.5?

2015-03-11 Thread Gary Cowell


On Saturday, 7 March 2015 19:18:17 UTC, Massimo Di Pierro wrote:

 Who is opposed? Why?


It would mean support going for Red Hat 5 I think

Red Hat 6 is on 2.6, Red Hat 7 is 2.7. 

Everything I have is at least Red Hat 6.

But that would be the reason, most probably 

-- 
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 in TEXT field presentation between View and Edit modes

2015-02-13 Thread Gary Cowell

 I have a SQLFORM.grid containing :

grid = SQLFORM.grid(
query=queryInstalled,
fields=[db.e5systemstatus.id,
db.e5systemstatus.patch,
db.e5systemstatus.patchstatus,
db.e5systemstatus.patchattempted,
db.e5systemstatus.patchsummary,
],
headers = {
'e5systemstatus.id' : 'ID',
'e5systemstatus.patch' : 'Patch',
'e5systemstatus.patchstatus' : 'Installed?',
'e5systemstatus.patchattempted' : 'Attempted?',
'e5systemstatus.patchsummary' : 'Summary',
},
create=False,
deletable=allowEdit,
editable=allowEdit,
formstyle='table3cols',
paginate=10
)

The model says:

db.define_table(
'e5systemstatus',
Field('system_id',db.e5system),
Field('patch',length=12, label='Patch'),
Field('prereq',length=512, label='Prereq'),
Field('patchstatus','boolean',default=False,label='Status'),
Field('patchlog','text',label='Log'),



The problem comes on the 'text' column.

When the grid goes to 'View' mode, the 'text' column looks like it has the 
line endings stripped. It comes out like this:

Java version = 1.7.0_71 Java vendor = Oracle Corporation Java OS name = 
Linux Java OS arch = amd64 Java OS version = 3.10.66-1.el6.elrepo.x86_64 
Java version = 1.7.0_71 Java vendor = Oracle Corporation Java OS name = 
Linux Java OS arch = amd64 Java OS version = 3.10.66-1.el6.elrepo.x86_64 
Fri Feb 6 11:42:13 GMT 2015 Result was 0 Database Available... Continuing 
Verifying archive 

Which isn't very readable. In 'edit' mode, it comes out as:

Java version = 1.7.0_71
Java vendor = Oracle Corporation
Java OS name = Linux
Java OS arch = amd64
Java OS version = 3.10.66-1.el6.elrepo.x86_64
Java version = 1.7.0_71
Java vendor = Oracle Corporation
Java OS name = Linux
Java OS arch = amd64
Java OS version = 3.10.66-1.el6.elrepo.x86_64
Fri Feb  6 11:42:13 GMT 2015
Result was 0
Database Available... Continuing

So the question is, how can I make this 'text' column display correctly in 
'View' mode ?

The column contains the captured stdout from an operating system command, 
so it's text with line breaks.

Thanks

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


[web2py] Re: can we have web2py groups with AD authentication ?

2015-02-13 Thread Gary Cowell
Thanks. I've just been given access to an LDAP server, so I'll be able to 
try things. If I get something working, I'll post it.

On Friday, 13 February 2015 10:41:13 UTC, mcamel wrote:

 Maybe you can delegate auth to Ldap and use 
 auth.settings.login_onaccept.append(lambda form: my_postlogin_tasks(form.
 vars.username..))

 to set a session variable that enables or disables admin access depending 
 on who the user is.

 Then you could use auth decorators like 
 @auth.requires(session.auth._adminaccess == True) 

 at admin actions.

 I've never used such a mixed system. This is just what it came to my 
 mind...

 Regards.


 El miércoles, 11 de febrero de 2015, 0:12:07 (UTC+1), Gary Cowell escribió:

 I would like my app to authenticate with AD (ldap) for users and 
 passwords.

 But, I'm not in control of the LDAP, and I can't get them to add new 
 groups etc. and the app requires users to be in a web2py admin group to do 
 certain admin functions within the app.

 So at the moment, I'm using standard auth, where users can self register, 
 then I add them to the admin group myself if necessary

 I found a web2py slices for authenticating against AD, but how can I also 
 use web2py groups, /instead of/ AD/ldap groups? So authenticate the user 
 and password against AD, but use my app groups for additional permissions

 Is it the case of the auth.settings.create_user_groups and 
 auth.settings.login_methods [ manage_groups ] options?

 I won't be able to test it sadly until I have access to an ldap server. 
 Might be time to run my own for now, I suppose! 

 Question for now is, is this possible at all? If so, I will set up and 
 configure an ldap server to test it with.

 Thanks


 from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
 auth = Auth(db, hmac_key = Auth.get_or_create_key())
  
 then
  
 auth.define_tables(username=True)
 #auth.settings.create_user_groups=False
  
 after
  
 # all we need is login

 auth.settings.actions_disabled=['register','change_password','request_reset_password','retrieve_username','profile']
  
 # you don't have to remember me
 auth.settings.remember_me_form = False
  
 and
  
 from gluon.contrib.login_methods.ldap_auth import ldap_auth
 auth.settings.login_methods = [ldap_auth(mode='ad',
 manage_groups= True, 
 db = db,
 group_name_attrib = 'cn',
 group_member_attrib = 'member',
 group_filterstr = 'objectClass=Group',
 server='server',
 base_dn='OU=my org unit,DC=domain,DC=domain')]



-- 
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: Difference in TEXT field presentation between View and Edit modes

2015-02-13 Thread Gary Cowell
Many thanks, that worked great. Looks good too in the way it formats it.

On Friday, 13 February 2015 19:54:15 UTC, Niphlod wrote:

 HTML doesn't preserve line breaks by default: that's why there are pre 
 or code tags

 you need a custom represent function to fill the cell of the grid with 
 *prethetext/pre* instead of simply 

 *thetext .*Use something like

 db.e5systemstatus.patchlog.represent = lambda value, row : PRE(value)


 and it should be enough 




-- 
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: submenus in layout

2015-02-11 Thread Gary Cowell
oh and the reason mine didn't work is, the layout plugins on web2py don't 
use bootstrap it seems. I changed to using a bootstrap3 scaffold, and a 
themed bootstrap.min.css, and it worked fine.

On Tuesday, 10 February 2015 08:33:01 UTC, Yebach wrote:


 I would like to create a drop down menu in my layout. The data for menu is 
 read from menu.py

 this is my list for menu

 response.menu_logged = [
 (T('Schedules'),URL('default','index')==URL(),URL('default','index')),
 (T('New schedule'),URL('script','edit')==URL(),URL('script','edit', 
 args='new')),
 (T('Settings'), False, None, [ 
   
 (T('Workers'),URL('settings','workers')==URL(),URL('settings','workers')),
 
 (T('Shifts'),URL('settings','turnusi')==URL(),URL('settings','turnusi')),
 (T('Config'),URL('settings','config')== 
 URL(),URL('settings','config')) ,]
 )]


 Now I would like to put workers, shifts and config in one submenu 
 (dropdown) called settings (Schedules,new schedule, and config to be 
 horizontal and then config menus vertical )

 and in my layout.html

  {{if auth.is_logged_in():}}
  {{ for i, page in enumerate(response.menu_logged): }}
 li{{ if response.menu_logged[i][1]: 
 response.write(XML(' class=active')) }}a href={{ 
 =response.menu_logged[i][2] }}{{ =response.menu_logged[i][0] }}/a/li

 {{ pass }}
   lia href=
 https://sites.google.com/site/navodilawoshi/; 
 target=_blank{{=T('Help')}}/a/li
 any suggestions?

 Is there is a possibility to do it with web2py and not html/css/js?

 thank you


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


[web2py] Re: submenus in layout

2015-02-10 Thread Gary Cowell
I don't know if I understand your problem, but I do this:
adminmenu = [
(T('Admin'), False, '', [
(T('Disk'), False, URL('dynamic', 'diskadmin'), []),
(T('Slot'), False, URL('dynamic', 'systemadmin'), []),
]),
]

Which creates a cascaded menu option, then I 

if auth.has_membership(group_id='admin'):
response.menu.append((T('DynAdmin'), False, '', adminmenu))

Which includes the menu, depending if the user is in the admin group.

My problem is though, that none of these render in any of the plugin 
layouts available on web2py.com, you only get the top level menu.

I don't know enough html/css to fix this, I'm just trying to build a web 
form based python app. 

It does work with the default 'layout.html' from admin.  


On Tuesday, 10 February 2015 08:33:01 UTC, Yebach wrote:


 I would like to create a drop down menu in my layout. The data for menu is 
 read from menu.py

 this is my list for menu

 response.menu_logged = [
 (T('Schedules'),URL('default','index')==URL(),URL('default','index')),
 (T('New schedule'),URL('script','edit')==URL(),URL('script','edit', 
 args='new')),
 (T('Settings'), False, None, [ 
   
 (T('Workers'),URL('settings','workers')==URL(),URL('settings','workers')),
 
 (T('Shifts'),URL('settings','turnusi')==URL(),URL('settings','turnusi')),
 (T('Config'),URL('settings','config')== 
 URL(),URL('settings','config')) ,]
 )]


 Now I would like to put workers, shifts and config in one submenu 
 (dropdown) called settings (Schedules,new schedule, and config to be 
 horizontal and then config menus vertical )

 and in my layout.html

  {{if auth.is_logged_in():}}
  {{ for i, page in enumerate(response.menu_logged): }}
 li{{ if response.menu_logged[i][1]: 
 response.write(XML(' class=active')) }}a href={{ 
 =response.menu_logged[i][2] }}{{ =response.menu_logged[i][0] }}/a/li

 {{ pass }}
   lia href=
 https://sites.google.com/site/navodilawoshi/; 
 target=_blank{{=T('Help')}}/a/li
 any suggestions?

 Is there is a possibility to do it with web2py and not html/css/js?

 thank you


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


[web2py] web2py on Microsoft Azure PAAS

2015-02-10 Thread Gary Cowell
Anyone any experience on deploying a web2py app on Microsoft Azure Web?

Can it be done?

-- 
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: why use the admin interface, at all?

2015-01-29 Thread Gary Cowell
I use the built in editor heavily.

Lots of my web2py coding is done on a chromebook, so it's completely 
perfect for me. 

Be really hard if it worked any other way than this.


On Friday, 12 February 2010 17:35:49 UTC, snfctech wrote:

 I'm just getting started with web2py and I must say - I love the
 code.  Adding validation logic with the DAL and building forms on the
 fly with the CRUD helper is awesome.

 That said, I don't understand the point of the admin interface -
 especially the online database designer and the editor.  The online
 database designer doesn't generate 'upload' types (and I imagine other
 DAL specific syntax, as well).  And the editor is too weak for any
 serious coding.

 So why does this extra fluff exist at all, as it will require
 resources to maintain and enhance?  Not to mention it adds more
 unnecessary options for new users wondering about best practices for
 web2py development.  This doesn't seem in keeping with there should
 be one obvious way to do it.

 The only thing I can think of why things like the editor and designer
 exist at all is to promote the full stack idea.  But is it really
 worth the effort to include sub-standard tools in the stack which you
 will have to abandon anyway once you start serious development work?

 Thanks in advance for helping me to understand the reasoning here.



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


[web2py] dynamic buttons in sqlform.grid

2015-01-29 Thread Gary Cowell
Hello

I have a SQLFORM.grid, where I wanted some buttons to do different things, 
and to look different based on the status of the entities being reported in 
the grid.

Here's what I did for one of them:
 links = [
dict(header=T('Running'),body=lambda row: testslot(row.
currentslot)),
dict(header=T('Control'),body=
lambda row:
A(
SPAN(_class=syss.iconClass[row.currentslot])
   ,syss.text[row.currentslot]
   ,_class=syss.buttonClass[row.currentslot]
   ,_title=syss.text[row.currentslot]
   ,_href=URL(dynamic,startstop,
  args=[row.id,syss.url[row.currentslot], syss.text[row.
currentslot], db.e5system, row.currentslot])
)
),

So the button can look red or orange, or green, because I populate some 
lists and use the values , 
syss.text is the text for the button
syss.buttonClass is the class to be used and so on. I call this at the 
start:

syss=listeningSystems()
syss.refresh()

My syss object then has these instance lists I can use to get the statuses 
of my rows. It ends up looking like:



So that's great, I get a start button for stopped systems, and a stop 
button for started ones.

Problem seems to me though, it's not very scalable or readable.

Is there a better way for me to do this? To make a decision, on my next 
button, it needs the 'id' from the table, and make some decisions.

Ideally, I'd like something similar to this:

dict(header=T('State'),body=
lambda row:
A(
SPAN(_class=icon stop icon-stop glyphicon glyphicon-stop)
  fixstatus(row.id)
)
)


where the systemStatus() def would fill in the middle bit, but I can't get 
that to work:

def fixstatus(sys):
return ',Unfinished,_class=button btn btn-warning,_title=Unf 
Title,_href=URL(dynamic,systemStatus,args={0})'.format(sys)

Could I return the whole thing from A( to close ) from a function?

I tried that, but I just got a table cell with the actual text 
A(SPAN(_class etc ... ) in it.

Am I expecting too much from the grid?

I like how it looks with the button I have coded right now, but it does 
seem unwieldy, there must be a better way!

Thanks group

p.s. Just a thanks to web2py developers, this is a top product, really 
enjoying working with it.


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


[web2py] How can I have optional, or vairable buttons in a sqlform.smartgrid 'links' ?

2015-01-14 Thread Gary Cowell
I have a smartgrid, thus:

grid = SQLFORM.smartgrid(db.exsystem,linked_tables=['exsystem', 
'disks'],
 user_signature=False,
 deletable=False,
links = [
lambda row:
 A(
SPAN(_class='icon play icon-play glyphicon glyphicon-play')
   ,'Start'
,_class='button btn btn-success',_title='Start'
,_href=URL(args=[exsystem/start, db.exsystem, row.id])
),
lambda row:
 A(
SPAN(_class='icon stop icon-stop glyphicon glyphicon-stop')
   ,'Stop'
,_class='button btn btn-warning',_title='Stop'
,_href=URL(args=[exsystem/stop, db.exsystem, row.id])
),
lambda row:
 A(
SPAN(_class='icon trash icon-trash glyphicon glyphicon-bin')
   ,'Delete'
,_class='button btn btn-danger',_title='Delete'
,_href=URL(args=[exsystem/delete, db.exsystem, row.id])
)
]
)


So this displays coloured buttons for stop, start, and delete.

Ideally, I'd like the stop button to be suppressed if the entity in 
question is already stopped (based on db.exsystem.system_status)

Or, the button function and URL and type could be changed, depending on 
system status

I don't like having button for 'stop' on a thing which is already 'stopped'

These are controls for a virtual machine manager page.

How can I do this please? 

-- 
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: Struggling with multi user

2015-01-05 Thread Gary Cowell
Once again, thank you. I'll get there in the end.

On Sunday, 4 January 2015 02:37:09 UTC, Massimo Di Pierro wrote:

 I would do:

 db.define_table(
 'shoe',
 Field('model',db.model),
 Field('purchased','date'),
 Field('price','integer'),
 auth.signature, # include created_by and created_on
 format=lambda r: '%s %s %s' % (r.model.manufacturer.name
 ,r.model.model,r.purchased)) 

 along with a common filter as you suggested:

 db.shoe._common_filter = lambda query: db.shoe.created_by == auth.user_id 

 Massimo



 On Saturday, 3 January 2015 13:00:24 UTC-6, Gary Cowell wrote:

 Hello

 Sorry for the probably obvious questions, but I do search for answers 
 honest :)

 Anyway, what I want is for my table rows to be user specific. Such that 
 when each user registers, the database looks empty to them, until they 
 start creating rows in their forms. 

 I have added these definitions to each table:

 db.define_table(
 'shoe',
 Field('model',db.model),
 Field('purchased','date'),
 Field('price','integer'),
 Field('created_on', 'datetime',
   default=request.now, update=request.now, writable=False),
 *Field('created_by', 'reference auth_user',*
 *  default=auth.user_id, update=auth.user_id, writable=False),*
 format=lambda r: '%s %s %s' % (r.model.manufacturer.name
 ,r.model.model,r.purchased)) 

 So I've added created_by referencing auth_user, and this places the 
 logged in user into the row

 I could add code to the controller, the simple controller looks like

 @auth.requires_login()
 def shoe():
form = SQLFORM(db.shoe)
if form.process().accepted:
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill out the form'
return dict(form=form)

 Perhaps with a SQLFORM.factory somehow?

 Or is CRUD the way to go? I have no idea about CRUD yet (nor much of an 
 idea about most of this right now, but I'm learning)

 Or perhaps using common_filter? Somehow like this:

 table._common_filter = lambda query: db.shoe.created_by == auth.user.id 

 I don't mind really which way this gets done, but if there's a canonical 
 way, or a best practice way, I'd like to learn that, instead of the 'wrong 
 but works' way.

 Thanks!

 Gary



-- 
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] Struggling with multi user

2015-01-03 Thread Gary Cowell
Hello

Sorry for the probably obvious questions, but I do search for answers 
honest :)

Anyway, what I want is for my table rows to be user specific. Such that 
when each user registers, the database looks empty to them, until they 
start creating rows in their forms. 

I have added these definitions to each table:

db.define_table(
'shoe',
Field('model',db.model),
Field('purchased','date'),
Field('price','integer'),
Field('created_on', 'datetime',
  default=request.now, update=request.now, writable=False),
*Field('created_by', 'reference auth_user',*
*  default=auth.user_id, update=auth.user_id, writable=False),*
format=lambda r: '%s %s %s' % 
(r.model.manufacturer.name,r.model.model,r.purchased)) 

So I've added created_by referencing auth_user, and this places the logged 
in user into the row

I could add code to the controller, the simple controller looks like

@auth.requires_login()
def shoe():
   form = SQLFORM(db.shoe)
   if form.process().accepted:
   response.flash = 'form accepted'
   elif form.errors:
   response.flash = 'form has errors'
   else:
   response.flash = 'please fill out the form'
   return dict(form=form)

Perhaps with a SQLFORM.factory somehow?

Or is CRUD the way to go? I have no idea about CRUD yet (nor much of an 
idea about most of this right now, but I'm learning)

Or perhaps using common_filter? Somehow like this:

table._common_filter = lambda query: db.shoe.created_by == auth.user.id 

I don't mind really which way this gets done, but if there's a canonical way, 
or a best practice way, I'd like to learn that, instead of the 'wrong but 
works' way.

Thanks!

Gary

-- 
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: Format clause for multiple table relationships

2015-01-02 Thread Gary Cowell


On Friday, 2 January 2015 20:12:31 UTC, Massimo Di Pierro wrote:

 I think you are asking about this:

 db.define_table(
 'manufacturer',
 Field('name'),
 format = '%(name)s')

 db.define_table(
 'model',
 Field('manufacturer', db.manufacturer),
 Field('model'),
 format=lambda r: '%s %s' % (r.manufacturer.name, r.model)) # one 
 hidden query

 db.define_table(
 'shoe',
 Field('model',db.model),
 Field('purchased','date'),
 Field('price','integer'),
 format=lambda r: '%s %s' % (r.model.manufacturer.name,r.purchased)) # 
 2 hidden queries



Ah yes, certainly am. That's a different syntax to the one I found by 
searching, looks much more understandable that way, thank you.

Trying to make myself a running gear usage tracker app, so I can, well ... 
track my gear usage :)

Thanks very much


-- 
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] Dropdown based on multiple parents?

2015-01-01 Thread Gary Cowell
Hi, this is probably simple but searching as come up a blank and I'm still 
very new to web2py

I have three tables,  'manufacturer' , 'model', and 'shoe'

Manufacturer contains 'Asics','Nike'

Then 'model' has parent of 'manufacturer', and will have 'Asics', 'Gel 
Nimbus' and 'Nike','Vomero'

'shoe' is child of 'model', and contains other details about a paticular 
instance of a manufacturer/model

What I want is for the drop down when 'shoe' is created (in admin, and in 
forms), to show 'Asics Gel Nimbus', or 'Nike Vomero'

At the moment it just says 'Vomero', or 'Gel Nimbus', i.e. the immediate 
parent.

Here are my models, I've tried using the other parent in the 'format', but 
I can't get it to work, or even if that's the correct thing to attempt.

Thanks for any help

Models:

db.define_table(
'manufacturer',
Field('name'),
format = '%(name)s')

db.define_table(
'model',
Field('manufacturer', db.manufacturer),
Field('model'),
format = '%(model)s')

db.define_table(
'shoe',
Field('model',db.model),
Field('purchased','date'),
Field('price','integer'),
format = '%(manufacturer.name)s %(model)s') 

So that's my attempt at putting the parent chain in to 'format'

-- 
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] Format clause for multiple table relationships

2015-01-01 Thread Gary Cowell
I want the 'format' for the dropdown when I create a 'run' entry to be 
'manufacturer.name model.model shoe.purchased'

e.g. 'Mizuno Wave Rider 10-11-2014'  for instance where 'Mizuno' is the 
manufacturer name, 'Wave Rider' is the model.model, and the date is 
shoe.purchased

I managed to get the 'shoe' table definition to represent the model and 
date with a lambda, but I don't know how to include the manufacturer name 
from the 'model' table parent.

So the question is, how do I change the lambda on the 'shoe' table to pull 
entries from its parent, and grandparent? I only managed the parent table 
so far.

Thank you

Here are my models:

db.define_table(
'manufacturer',
Field('name'),
format = '%(name)s')

db.define_table(
'model',
Field('manufacturer', db.manufacturer),
Field('model'),
format=lambda r: '%s %s' % (db.manufacturer[r.manufacturer].name, 
r.model))

db.define_table(
'shoe',
Field('model',db.model),
Field('purchased','date'),
Field('price','integer'),
format=lambda r: '%s %s' % (db.model[r.model].model,r.purchased))


db.define_table(
'run',
Field('run_date','date'),
Field('run_time','time'),
Field('run_event'),
Field('run_distance','integer'),
Field('run_calories','integer'),
Field('shoe',db.shoe),
Field('race','boolean'),
format = '%(rundate)')

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


[web2py] Re: How to do references, and dropdowns?

2014-09-01 Thread Gary Cowell


On Friday, 29 August 2014 14:22:56 UTC+1, Gary Cowell wrote:

 Hello

 I have the following in models:

 db.define_table('senders',
 Field('sender','string',length=80,label=Sender))

 db.define_table('documents',
 
 Field('description','text',requires=IS_LENGTH(256,1),label=Description),
 Field('header_date','date',label=Header Date),
 Field('received_date','date',label=Received Date),
 Field(sent_by,db.senders,label=Sent By,requires=IS_IN_DB(db, 
 'senders.sender')))



 So I want some 'senders', with a description 'sender' and some 
 'documents'. Each 'documents' has one 'senders', a 'senders' has many 
 'documents'.

 I added the requres=IS_IN_DB to enable a SQLFORM to provide a drop down 
 list of SENDERS when I create a new document. This works but ...

 We get this:

 class 'sqlite3.IntegrityError' FOREIGN KEY constraint failed

 When we create the DOCUMENT, even though it specifies a SENDER from the 
 dropdown

 Is this because the drop down is senders.sender but the RI constraint is 
 on senders.id ?

 I'm not a fan of surrogate keys, I must say. Traditionally I would have 
 defined SENDERS as SENDER_CODE, SENDER_NAME and given a meaningful code, 
 such as 

 NWAT, Northumbrian Water

 instead of

 1,Northumbrian Water

 which is what I have now.

 Anyway, what have I messed up in my model/form, please? I can't see how to 
 change it to fix this

 Form is built with this controller code:

 @auth.requires_login()
 def newdocument():

 form = SQLFORM(db.documents).process()

 if form.accepted:
 response.flash = 'new record inserted'

 dochead = {'documents.description':'Description', 
 'documents.header_date':'Header Date', 'documents.received_date':'Received 
 Date', 'documents.sent_by':'Sender',}
 
 # and get a list of all documents
 records = SQLTABLE(db().select(db.documents.ALL), truncate=80, headers 
 = dochead )

 return dict(form=form, records=records)

 View:

 {{extend 'layout.html'}}
 h1Documents/h1
 {{=form}}
 h2Current Documents/h2
 {{=records}}

 Thanks for any assistance




For reference: I fixed this by reading tfm. Model is now:

db.define_table('senders',
Field('sender','string',length=80,label=Sender),
format = '%(sender)s')

db.define_table('documents',

Field('description','text',requires=IS_LENGTH(256,1),label=Description),
Field('header_date','date',label=Header Date),
Field('received_date','date',label=Received Date),
Field(sent_by,db.senders),
format = '%(description)s') 

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


[web2py] How to do references, and dropdowns?

2014-08-29 Thread Gary Cowell
Hello

I have the following in models:

db.define_table('senders',
Field('sender','string',length=80,label=Sender))

db.define_table('documents',

Field('description','text',requires=IS_LENGTH(256,1),label=Description),
Field('header_date','date',label=Header Date),
Field('received_date','date',label=Received Date),
Field(sent_by,db.senders,label=Sent By,requires=IS_IN_DB(db, 
'senders.sender')))



So I want some 'senders', with a description 'sender' and some 'documents'. 
Each 'documents' has one 'senders', a 'senders' has many 'documents'.

I added the requres=IS_IN_DB to enable a SQLFORM to provide a drop down 
list of SENDERS when I create a new document. This works but ...

We get this:

class 'sqlite3.IntegrityError' FOREIGN KEY constraint failed

When we create the DOCUMENT, even though it specifies a SENDER from the 
dropdown

Is this because the drop down is senders.sender but the RI constraint is on 
senders.id ?

I'm not a fan of surrogate keys, I must say. Traditionally I would have 
defined SENDERS as SENDER_CODE, SENDER_NAME and given a meaningful code, 
such as 

NWAT, Northumbrian Water

instead of

1,Northumbrian Water

which is what I have now.

Anyway, what have I messed up in my model/form, please? I can't see how to 
change it to fix this

Form is built with this controller code:

@auth.requires_login()
def newdocument():

form = SQLFORM(db.documents).process()

if form.accepted:
response.flash = 'new record inserted'

dochead = {'documents.description':'Description', 
'documents.header_date':'Header Date', 'documents.received_date':'Received 
Date', 'documents.sent_by':'Sender',}

# and get a list of all documents
records = SQLTABLE(db().select(db.documents.ALL), truncate=80, headers 
= dochead )

return dict(form=form, records=records)

View:

{{extend 'layout.html'}}
h1Documents/h1
{{=form}}
h2Current Documents/h2
{{=records}}

Thanks for any assistance

-- 
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: Total newbie, advice on storing scans

2014-08-29 Thread Gary Cowell


On Thursday, 21 August 2014 16:34:46 UTC+1, Michael Beller wrote:

 Web2py has an 'upload' field type that helps you manage file uploads. 
  Upload is a little bit of a misnomer because you can select the file 
 path to store the file (or an existing path) and the blob is not stored in 
 the database.

 You can read more here:

 http://web2py.com/books/default/chapter/29/07/forms-and-validators?search=upload#SQLFORM-and-uploads

 There are several good Bootstrap and Jquery plugins that you can use to 
 view a lightbox type of layout of your scanned images with the ability to 
 zoom on an image rather than download and then open the file which I think 
 would be best for your archival type of solution.  Here's just one example:
 http://www.bootply.com/71401

 There are many discussions on the web2py upload feature in this forum and 
 some 'slices' that you may find helpful such as:
 http://www.web2pyslices.com/slice/show/1504/manual-uploads

 Hope that helps.

 Mike




It did help, thanks. The thing is, I don't want to 'upload' my scans, there 
is an acquire button on my page that triggers the scanner to scan the 
current document on the flatbed. Currently this is only held in memory in 
my scanner class, I just wanted it stored so that web2py can present it in 
a lightbox kind of way (good example there).

I'll keep looking through those examples, thank you 

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


[web2py] Total newbie, advice on storing scans

2014-08-21 Thread Gary Cowell
Hi

I'm writing a web app for my home server to allow me to scan and store 
images of official correspondence, so I can shred the paper and recycle it. 
 A document archive.

I have the scanner components written [using pyinsane]

I have an idea of the models required, tables to hold the sender, date, 
page number, header ref, header date, received date etc.

What I want to know is how best to handle the scanning and image storing.

I don't really [I don't think] want to store the images in the database, be 
that sqlite or pgsql [or do I?]

At the moment my python scanner scans the image, and stores it in a 
directory which is a NFS mount on my NAS. 

My web2py application would have to read this image and present it for 
confirmation, checking before storing the index entry, and the path to the 
image into the database.

So, firstly, how best to present the scanned image to the user for 
acceptance, can I do this from an arbitrary location [guessing not], I do 
have a PIL image in memory, so can I present that in web2py, if I can't 
link an IMG= to the arbitrary disk location

Sorry if my questions sound vague, I'm just getting to grips with web2py [ 
used it a whole 3 days! ]

Thanks for any pointers. Including NO! YOU FOOL! DON'T DO IT!

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