[web2py] list:integer and list:string not respecting show_if parameter, patch included

2016-08-02 Thread Tim Alexander
The subject line pretty much says it all, the list:integer and list:string
data types don't appear to respect the show_if parameter (from this

section
in the book). I needed them to, and had a workaround in js for a while, but
wanted to use all of the built-in web2py goodness for everything,
regardless of list data types (I'm using the list types in
sqlform.smartgrid already)

In brief, it comes down to the fact that the ID is different for list types
on the ul element containing each of the list items. Given a major priority
of web2py is backwards compatibility (one I highly appreciate),I wrote it
in a way that won't break existing CSS/JS/etc. for things referencing that
UL containing the list items. This is not exactly "clean" in my opinion,
but it's been running in my test environment for a few months with no
issues.

Even though though it takes 2 additional CSS selector lookups from jquery
to perform on each change of the monitored element, this handling should be
able to be reused for any additional data types that don't properly handle
the show_if situation, and the parent_tr reference can be used as a backup
for any future functionality that also has issues with cross-referencing
from the UL element to it's parent TR element. Note, I'm quite abysmal at
JS IMHO, though I can hack my way through it enough to be dangerous. So
there may be a better way to do this work than storing the parent element
name on the child as an attribute, then adding a fallthrough handler to
examine and select based upon said attribute. Given there doesn't exist a
parent reference in CSS (for good reason, performance wise), this is the
most efficient method I came up with in the 30 seconds I spent considering
before I wrote it.

I can work on forking and throwing a pull request up on github
if you prefer, and if someone can confirm
it's the "official home" of web2py code now. Might take me a short bit to
find the time to spin up a dev environment that's "clean" enough to do so,
but that's been on my todo list for a while. Otherwise the patch is
attached here for review.

You may also consider this my agreement to the Web2py Contributor Agreement
 (again
I think, though I don't entirely remember if the changes I made were to
web2py or some of the contrib libraries), unless you'd rather require I
upload a signed copy somewhere.

-- 
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.
diff -ur web2py_orig/applications/admin/static/js/web2py.js web2py/applications/admin/static/js/web2py.js
--- web2py_orig/applications/admin/static/js/web2py.js  2016-08-02 18:48:50.0 -0500
+++ web2py/applications/admin/static/js/web2py.js   2016-08-02 18:49:13.0 -0500
@@ -539,6 +539,7 @@
 for(var k = 0; k < triggers[id].length; k++) {
   var dep = $('#' + triggers[id][k], target);
   var tr = $('#' + triggers[id][k] + '__row', target);
+  if(!tr.length) tr = $('#' + $('#' + triggers[id][k], target).attr('parent_tr'), target);
   if(t.is(dep.attr('data-show-if'))) tr.slideDown();
   else tr.hide();
 }
diff -ur web2py_orig/gluon/sqlhtml.py web2py/gluon/sqlhtml.py
--- web2py_orig/gluon/sqlhtml.py2016-08-02 18:53:11.0 -0500
+++ web2py/gluon/sqlhtml.py 2016-08-02 18:33:04.0 -0500
@@ -296,6 +296,9 @@
   value=v, hideerror=k < len(nvalue) - 1,
   requires=requires),
 **attributes) for (k, v) in enumerate(nvalue)]
+default = dict(value=value)
+attributes = cls._attributes(field, default, **attributes)
+attributes['_parent_tr'] = attributes['_id'] + '__row'
 attributes['_id'] = _id + '_grow_input'
 attributes['_style'] = 'list-style:none'
 attributes['_class'] = 'w2p_list'

Re: [web2py] web2py recipe book

2012-03-16 Thread Tim Alexander
Bought one for me, and one for a friend (kindle edition). Now to find the
time to read it...


Re: [web2py] How do you manage your app repo with Mercurial

2012-01-10 Thread Tim Alexander
I'm not sure there's a standard way of doing it if you're not using
sqlite, but I personally have the database pointing to a name in my
hosts file. So I'll configure configdbhost to be my configuration
database (in the hosts file on the box) and then have the lines (split
so that if the application is deployed on apptest application, it
points to a test database):
if request.application == 'apptest':
# Test db
db = DAL('postgres://configdbhost/apptest')
else:
# Prod DB
db = DAL('postgres://configdbhost/mydb')

On Tue, Jan 10, 2012 at 9:25 AM, Jonathan Lundell jlund...@pobox.com wrote:
 On Jan 10, 2012, at 6:04 AM, Jim Steil wrote:

 I'm looking for input on how people manage their database connection when 
 setting up your app in a Mercurial repository.

 If I just add my app and db.py to my repository, then every time I setup a 
 different development machine to access it, the app will, by default, point 
 to the same database.  But, this database connection isn't correct when I'm 
 working on my laptop or from a home workstation and therefore, I need a 
 different way to specify my db connection info.

 The solution I've come up with is to have a config file (using configobj) 
 hold my db information, and read it in db.py to get the info.  But, then 
 this causes even more overhead on each request.

 Also, what do you do about your databases sub-directory?  I would think that 
 I don't want to track any changes there, but when my repo gets cloned an 
 empty databases directory should be placed there.

 web2py should create the databases subdirectory for you if it's not there (at 
 the beginning of the first request).


Re: [web2py] Re: web2py wins an InfoWorld 2012 Technology of the Year Award

2012-01-09 Thread Tim Alexander
FYI - probably been thrown out there already, but it also won a 2011 BOSSIE
award: http://bit.ly/yjdq1l


On Mon, Jan 9, 2012 at 11:36 AM, Ovidio Marinho ovidio...@gmail.com wrote:

 +1



Ovidio Marinho Falcao Neto
 Web Developer
  ovidio...@gmail.com
   ovidiomari...@itjp.net.br
  ITJP - itjp.net.br
83   8826 9088 - Oi
83   9334 0266 - Claro
 Brasil

 Apóio



 2012/1/9 Omi Chiba ochib...@gmail.com

 Yeah !!

 On Jan 9, 9:48 am, Anthony abasta...@gmail.com wrote:
 
 http://www.infoworld.com/slideshow/24605/infoworlds-2012-technology-t...http://www.infoworld.com/t/application-development/picking-the-top-te.
 ..
 
  Other winners include Amazon Web Services, Heroku, Node.js, Apple iOS 5,
  iPad 2, and other well-known brands/technologies -- pretty good company.
 
  Anthony





Re: [web2py] Re: web2py Application Development Cookbook

2012-01-06 Thread Tim Alexander
Out of curiosity, what's the link to purchase from the app dev book
from safari books? I wasn't able to find it, and wanted to pre-order
one from there so I can get drafts as they come in...

On Mon, Dec 5, 2011 at 3:23 PM, Constantine Vasil thst...@gmail.com wrote:
 Currently I am reading a draft book in Safari Books Online for which I paid
 for in advance. I get emails when an update is ready, I click on the
 link http://my.safaribooksonline.com/mydownloads, login to my account,
 download an encoded pdf of the book and read it in draft. When the book is
 finished January, 2012 they will ship it out to me.

 You should use Safari Books Online.



Re: [web2py] Re: Web2Py Foundation?

2010-12-28 Thread Tim Alexander
Then maybe a bit of info around massimo being the BDFL (python/linux,
benevolent dictator for life) being out there might work. As said before,
seems very much like a perception problem rather than something that will be
solved via some sort of company or group running things rather than a single
person.

The current setup works great for me, but identifying that there are a few
people (the list above is awesome) who are web2py experts, and very
experienced in the code, even if there is a BDFL who is gatekeeper, and
setting that as the expectation/perception going forward might well fix
perception without any changes neccesary. Perhaps an about the developers
page or something? Or an explanation of some sort on the web2py site?

On Tue, Dec 28, 2010 at 2:42 PM, Jonathan Lundell jlund...@pobox.comwrote:

 On Dec 28, 2010, at 11:54 AM, VP wrote:
 
  I love the fact that if I have a problem with web2py and asked a
  question, Massimo will likely answer it.  But the perceptual problem
  of web2py is a single-person effort is real.  Massimo fixes most of
  the bugs (it seems so).  Massimo is mainly responsible for PR.
  Massimo is in charge of experts4solution (it appears so).  Massimo is
  mainly in charge of documentation (the book) (it appears so).
 
  Note that these are not necessary bad things.  But the concern is
  real. Now, you can say this issue should not be a concern (i.e. we are
  okay with the current setup).  Then that's a different perspective, a
  different story.

 Offhand, I can think of at least three major projects that have a single
 person in charge, in one way or another: Linux, OpenBSD and Python. I don't
 know much about the OpenBSD and Python patch processes, but all Linux
 patches go through Linus. So in that sense, Massimo's role is not
 unprecedented.




Re: [web2py] Re: Web2Py Foundation?

2010-12-28 Thread Tim Alexander
Something like that.

We could go with semi tolerant dictator for life... :)

On Tue, Dec 28, 2010 at 4:21 PM, mdipierro mdipie...@cs.depaul.edu wrote:

 benevolent?

 On Dec 28, 4:01 pm, Christopher Steel chris.st...@gmail.com wrote:
  While it is not required due to the nature of his position, I do
  hereby officially recognize Massimo Di Pierro as Web2py's Benevolent
  Dictator for Life as is in keeping with the Pythonic and opensource
  tradition and in recognition of his leadership and nurturing role in
  the development and maintenance of the Web2py project.
 
  Long Live Massimo!
 
  http://en.wikipedia.org/wiki/Benevolent_Dictator_For_Life
 
  On Dec 28, 4:02 pm, Tim Alexander dragonfyr...@gmail.com wrote:
 
   Then maybe a bit of info around massimo being the BDFL (python/linux,
   benevolent dictator for life) being out there might work. As said
 before,
   seems very much like a perception problem rather than something that
 will be
   solved via some sort of company or group running things rather than a
 single
   person.
 
   The current setup works great for me, but identifying that there are a
 few
   people (the list above is awesome) who are web2py experts, and very
   experienced in the code, even if there is a BDFL who is gatekeeper, and
   setting that as the expectation/perception going forward might well fix
   perception without any changes neccesary. Perhaps an about the
 developers
   page or something? Or an explanation of some sort on the web2py site?
 
   On Tue, Dec 28, 2010 at 2:42 PM, Jonathan Lundell jlund...@pobox.com
 wrote:
 
On Dec 28, 2010, at 11:54 AM, VP wrote:
 
 I love the fact that if I have a problem with web2py and asked a
 question, Massimo will likely answer it.  But the perceptual
 problem
 of web2py is a single-person effort is real.  Massimo fixes most of
 the bugs (it seems so).  Massimo is mainly responsible for PR.
 Massimo is in charge of experts4solution (it appears so).  Massimo
 is
 mainly in charge of documentation (the book) (it appears so).
 
 Note that these are not necessary bad things.  But the concern is
 real. Now, you can say this issue should not be a concern (i.e. we
 are
 okay with the current setup).  Then that's a different perspective,
 a
 different story.
 
Offhand, I can think of at least three major projects that have a
 single
person in charge, in one way or another: Linux, OpenBSD and Python. I
 don't
know much about the OpenBSD and Python patch processes, but all Linux
patches go through Linus. So in that sense, Massimo's role is not
unprecedented.
 
 



Re: [web2py] Cache stored at request, does not sync with other threads until new request

2010-12-21 Thread Tim Alexander
It occurs to me, I'm using uwsgi. I'm assuming cache.ram is per process,
meaning that if my Ajax side and xmlrpc side are not on the same process,
this will completely not work properly. I'll try flipping over to cache.disk
tomorrow morning to verify.
On Dec 21, 2010 5:20 PM, Dragonfyre13 dragonfyr...@gmail.com wrote:
 At least I think the subject seems to define the behavior.

 I have a function that exposes as an XMLRPC service. It puts something
 in a DB, and then polls to see if there is a response to it from
 another system talking to that same DB. (yes I realize that polling a
 DB is a bad thing but necessary for various reasons in this case)

 The difficulty is, there's an xmlrpc side, and an ajax side. The ajax
 side is a longpoll (simulated server side push) with a loop like this:

 while endtime  datetime.datetime.now():
 # This keeps finding a cached value, even when it's cleared
 by
 # another request.
 #for k in cache.ram.storage.keys():
 #logging.debug(k,v)
 #if k.find(next_action.ccid= + str(ccid)) != -1:
 # logging.debug(str(ccid) + found cached value)
 actionrow = localdb(localdb.next_action.ccid == ccid).select(
 cache=(cache.ram,600)).first()
 if actionrow and len(actionrow) and actionrow.action_str !=
 None and \
 actionrow.return_str == None:
 return dict(action_xml=actionrow.action_str,
 ccid=ccid)
 time.sleep(.5)

 The XMLRPC side is much the same. ccid is a unique key for the
 conversation for both of them to use. The action string is where the
 XMLRPC side pushes information, and return_str is data that is handed
 back after the ajax longpoll fulfills the action string's needs.


 My problem in all of this is the comments above. Even though when I do
 an update on the XMLRPC side, I clear cache for this select statement
 (via setting timeout to 0 for that select statement in cache) it still
 maintains the value pulled from cache in the ajax request above. So I
 don't pull out the actual value in the DB until cache expires in this
 function, even though I've cleared the cache via setting timeout to 0
 in the other function:
 localdb(localdb.next_action.ccid == ccid).select(cache=(cache.ram, 0))


 Any ideas? For now, I really don't know what I'm looking at for an
 issue or resolution, but even a yep, makes a copy when your request
 object is created would work if someone knows. Or you're an idiot,
 do it like this would be even better!


Re: [web2py] can't get SSL/admin working on LAN (apache + mod_wsgi)

2010-02-26 Thread Tim Alexander
Not sure why this isn't going through off the google groups page, but I'll
just reply via email.

The problem centers around the port you're hitting it on. You have admin
access disabled on 8080 via the below lines:

   Location /admin
   Deny from all
   /Location

that's why http://myserverIP:8080 doesn't work when clicking on the link.
The reason https://myserverIP:8080/admin doesn't work, is because you're
trying to access the http port via https. To visit myserverIP on port 443,
go to https://myserverIP/admin since https defaults to port 443 on all
current browsers. If you want to specify a port, feel free to do
https://myserverIP:443/admin https://myserverIP:8080/admin

Either of those will get you in. Also, shouldn't be any issues just doing
everything over https, via https://myserverIP/ that's how I'm currently
running everything.

On Fri, Feb 26, 2010 at 4:06 PM, snfctech tschm...@sacfoodcoop.com wrote:

 apache2 fedora10 web2py1.75.5

 I set up my web2py.conf virtual host file per the instructions on
 p285-288 of the web2py book (2nd edition).  The main differences from
 the examples are that I'm running Fedora10 and serving web2py on port
 8080 for access over a LAN.  I also removed display-name=%{GROUP}
 from the WSGIDaemonProcess directive, per a thread I found on this
 group.

 I can hit the welcome app fine from other machines by hitting
 http://myserverIP:8080.  When I click on the link for the
 administrative interface, I get a 403 error.  When I hit
 https://myserverIP:8080/admin I get a 303 error The connection to
 myserverIP:8080 was interrupted while the page was loading.

 I'm pretty stuck at this point.  Any help would be greatly
 appreciated.

 Here is my web2py.conf:

 VirtualHost *:8080

ServerName web2py.order-system.com
WSGIDaemonProcess web2py user=apache group=apache
WSGIProcessGroup web2py
WSGIScriptAlias / /var/www/web2py/wsgihandler.py

Directory /var/www/web2py
AllowOverride None
Order Allow,Deny
Deny from all
Files wsgihandler.py
Allow from all
/Files
/Directory

AliasMatch ^/([^/]+)/static/(.*) /var/www/web2py/applications/$1/
 static/$2

Directory /var/www/web2py/applications/*/static/
Order Allow,Deny
Allow from all
/Directory

Location /admin
Deny from all
/Location

LocationMatch ^/([^/]+)/appadmin
Deny from all
/LocationMatch

ErrorLog logs/web2py-error_log
CustomLog logs/web2py-access_log common

 /VirtualHost

 LoadModule ssl_module modules/mod_ssl.so
 NameVirtualHost *:443

 VirtualHost *:443

ServerName web2py.order-system.com
SSLEngine on
SSLCertificateFile /etc/httpd/ssl/server.crt
SSLCertificateKeyFile /etc/httpd/ssl/server.key

WSGIProcessGroup web2py

WSGIScriptAlias / /var/www/web2py/wsgihandler.py

Directory /var/www/web2py
AllowOverride None
Order Allow,Deny
Deny from all
Files wsgihandler.py
Allow from all
/Files
/Directory

AliasMatch ^/([^/]+)/static/(.*) /var/www/web2py/applications/$1/
 static/$2

Directory /var/www/web2py/applications/*/static/
Order Allow,Deny
Allow from all
/Directory

ErrorLog logs/web2py-error_log
CustomLog logs/web2py-access_log common

 /VirtualHost










 --
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To post to this group, send email to web...@googlegroups.com.
 To unsubscribe from this group, send email to
 web2py+unsubscr...@googlegroups.comweb2py%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/web2py?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.