[web2py] Re: Strange but useful THEAD trick!

2014-09-10 Thread Joe Barnhart
Well, I have to eat my tuple claims. And they are tasty. This works and renders the strings inside TH elements:: head = THEAD([['Date','Name','Amount','Term']]) As does this: head = THEAD([('Date','Name','Amount','Term')]) But (no surprise) these do not: head = THEAD(['Date','Name','Am

[web2py] Re: web2py meetup Bay Area

2014-09-10 Thread Joe Barnhart
I'm in! I live in Santa Clara, or as most people know it ... Silicon Valley! On Wednesday, September 10, 2014 12:12:14 PM UTC-7, weheh wrote: > > I've moved back to the Bay Area and was surprised to find there is no > web2py meetup group. Massimo, how did your web2py meetup in San Fran go > ma

[web2py] request password generates an infite loop?

2014-09-10 Thread Martin Weissenboeck
I have a fresh copy of w2p 2.9.9 and I have tried the request_reset_password function. It generates an email with a text like http://127.0.0.1:8000/testupdate/default/user/reset_password/14104... It's the right auth_user.reset_password_key That's ok, but if I try this link I get an error message f

[web2py] Re: Customize SQLFORM.grid

2014-09-10 Thread Luciano Laporta Podazza
Thanks guys! Anthony's hint help me out to solve this. If somebody is interested on how I did it, here's the code: def search(): users = SQLFORM.grid(db.users, fields=[db.users.id, db.users.facebook_id, db.users.first_name, db. users.last_name, db.users.birthday], sortable=Fa

[web2py] Re: Strange but useful THEAD trick!

2014-09-10 Thread Anthony
Well, the code I pasted definitely works -- copied the code and output directly from the shell (also tried in an app). Can you show your code where a tuple worked but a list did not? Also, please show the code that wraps the cells in TD's instead of TH's. Anthony On Wednesday, September 10, 20

[web2py] Re: Strange but useful THEAD trick!

2014-09-10 Thread Joe Barnhart
Actually, no. Wrapping a list inside a list does NOT work. In that case, the inside list is all "joined" together as a single string. Only a tuple inside a list works. I tried everything, only the tuple in the list worked. On Wednesday, September 10, 2014 5:04:54 AM UTC-7, Anthony wrote: > >

[web2py] Re: Check is user is the owner of row (help with db query)

2014-09-10 Thread Anthony
> db((db.task.id == 5) & (db.task.ref_to_job == db.job.id) & > (db.job.ref_to_project == db.project.id) & (db.project.owner == > auth.user_id)) > > I tried it and it works, but I am not sure how different it is from the > one Leonel suggested. How does this work? > The above does a join, so i

[web2py] Re: Check is user is the owner of row (help with db query)

2014-09-10 Thread desta
Thanks Anthony, indeed I will have to evaluate the tradeoff of speed for complexity. I don't think that our site will have the amount of traffic that this would be a problem but its always good to know good practices! A friend suggested to use db((db.task.id == 5) & (db.task.ref_to_job == db.job

[web2py] Re: Comments/notes and api documentation

2014-09-10 Thread Anthony
It's not embedded with the main documentation, but for user contributed content, we do have http://www.web2pyslices.com/home. Anthony On Wednesday, September 10, 2014 5:55:36 PM UTC-4, Robin Manoli wrote: > > Hey, > the php documentation has user comments with examples of how to use > different

[web2py] Comments/notes and api documentation

2014-09-10 Thread Robin Manoli
Hey, the php documentation has user comments with examples of how to use different functions. This is a great complement to their documentation. With web2py I have stumbled upon many things in these forums that I have not seen in the documentation. I'm not sure how often you update it, since I

[web2py] Re: Reasoning behind "dict objects", such as request.vars, session, etc

2014-09-10 Thread Anthony
> > I was looking for something that does exactly this, using a dict with > class syntax, and I could only find solutions that would set class > attributes. The only problem I stumbled upon would be to use the key "from" > as it is a python keyword. > With Storage, you can use "from" as a key,

[web2py] Re: Enabling HTML posts for admin (security)

2014-09-10 Thread Yousif Iyad Shaban
Yes, thank you, I'm disabling registration for a personal blog in which I'm the only one who posts, and from the looks of it the answers suggest this is enough. On Wednesday, September 10, 2014 7:46:20 PM UTC+3, Anthony wrote: > > Depends on how secure the posting permissions are. Disabling reg

[web2py] Re: Reasoning behind "dict objects", such as request.vars, session, etc

2014-09-10 Thread Robin Manoli
> > > I've been looking into using classes to store values, just like for >> example session does in web2py. I found on stack overflow that it might not >> be pythonic, it is not recommended by some experienced programmers. >> > > Not sure what that means. Can you share specific arguments made a

[web2py] Re: web2py meetup Bay Area

2014-09-10 Thread Jonathan Lundell
I'm down in the Half Moon Bay area, spend some time in the valley. Meetup'd be fun. On Wednesday, September 10, 2014 1:08:58 PM UTC-7, Massimo Di Pierro wrote: > > I agree. I come often to SF. I will be there again at the end of November. > Let me know what I can do to help. > > On Wednesday, 10

[web2py] Re: web2py meetup Bay Area

2014-09-10 Thread Massimo Di Pierro
I agree. I come often to SF. I will be there again at the end of November. Let me know what I can do to help. On Wednesday, 10 September 2014 14:12:14 UTC-5, weheh wrote: > > I've moved back to the Bay Area and was surprised to find there is no > web2py meetup group. Massimo, how did your web2py

[web2py] web2py meetup Bay Area

2014-09-10 Thread weheh
I've moved back to the Bay Area and was surprised to find there is no web2py meetup group. Massimo, how did your web2py meetup in San Fran go many moons ago? How was the interest level? Bay Area web2py community, are you interested in a web2py meetup? Or should we continue to piggy-back the pyt

[web2py] Re: map weirdness

2014-09-10 Thread Cliff Kachinske
Got it. That's why I need to unpack the list. I even knew that. (palm to forehead) On Wednesday, September 10, 2014 11:23:41 AM UTC-4, Anthony wrote: > > SELECT is not expected to behave like your printem() function, which > merely takes a list. SELECT can either take a list, or it can take a s

[web2py] Re: Cannot resolve reference error

2014-09-10 Thread José Eloy
Thanks Niphlod for the answer. I didn't know that was not possible to reference tables from a database to another. The solution to this is to move the required tables to the external database. Regards. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.

[web2py] Re: Enabling HTML posts for admin (security)

2014-09-10 Thread Anthony
Note, you can also do XML(..., sanitize=True) and also specified permitted_tags and allowed_attributes to make it a little safer. Anthony On Wednesday, September 10, 2014 12:46:20 PM UTC-4, Anthony wrote: > > Depends on how secure the posting permissions are. Disabling registration > isn't nece

[web2py] Re: Enabling HTML posts for admin (security)

2014-09-10 Thread Anthony
Depends on how secure the posting permissions are. Disabling registration isn't necessary, as long as registered users can't post. Of course, if you don't need registration (presumably you don't if you're disabling it), then you should disable it anyway. Anthony On Wednesday, September 10, 201

[web2py] Re: Enabling HTML posts for admin (security)

2014-09-10 Thread Niphlod
you are the only one choosing how much security would matter to you and your app. In this case, you are permitting anything to be injected in your page. If you trust your users at that level, please do. As soon as you get an annoyed user, your site will be screwed but hey, you were the trusting

[web2py] Re: How to run web2py's scheduler as uwsgi's mule?

2014-09-10 Thread Niphlod
if started, scheduler doesn't quit itself. Where are you needing to pass "-p 25903" ? BTW: in that script, importing gluon.widget is superflous. On Wednesday, September 10, 2014 3:00:11 PM UTC+2, Zbigniew Pomianowski wrote: > > I think I can have a resident process. When I make a simple loop sc

[web2py] Enabling HTML posts for admin (security)

2014-09-10 Thread Yousif Iyad Shaban
If I was to enable HTML in posts using: {{=XML(post.body)}} and disable registration entirely using: auth.settings.actions_disabled.append('register') Would that be enough to remove security concerns about injections from the outside? And as a side note, thank you guys for this great framewo

[web2py] Re: map weirdness

2014-09-10 Thread Anthony
SELECT is not expected to behave like your printem() function, which merely takes a list. SELECT can either take a list, or it can take a set of positional arguments. In your case, however, you have passed it one positional argument followed by a second positional argument that happens to be a

[web2py] Re: Customize SQLFORM.grid

2014-09-10 Thread Anthony
Are you saying you don't want each record in an HTML table row but instead want to display each record as a card? There's no built-in way to do that, but you can hack the returned grid object and replace the HTML table with your own DOM: def my_custom_grid_layout(rows): [code to produce the

[web2py] Re: get hidden input value in controller

2014-09-10 Thread Anthony
On Wednesday, September 10, 2014 8:45:36 AM UTC-4, Mirek Zvolský wrote: > > Maybe(?) he creates hidden field in the html, instead to define it in the > SQLFORM(): > form = SQLFORM.factory( > Field('customer', label="Select customer"), > hidden=dict(customer_id='') > ) > D

[web2py] Re: get hidden input value in controller

2014-09-10 Thread Anthony
On Wednesday, September 10, 2014 7:26:12 AM UTC-4, trr wrote: > > Thanks Niphlod. I changed from _type='hidden' to _class='hidden. But still > it is not in request.vars. In controller I do > INPUT(_id='txtNoOfRows',_class='hidden',_value=len(l)), > No need for that -- _type='hidden' should work

[web2py] Re: map weirdness

2014-09-10 Thread Cliff Kachinske
Python does as below. SELECT does otherwise. I was curious as to why. In [1]: foo = ['bar', 'baz', 'bazzle'] In [2]: def func(str): ...: return 'fu{}'.format(str) ...: In [3]: map (func, foo) Out[3]: ['fubar', 'fubaz', 'fubazzle'] In [4]: def printem(lis): ...: for l in li

[web2py] Re: RSS is an error! What to do?

2014-09-10 Thread Massimo Di Pierro
Sorry for the trouble here: I pushed this to trunk: def rss(feed): if not 'entries' in feed and 'items' in feed: feed['entries'] = feed['items'] def safestr(obj, key, default=''): return str(obj[key]).encode('utf-8', 'replace') if key in obj else default now = datetim

[web2py] Re: get hidden input value in controller

2014-09-10 Thread trr
Thanks Niphlod. I changed from _type='hidden' to _class='hidden. But still it is not in request.vars. In controller I do INPUT(_id='txtNoOfRows',_class='hidden',_value=len(l)), On Tuesday, September 9, 2014 4:20:48 PM UTC+5:30, trr wrote: > > > I have a hidden input in form. I set the hidden val

[web2py] Re: Make grid view larger & add scroll bar to top

2014-09-10 Thread Antonis Loumiotis
LoveWeb2py wrote "is it possible to add a scroll bar to the top so I don't have to scroll all the way to the bottom to scroll to the right?" I also have the same question. Thanks, Antonis -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/we

[web2py] SQLFORM.grid in LOAD() search error

2014-09-10 Thread Ariya Owam-aram
Dear all, There is an error when use SQLFORM.grid in LOAD function. This are steps to reproduce the problem? *Step 0* # in models/db.py db.define_table('product', Field('code', length = '50', notnull = True, unique = True), Field('name', notnull = True), ) *Step

[web2py] 'Table' object has no attribute 'type'

2014-09-10 Thread Tommi Lahtonen
I have no idea how to fix this error. I used this same code earlier in google app engine and it worked just fine. Now I moved my app to ubuntu + apache + postgresql and got this error: Error ticket for "viikko" Ticket ID 130.234.160.35.2014-09-10.08-14-09.e20b10b7-72bd-4f79-9618-948387ca1cf0

Re: [web2py] Re: web2py app as proxy... but how?

2014-09-10 Thread Manuele Pesenti
Il 10/09/14 11:18, Niphlod ha scritto: > too much code will kill you. Start simple, and go from there onwards. thank you so mutch! M. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/

[web2py] Re: How to run web2py's scheduler as uwsgi's mule?

2014-09-10 Thread Zbigniew Pomianowski
I think I can have a resident process. When I make a simple loop script it is executed by mule. It is strange to me I need to pass "-p 25903" to have active worker that performs the queued tasks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2

[web2py] Re: get hidden input value in controller

2014-09-10 Thread Mirek Zvolský
Maybe(?) he creates hidden field in the html, instead to define it in the SQLFORM(): form = SQLFORM.factory( Field('customer', label="Select customer"), hidden=dict(customer_id='') ) Dne středa, 10. září 2014 14:34:44 UTC+2 Anthony napsal(a): > > trr said the value is *no

[web2py] Re: get hidden input value in controller

2014-09-10 Thread Mirek Zvolský
maybe it works without this line too: Field('customer_id', readable=False, writable=False), -- 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 t

[web2py] Re: get hidden input value in controller

2014-09-10 Thread Anthony
trr said the value is *not* in request.vars. On Wednesday, September 10, 2014 8:32:51 AM UTC-4, Mirek Zvolský wrote: > > You need to rewrite request.vars into form.vars in form validation. > I use following (based on maybe web2py doc or maybe some article in this > conference). > I have javascrip

[web2py] Re: get hidden input value in controller

2014-09-10 Thread Anthony
Can you show your code? What does the DOM look like right before submitting? Using the browser tools, what data get sent with the post request? On Tuesday, September 9, 2014 6:50:48 AM UTC-4, trr wrote: > > > I have a hidden input in form. I set the hidden value in client by java > script. But

[web2py] Re: get hidden input value in controller

2014-09-10 Thread Mirek Zvolský
You need to rewrite request.vars into form.vars in form validation. I use following (based on maybe web2py doc or maybe some article in this conference). I have javascript YUI2 autocomplete in client (on customer field), which will set hidden customer_id field. In JavaScript I use jQuery selector

Re: [web2py] Re: two forms submitted into the same cotroller

2014-09-10 Thread Andrey Khmelevskiy
Thank Cliff and Massimo for your help. I have finally make in very similar fission: I have 2 divs, controller1 with static form with id=1 that inserted in div1, another controller2 that triggers by w2p_component (ajax) and generates form with id=2 and inserted to div2 but all input fields of this f

[web2py] Re: Strange but useful THEAD trick!

2014-09-10 Thread Anthony
Can you show an example of where it wraps the items in a TD? I think that would only happen if you explicitly put items into TR's, in which case the TR will control what wraps its components. Also, you don't need a tuple -- can just be a list inside a list: print THEAD([['a', 'b']]) ab Antho

[web2py] Re: How to run web2py's scheduler as uwsgi's mule?

2014-09-10 Thread Niphlod
I don't think webfaction allows you to have a resident process active beside the web-serving one. On Wednesday, September 10, 2014 12:35:25 PM UTC+2, Zbigniew Pomianowski wrote: > > Hi, I tried this apporach: > http://blog.lifeeth.in/2012/02/uwsgi-mule-magic-and-web2py-scheduler.html > > My conf

[web2py] How to run web2py's scheduler as uwsgi's mule?

2014-09-10 Thread Zbigniew Pomianowski
Hi, I tried this apporach: http://blog.lifeeth.in/2012/02/uwsgi-mule-magic-and-web2py-scheduler.html My config.xml for uwsgi: web2py web2py /home/user/webapps/web2py/env :25903 /home/user/webapps/web2py/web2py wsgihandler /tmp/web2py.sock spare 1 6 run_scheduler.py 1

[web2py] Re: IS_INT_IN_RANGE() weirdness

2014-09-10 Thread Leonel Câmara
The INT implementation is correct as it follows the python convention for ranges. For float frankly it's better that way as float comparison is a freaking headache. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https

[web2py] Re: get hidden input value in controller

2014-09-10 Thread Niphlod
by default in form submission any input with the attribute hidden is not sent. That's HTML 101. If you need something that is not visible to the user but the browser still needs to submit, use css, not the attribute hidden. On Tuesday, September 9, 2014 12:50:48 PM UTC+2, trr wrote: > > > I hav

[web2py] Re: Can I interact with code in Java Springs using web2py?

2014-09-10 Thread Niphlod
there is no or little way to make python talk with java. I assume though that the java app can return some data in form of an api call. from there on it's just a matter of coding in web2py the api call. On Tuesday, September 9, 2014 10:43:10 AM UTC+2, Gurpreet Singh Anand wrote: > > I am a Pytho

[web2py] Re: Strange but useful THEAD trick!

2014-09-10 Thread Joe Barnhart
I dunno. If a bug turns out to be useful, does that make it a feature? On Wednesday, September 10, 2014 12:54:11 AM UTC-7, Cliff Kachinske wrote: > > Are you sure that's a feature and not a bug? > > On Wednesday, September 10, 2014 3:32:24 AM UTC-4, Joe Barnhart wrote: >> >> I often use the web2p

[web2py] Re: Cannot resolve reference error

2014-09-10 Thread Niphlod
you can't cross-reference a field between two separate databases..there's no way to create a foreign key between different databases. On Wednesday, September 10, 2014 1:36:23 AM UTC+2, José Eloy wrote: > > Hi! > > I'm developing an web2py application that use an external SQL Server > da

[web2py] Re: db.commit() taking too long to update records

2014-09-10 Thread Niphlod
BTW, log somewhere db._timings before returning and try to replay the query in mysql to see what's going on. On Wednesday, September 10, 2014 12:54:03 AM UTC+2, Leonel Câmara wrote: > > Well that's true, but web2py automatically calls db.commit for you after > running the controller. That would

Re: [web2py] Re: web2py app as proxy... but how?

2014-09-10 Thread Niphlod
too much code will kill you. Start simple, and go from there onwards. def test(): url = 'http://creativity103.com/collections/Landscape/golf_course.jpg' r = requests.get(url) if r.status_code == 200: newheaders = r.headers meaningful = ['Content-Length', 'Content-Type',

[web2py] Re: Launching modal form from onupdate callback (Grid)

2014-09-10 Thread Sarbjit
I tried the following such that when the user clicks on Submit button from the Grid edit form, it would open the dialog. -> But it just opens the dialog and in actual doesn't updates the db or performs the other checks. grid.element(_type='submit')['_onclick']='%s;return false' %dialog1.show()

[web2py] Re: map weirdness

2014-09-10 Thread Leonel Câmara
You need to argument expand (using *) the result of the map in the first case. myselect = SELECT( OPTION('Choose'), *map(make_option, rows), _id='container_selector', _name='container_selector', ) -- Resources: - http://web2py.com - h

[web2py] map weirdness

2014-09-10 Thread Cliff Kachinske
Does anyone have a clue why this code def make_option(row): return OPTION(row[1], _value=row[0]) q = ''' SELECT id, name FROM products WHERE is_active = 'T' AND tenant_link = {} AND is

[web2py] Re: Strange but useful THEAD trick!

2014-09-10 Thread Cliff Kachinske
Are you sure that's a feature and not a bug? On Wednesday, September 10, 2014 3:32:24 AM UTC-4, Joe Barnhart wrote: > > I often use the web2py helpers to build my tables on the fly. I've always > thought it was strange that my THEAD() helper seemed to prefer wrapping its > components inside a T

[web2py] Re: Customize SQLFORM.grid

2014-09-10 Thread Cliff Kachinske
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#format--Record-representation Not entirely sure if the record representation technique will work, but maybe you could use the lambda to call a named function that renders the divs for each thumbnail. I think the css wi

[web2py] Re: "validate_and_insert" my new best friend

2014-09-10 Thread Joe Barnhart
I'll definitely keep that code in mind. It looks really useful for barely-structured or unstructured data! My text files are so highly structures that I'm using "struct" to parse the text. The fields are all on fixed boundaries. It's just that the text format chosen represents fields in stra

[web2py] Strange but useful THEAD trick!

2014-09-10 Thread Joe Barnhart
I often use the web2py helpers to build my tables on the fly. I've always thought it was strange that my THEAD() helper seemed to prefer wrapping its components inside a TD element instead of a TH. I mean, why not a TH? We already know its in a header. Playing around, I found this pattern wo