The new CSS3 buttons look pretty sweet.
The order of CSS priority is (from least important to most important):
Whichever CSS file gets called LAST is the one that takes priority. Then
whatever is in the head HTML file's tags, then on the
individual elements themselves (i.e. ).
So if you link to your base.css, then to layout's style.
Polling with JavaScript is the most common way. However, there is a way to
use comet, which allows the server to push updates immediately to clients,
but I've never used that, it's still experimental, and may be difficult to
set up. Unless you need instant updates (like with an instant messaging
If I am reading this properly, you want to create a new instance if db for
each thread? I have never tried this before, but could you do something like
this for each thread?
db_thread = DAL(db._uri)
for k, v in db.items():
db_thread[k] = v
The idea being to using the existing db's URI strin
Now if we could just get a built-in web2py version that does the exact same
thing. Massimo should be able to knock that out in a couple hours :)
Just kidding, of course. Although it would be sweet.
Whenever I have to pass variables from Python to JavaScript, I usually do it
like this to avoid problems, and to make the code cleaner:
var target = '#page-{{=page.id}}';
jQuery(target).click(function() {
alert('clicked');
});
A quick note about this. ID, NAME, and CLASS HTML attributes need
I am not that familiar with CAS, but it might be useful in some cases to
know what groups the user is a member of in the remote web2py installation.
For example, if there is an 'Administrators' group that should have access
to everything, then you wouldn't have to set up groups and permissions f
That would be nice. It has all the information required, plus group
membership. Would this work with custom auth_user tables as well?
Should it transfer all fields in auth_user, or should the application
provide its own service to get more information if it needs to?
This is fantastic. I was going to have to do something like this in the
future. Glad to know that web2py makes it easy :)
For whatever reason, after running for 24 hours, web2py throws an exception
when trying to log in. I have to stop web2py, and restart it, then the error
goes away and my application starts working again. Any ideas?
Traceback (most recent call last):
File "/media/psf/Python/web2py/gluon/main.py
Some elements are set to display: none, like the .flash and .hidden CSS
classs. The reason for this is to prevent exactly what you are describing.
You don't want those elements to be displayed before JavaScript has a chance
to load. Once the page is fully loaded, then JavaScript makes these elem
I am trying to make a user editor and running into trouble. I have the
standard auth_user table, and I also have an auth_user_extended table that
stores a bunch of other information, using auth_user as the reference
between the two tables. I set my controller up like this:
def update():
id
So you basically do:
form = SQLFORM(db.auth_user, id)
form2 = SQLFORM(db.auth_user_extended, row.auth_user_extended.id)
form.append(form2)
Interesting. I'll have to give this a shot...thanks!
This is the code I have:
form = SQLFORM(db.auth_user, row.auth_user)
form.append(SQLFORM(db.auth_user_extended, row.auth_user_extended))
My view requires that I manually build the form, and for some reason, when I
look at the resulting form object via PDB, the form object has two
I've gotten much closer with this, however, I am still hitting a snag:
One of the fields in my auth_user_extended is set to
requires=IS_NOT_IN_DB(). And when form.accepts is called, I'm still getting
a "value already in database" error.
I do have a script that runs every day, but I don't think that is the
problem because it doesn't touch sessions. In the application itself, one of
the things I store in is a list of URL objects in the session. Every time a
user logs in, the menu is generated based on that user's permissions an
You were right, that was a stupid mistake on my part. However, it still
isn't working. This is the new select() command, but I still get the
previous error:
row = db((db.auth_user_extended.auth_user==db.auth_user.id) &
(db.auth_user.id==id)).select().first()
The model for the field that is giv
If I remove the requires, then the record updates properly, but the idea is
that the barcode id should be unique. So is this a bug? I mean I could do
custom validation on the form to ensure the barcode id is unique, but that
kind of defeats the purpose of requires.
The current trunk version is pretty stable for me. I know there are a few
people out there looking forward to the new import functionality. Plus, it's
been about a month since the last stable release, so it's probably time :)
Though you may want to make a note that it will not work with Python 2
Jose,
I learned the hard way that Python 2.4 is no longer supported by web2py and
a lot of the new stuff in the trunk requires Python 2.5 or higher. I had
submitted several patches to support Python 2.4, but they were rejected
because maintaining Python 2.4 support really is a pain, which is wh
response.file is what you are looking for, not request. And response.files
is simply a list, and append just appends another item to the list. The
web2py_ajax.html view is what loops through the list and writes the
and
Jose,
That is understandable. The two incompatibilities with Python 2.4 that I am
aware of are:
http://code.google.com/p/web2py/issues/detail?id=269&can=1&q=python%202.4
and
http://code.google.com/p/web2py/issues/detail?id=267&can=1&q=python%202.4
This basically means that using "from gluon imp
You could always do something like this in your layout.html:
{{if 'extra_css_files' in response:}}
{{for file, media in response.extra_css_files:}}
{{pass}}
{{pass}}
Then in your menu.py, you would want to put this in:
response.extra_css_files = {}
And anywhere you want to include your
That is how I do it. As far as I know, setting registration_key to
'disabled' is the only way for web2py to deny a log in for someone using
Auth. When I need to set this or check it, I just wrap the code into a
generic is_disabled() method to do the checking in case a better way
presents it sel
I am actually using web2py as a JSON-RPC service now. Using RPC, you can
make a web2py application act like you are running functions on the local
machine. This is most commonly used to provide a desktop application that
can interface with your web service. Right now, I have a web2py installatio
All the communication is done on the local network, so security isn't a huge
issue, however, I still require the JSON-RPC service to communicate over
HTTPS so that when I pass username/password combinations to it, it's all
encrypted. And I use a custom controller that checks authentication.
Alt
I'm not exactly sure what's going here, but at first glance, this is what I
see:
I think you are using attr() wrong. In the first section of code, you are
checking the 'Protected' attribute, but in the second block of code, you are
setting an 'onchange' attribute to the value of 'Protected', Ma
This patch that was added to the trunk breaks my application which runs on
MSSQL. Whenever I try to read a datetime from MSSQL now, I get a syntax
error about not being able to parse the date time from a string. Reverting
my web2py installation to to R-1.96.1 fixes the problem.
Doing a little more research on this:
This happens when doing an INSERT. And the exact error I get:
DataError: ('22007', '[22007] [FreeTDS][SQL Server]Syntax error converting
datetime from character string. (241) (SQLExecDirectW)')
What's happening is my application is importing data from a leg
AHAH!
I figured out what it was. I will post in a new thread since it actually has
nothing to do with the DAL at all, but rather the new behavior of the
Storage() object.
I just updated my trunk only to find several scripts not working properly
and acting strangely. I thought it was a change made to MSSQL, but I have
narrowed down the problem to revision 1980 titled, 'many semplifications'. A
change made to storage.py's __getattr__() function is causing the probl
It still returns an empty Storage instance instead of None.
I just tried this in a web2py shell:
>>> from gluon.storage import Storage
>>> data = Storage()
>>> data.foo = 'bar'
>>> data.foo
'bar'
>>>data.test
Having the two Storage and MultiStorage objects would be nice, as Storage
would require explicit initialization (just like request.vars does). Then if
you want to use recursive Storage objects (data.a.b.c = 1), that's where
MultiStorage comes in.
Nice suggestion, because I do like this new func
Setting requires only performs validation with CRUD and SQLFORM. Doing a
direct insert does not cause validation to be checked. Try using
validate_and_insert() instead of insert().
In your SQLFORM call, you should be able to set deletable=False
http://web2py.com/book/default/chapter/07#SQLFORM
I just got hit by this change. I think the original reason why it never
showed the toolbar for a single returned item was to make web2py easier to
use. I'll give a use case:
You want to create a simple form, so in a controller you do the following:
form = SQLFORM(db.table)
return dict(form=form
It says "I bet the PyCharm team will step up to the task". I hope this is
their way of secretly saying, "It's now on our todo list". I use Komodo IDE
for development right now, which is a decent editor with autocomplete, but
no debugging (and no remote debugging either). So I hope PyCharm does a
I thought this change meant that regardless of the number of variables
passed, it shows the toolbar anyways if is_local. My application that was
created before back in 1.94.1 does not check for is_local, because I see the
toolbar on a remote machine, when all I pass is form=form. This change is
No proxy, just default Ubuntu Server 10.04.2 with web2py trunk, plus pyodbc.
No web server is installed on the machine and I am running it using python
web2py.py -i 0.0.0.0 -a password -c cert.crt -k key.key, so I wonder if it
has something to do with SSL? And the generic views have not been mod
Not to start a holy war or anything, but I hear people talking all the time
about how emacs or vim is the best code editor ever. Why is that? Does it do
code completion or have some other really helpful feature that I just
missed? I've used vim to edit text files, but editing code in a tiny cons
This was a while ago, and I cannot find my source at the moment, but I
recall reading a benchmark done that put RoR faster than PHP, but slower
than Python by a large margin (without server-side caching and other
performance tweaks). If I find the original article or maybe a more recent
one on
Good point. The last thing we want is another Python vs RoR vs whatever war.
I know that I helped test performance and ran my own benchmarks when Massimo
was working performance improvements with regards to session files back in
March, since sessions can slow down response times. My own testing
web2py makes extensive use of these. Take the A, DIV, or TABLE as examples,
you can pass HTML attributes (e.g. _class, _id, _style) to these, but if you
look at the code, you will notice that these things are not in the signature
of these methods. They allow you to provide an unknown number of p
That would be awesome. I tried using Eclipse + PyDev once, but it just felt
too big and complicated, especially since it didn't know anything about
web2py and couldn't do autocomplete. If this works, I may have to reevaluate
Eclipse + PyDev again.
I'm sure you've already considered this, but maybe use a checkbox instead,
as it's specifically designed to handle true/false. The SELECT widget and
associated IS_IN_SET is designed to return a string value. So If you really
want to use a select box for this instead of a checkbox, then you need
For the last month or so, I have been working on a plugin that does
something similar to CRUD, except that it's all AJAX and provides a couple
of nice features for editing things. Obviously, it doesn't work exactly like
CRUD, since I've never really looked at the code for it, but I wanted
somet
That would be something if it actually went into the trunk :) Thanks for
offering to help to. I'll send you over what I have. It is a somewhat large
and complicated plugin, so maybe you will find a better way to do some of
the things in there and simplify it a bit.
I sent everything to you before I got this message, so now I'm looking at
either using BitBucket or Google Code (because that's what web2py uses).
That is unless Massimo wants to give me a named branch or something ;)
Ok, I made a repository on BitBucket, so anyone that wants to help with with
this, please do.
https://bitbucket.org/PhreeStyle/web2py_crud/src
I chose to go with a locally installed jQuery UI since my original project
was designed to replace an internal enterprise application which may not
have internet access once it goes into production. I suppose I could make it
pull from the CDN by default to lower the barrier to entry. But I want
The more I get in to working with web2py and writing applications, I always
seem to end up including jQuery UI in my applications, if for no other
reason than it's easy to theme elements of my application using ThemeRoller.
For example, the menu is usually the first thing I change by using the
I make heavy use of Storage in my apps because dot notation is so much
easier and faster. It is completely backwards compatible with Python's
dictionary. I usually end up putting this at the top of all my controllers
and modules:
from gluon.storage import Storage
Then instead of using a dictio
True about plugin_wiki, but not everyone uses it. I know I don't, just
because I am mostly developing internal enterprise applications that do CRUD
operations on a database. Also, there are other plugins that require jQuery
UI, so having those plugins include their own version of it is a bad ide
I've been using StartSSL for a couple years now. I generate S/MIME certs,
SSL certs, and one for our Jabber server. Works great and never had a
problem and it was all FREE. Their paid certs are very competitively priced
too. The class 1 certs are about half the price of GoDaddy's and allow for
Jim,
You could try doing:
import sys
sys.path.append('/path/to/web2py/applications/another_app/modules')
from mymodule import MyClass
Alternatively, you could also add mymodule to a location that already exists
in sys.path.
I am trying to provide an editor for auth_user using SQLFORM. I also am
trying to add a checkbox to the bottom of the form to set whether or not the
user is an administrator. If so, then the user gets added to an
Administrators group when calling form.accepts().
The strange part is, the code wo
With jQuery, I think you just have to do something like the following (but
check the docs first http://api.jquery.com/jQuery.post/ ):
var form_vars = jQuery('#myform').serialize();
jQuery.post(url, form_vars, function() {
alert('POST was successful');
});
When talking across applications like that, you might be better off putting
your core functionality in its own app, then having all of your other apps
make XML-RPC or JSON-RPC calls to it. This gives you a good level separation
and means that you can break up your apps and run each of them on a
I tried it in a multitude of ways, (using SQLFORM and SQLFORM.factory) and
none of them worked. I did not try setting dbio=False and doing it myself,
however. Perhaps that's what I should have done. Instead, I turned
is_administrator into something that gets set separately. Not optimal, but
may
This is the first time I have really tried to deploy web2py to a production
server, so I'm going to need some help. What I want to do is run my web2py
app through Apache using a subdomain. Right now, I've got the server
configured as a LAMP server using the default Ubuntu configuration because
I copied the web2py folder over from the trunk, since that's the version I
developed the app from. I cannot find the file you describe in the trunk
version of web2py. A lot of the config files I see around the web involve
putting web2py at the root of the server. What I wanted to do (and I don't
I probably overuse DropBox using this method. I actually have my code on
DropBox AND have the web2py server using those files running on two
different machines at the same time. I have never had the problem you
describe. The only problem I have is conflicting cron files from the two
machines wr
Did this ever get resolved? I tried looking for a ticket on this but only
found one related to setting unique=True. I have to convert my app to
support multiple tenants and IS_IN_DB() and IS_NOT_IN_DB() are going to be
used in several places to make sure that a tenant cannot have duplicate rows
Ok, thanks Massimo. I know that unique=True will never work because there's
no way to tell the database about multi-tenancy, I just wanted to make sure
the validators were working properly.
I have a similar set up, but do not use connection pooling. When the MSSQL
server is rebooting, any requests by web2py will predictably return an error
about not being able to connect, but when the MSSQL server becomes available
again, web2py starts working again, no restart required. So I suspe
The default, if not specified is always None (NULL). Some DBAs will argue
for and against storing NULL values in a database, but I personally use
NULLs simply because they allow more flexibility. For example, say you have
a text field in one of your tables. This text field should be set by the
I did something similar to demonstrate common vulnerabilities, such as SQL
injection and changing hidden values in forms before submission. It was
really tough to make this app with web2py, as I had to skirt around most of
the framework to make it happen. This is a GOOD THING though. I learned a
Since I want to make sure that my application is as secure as possible, I
wanted to force all traffic to use HTTPS. At the bottom of my db.py, I have
this:
FORCED SSL #
session.secure()
if not request.is_https:
redirect('https://%s/%s' % (request.env.http_host, reque
a jQuery version of web2py's HTML helpersvery nice. I use jQuery
heavily, but I rarely ever "create" DOM elements using JavaScript. Either I
wrap hidden elements for later with "display: none;" or I just replace with
HTML from an AJAX callback. But if creating DOM elements in JavaScript
on-
I just tried the following by running web2py -S app -M -R my_script.py
(since this is how I run the script from cron):
from gluon.settings import global_settings
print global_settings
The cronjob value seems to always be False and I can't figure out how this
actually gets set to True. Any ideas
I'm calling from external cron, which is why this option is not getting set.
So all I have to do is add --cronjob to my cron line and it's all set.
Alternatively, while trying to figure this problem out, I noticed that
global_settings.cmd_options.shell will return a string if run from the
shell
oogle Groups is giving me a lot of trouble. This is the 3rd time
I've tried to post this, so I apologize if this shows up several
times.
On Jul 1, 11:46 am, Ross Peoples wrote:
> I'm calling from external cron, which is why this option is not getting set.
> So all I have to do is add
Apple,
When dealing with Google Code, it is expected that you use Mercurial to get
the code rather than waiting on the author to provide a direct download
link. You should use:
hg clone https://web2py-estore.googlecode.com/hg/ web2py-estore
Or if you just want to browse the code:
https://code
I have tried it. I like it better than Facebook, especially because of its
commitment to privacy. The circles feature is great. I think most people
don't friend their bosses, coworkers, and business acquaintances of Facebook
because they don't want their personal lives to be exposed to those peo
Free, unlimited storage of photos as large as 2048x2048 and videos under 15
in length is pretty awesome. This will be more than enough for most people.
@sebastian:
The point of the circles is so that you can share information with only
certain groups if you want. So you could be "friends" with
You're doing it right, but there are a couple of things to keep in mind.
Using $.post(url, {input_n: input_number}); is easier than using $.ajax, but
that's merely preference. The other thing you should know is that if a
web2py ticket is generated during an AJAX call, you will not know about it.
Going from web2py -> JavaScript is easy:
{{=var}}
However, going from JavaScript -> web2py requires an AJAX call. Since
JavaScript is run on the user's machine and not the web server, the two
machines have to communicate somehow, which is where AJAX comes in. You
should also know that things i
This will be my second public plugin release. I will put it up on BitBucket
soon, but for now, I thought I would introduce a new plugin I've been
working on. Sometimes you just need a WYSIWYG editor. This plugin integrates
CKEditor into web2py. It acts much like the Auth object in its usage. For
Ok, I have posted the source code on BitBucket. I don't have time to put any
documentation up there yet other than what's here in this thread. I will
update with more documentation hopefully this weekend when I have time.
Until then, enjoy!
https://bitbucket.org/PhreeStyle/web2py_ckeditor
I think because when a table is hidden behind a tab that it can't resize
what's not visible. So if you listen for the tab change event and force
datatables to refresh after a tab change, that should solve the problem.
I'm pretty sure you have to set mail.settings.tls = True for web2py to start
a secured connection with a mail server.
Oh, and looking at the code, it doesn't want to start a secured session
unless mail.settings.login is set. Not sure why this is. Maybe because mail
servers typically don't allow anonymous logins anymore.
I know it's on the radar, but I don't know to what extent. I am guessing
that it won't be an immediate priority until operating systems like Mac OS
X, Ubuntu, and RHEL/CentOS start shipping Python3 by default. Python3, being
the next-generation of Python as it were, is still new and these operat
The less your models do, the better in general. When a page comes in, web2py
does it's thing, then executes ALL models, then executes the appropriate
controller->function, then the function executes the view.
However, with newer versions of web2py, there are conditional models, so in
your model
Quick correction, set:
mail.settings.login = None
Setting this to False will probably cause an error, as it specifically
checks for None, and assumes the value is a string otherwise.
I see this a lot when there is a problem in the view. If this is the case,
then you'll see a line number on the error, which if you scroll all the way
down to the bottom on the ticket, you will see the view code converted to
Python code and you will see which line it is talking about in the view
I'd be interested to see what something like 2to3 would say about web2py's
compatibility with Python3:
http://docs.python.org/library/2to3.html
http://diveintopython3.org/porting-code-to-python-3-with-2to3.html
I know that Python 2.5 is the officially supported Python version of web2py,
but I've been coding all of my stuff with the assumption that this will
eventually change to Python 2.6, or even 2.7. I have applications running on
both 2.6 and 2.7 in production. But since I'm using Ubuntu 10.04 Serve
After so many attempts, admin should block the IP address attempting to gain
access. Further, an invalid password, should require a 5 second timeout.
After maybe 5 attempts, block the IP. The DenyHosts script that is used to
prevent SSH brute force attacks does the same thing basically.
And maybe we should require some level of complexity on the admin passwords.
The other day I set my dev machine's password to a single letter. I think
that could be a potential security problem :)
If your controller doesn't have an index function at all, you could add
something like this to one of your models:
if request.controller = 'mycontroller' and request.function == 'index':
request.function = 'myfunction'
So that if someone tries to go to /mycontroller or /mycontroller/index, t
Well, as far as the delay and the blocking of the IP, I put this together,
which would go somewhere in the /admin/models/access.py file, but I'd like
to get some comments, as I've never coded this type of thing before so I'd
like to know if there's a better way to code it, and what problems it m
One quick change: In failed_login(), the line:
times_denied = 0
Should really be:
times_denied = 1
I know that web2py has a nice JSON-RPC Server built into it, but if I wanted
two web2py applications to talk to each other, first would JSON-RPC be a
good choice? And if so, does web2py have a built-in JSON-RPC client, or
would I have to easy_install python-cjson and jsonrpclib?
Well, support for Python 2.4 was officially dropped with version 1.96.1, so
I don't think 'with' will be a problem. You're right about the cache
invalidation. Nice catch!
it looks correct, and shouldn't make any difference as long as indentation
is correct. Maybe try lowercasing the domain names. Also, do you have any
other routing options besides this one?
I have created Issue 336 with a patch that adds brute-force attack
protection to the admin application using the input gathered from everyone:
http://code.google.com/p/web2py/issues/detail?id=336
This does NOT add a password complexity requirement, as it seems this is a
touchy issue at the mome
Very true, we would need to create another branch of web2py, do the initial
conversion to Python 3, then try to maintain it, coding updates and new
features twice: once for Python 2.x and once again for Python 3.x, since the
two have different coding requirements. Then both would need to be test
401 - 500 of 573 matches
Mail list logo