I'm trying to use pytest (instead of unittest) to do unit testing for a
web2py app. I've written a script (attached: runtest.py) to launch py.test,
which then finds and executes my test files. I run this launcher script in
a web2py environment like this:
python ~/web/web2py/web2py.py -S
On Wednesday, December 5, 2012 4:02:51 PM UTC-5, viniciusban wrote:
Hi monotasker.
I'm starting to run something like that and I'm giving
gluon/contrib/webclient.py a try.
I intend to prepare an environment to allow running tests using both
unittest2 or pytest.
I think next week
I'm finding it awkward to insert uploaded images into markmin-formatted
text because the upload filenames aren't memorable. I see the point of the
file renaming. But I think I need some kind of widget that displays the
images in my upload library and will automatically get and insert the
October 2012 13:54:49 UTC-5, monotasker wrote:
I'm finding it awkward to insert uploaded images into markmin-formatted
text because the upload filenames aren't memorable. I see the point of the
file renaming. But I think I need some kind of widget that displays the
images in my upload library
I'm trying to set up unit tests and run into this error during the creation
of the test db (using testrunner.py). I've looked at the code of this
method in gluon.dal, but I really don't know enough about csv importing to
know how to debug the error. So any help would be much appreciated.
Here
Thanks very much. I just sent the files to you by email.
Ian
On Thursday, October 4, 2012 8:11:23 AM UTC-4, Massimo Di Pierro wrote:
If you send me the file and the models I will try it.
On Thursday, 4 October 2012 01:16:17 UTC-5, monotasker wrote:
I'm trying to set up unit tests and run
I'm not sure how this would work with the current web2py framework (which
uses static css), but a css pre-processing system like LESS makes the
application of framework classes to your custom html trivial. Twitter
Bootstrap (like many of the other css frameworks out there) provides its
styles
Has anyone looked at the speed differences between operations performed
with a Storage object and the equivalent object with a dictionary? I wonder
how these would compare?
bob = MyStorageObject.name
bob = MyDictionary['name']
I suspect that the difference with one lookup would be trivial,
One thing I'm trying out right now is (a) writing all of my business logic
in module files; (b) breaking up that logic into small-ish classes that
each seem to have with around 5-10 methods each; (c) injecting my
dependencies as much as possible into the class in the __init__ method and
then
suspects -- number of file and
image downloads, resolution of image files, server optimization, etc. Good
to know.
Ian
On Thursday, October 4, 2012 3:52:24 PM UTC-4, Niphlod wrote:
Not directed only to monotasker: aren't all you tired of reading
benchmarks when the sourcecode
of update_or_insert is not specified the following
named arguments (tlast_right=time_last_rightm,...) are used to build a
condition dict.
On Sunday, 30 September 2012 20:59:41 UTC-5, monotasker wrote:
In the manual section on update_or_insert() the examples only touch on a
situation where
In the manual section on update_or_insert() the examples only touch on a
situation where one field/value is given as the matching condition. I'm
wondering what syntax needs to be used if we want to match values on more
than one field. Extrapolating from the manual example, can I do this?
My site hosted on webfaction started returning a 500 internal server error
this morning and it looks like it's choking on my routing. What's strange
is that it was all working (with no changes made) for quite a while prior
to this. My server log shows this at the start of the problem:
[Thu Sep
Sorry, found the problem. I was just missing a comma in the list of tuples
(sheepish grin).
On Thursday, September 27, 2012 11:26:51 AM UTC-4, monotasker wrote:
My site hosted on webfaction started returning a 500 internal server error
this morning and it looks like it's choking on my
Ok, this reveals the depth of my ignorance. The logging.example.conf file
is set up to output logs to console. What is that? If I'm trying to log
things running on a remote server, where do I access this console?
Thanks.
--
output + standard error, you see it only if you're running on
terminal (unix, mac) or Dos prompt (Windows). That's why usually
production apps log something directly to a file or to a database.
On Thursday, September 20, 2012 11:20:10 PM UTC+2, monotasker wrote:
Ok, this reveals the depth of my
Following on an earlier question of mine, I'm trying to arrange for
persistent data (per user) by writing session data to the db. The trick I'm
stumbling over is how to make sure that the session data that is stored
always represents the end of the most recent user session. It seems to me
like
Ok, so would I then just have python read the contents of the file and then
unpickle the whole as a single string?
Ian
On Friday, September 14, 2012 2:52:33 PM UTC-4, Niphlod wrote:
it's not hashed, it's pickled.
On Friday, September 14, 2012 7:40:47 PM UTC+2, monotasker wrote:
Following
I'm using github for open-source development of some web2py apps and want
to make sure I'm not exposing any data that would be a security risk. As
far as I can tell, the sensitive pieces of data in a standard app would be:
- email account information (by default in db.py)
- any recaptcha keys
I'm having trouble on Webfaction with web2py not finding the pytz module,
even though it is found fine in my local environment. I've
already installed the module using easy_install at myname/lib/python2.7 (as
per Webfaction instructions), and I've confirmed that I can import it from
the
the module?
On Mon, Sep 10, 2012 at 4:52 PM, monotasker scot...@gmail.comjavascript:
wrote:
I'm having trouble on Webfaction with web2py not finding the pytz module,
even though it is found fine in my local environment. I've
already installed the module using easy_install at myname/lib
Aha! That did it. For the record, on Webfaction an application server is
restarted with $HOME/webapps/app_name/apache2/bin/restart
Thanks for pointing me in the right direction. I'm obviously going to have
to learn a lot more about the server end of things :) But I really
appreciate the help.
, September 1, 2012 12:38:47 PM UTC-4, monotasker wrote:
I'd like my app to preserve a state for each user for 24-hours, even if
s/he
- logs out and back in
- switches browsers
- switches IP (i.e., uses a different device)
What would be the best way to do this?
I'm already using the session
Perfect. Thanks for providing the snippet. I haven't used the cache methods
yet, and this saves me a lot of time.
Ian
On Sunday, September 2, 2012 2:28:14 AM UTC-4, rochacbruno wrote:
I think you can use cache.
user_data = cache.ram(user_data_%s % auth.user_id, lambda :
dict(field=value,
I'd like my app to preserve a state for each user for 24-hours, even if
s/he
- logs out and back in
- switches browsers
- switches IP (i.e., uses a different device)
What would be the best way to do this?
I'm already using the session object to preserve state in the app. So I was
thinking
Am I right that the Markmin syntax still doesn't implement nested lists?
Has anyone found an easy workaround for this? I'm building a presentation
(slideshow) component and would like to use Markmin, but I need more depth
than a flat list.
Thanks.
, Massimo Di Pierro wrote:
Looks like there is a patch pending about this.
On Wednesday, 4 July 2012 09:58:47 UTC-5, monotasker wrote:I will review
it asap.
Am I right that the Markmin syntax still doesn't implement nested lists?
Has anyone found an easy workaround for this? I'm building
Do you know how to set the admin password? I tried entering my webfaction
dashboard password but it didn't work.
Ian
On Wednesday, July 4, 2012 11:42:24 AM UTC-4, kokoyo wrote:
hi, i have been using webfaction, you can do these step to get w2py admin:
on the left menu: Domains/Website
I'd like to be able to bind a jquery function to a div that is the
container for a web2py component, so that when the component content is
updated by the controller the jquery function is triggered. But I'm not
sure whether there is a stock event that would cover the component refresh
(I don't
('#mycomponent').ajaxSuccess(function(e, xhr, settings) {
if (settings.url == '/default/mycomponent.load') {
jQuery(this).doSomething();
};
});
});
/script
Anthony
On Thursday, June 28, 2012 3:53:14 PM UTC-4, monotasker wrote:
I'd like to be able to bind a jquery function to a div
I have a db field that holds a regular expression (one unique regex for
each row in the table). Another row in the table
(db.steps.readable_response) lists sample strings that should satisfy the
regex. I'm trying to create a custom validator that tests the regular
expression against the sample
The :eval method of the ajax() function requires that there is a form field
holding the value to be sent by ajax. So in your view you could just
include in INPUT() helper somewhere on the page and hide it via css. Then
when the remove row link is clicked, your could use js to:
- set the input
Thanks, Anthony, and sorry for spreading misinformation. I just re-read the
book section and found where I'd been confused. So it looks like Johann
simply needs something like this for each row in his view:
a href='ajax('controller_function/{{=row.id}}', [], ':eval')X/a
Then to refresh the
ΟΚ, that's very helpful. Thanks once again.
On Friday, June 1, 2012 1:14:08 PM UTC-4, Anthony wrote:
a href='ajax('controller_function/{{=row.id}}', [], ':eval')X/a
That would have to be _onclick, not _href, and you'd want to add something
like ; return false at the end to prevent the
I'm trying to use the recipe on p. 142 of the web2py cookbook (Uploading
files using a LOADed component) and I'm wondering if there's an error in
the replacement web2py_trap_form function. Line 4 of the replacement
provides an 'if' condition with no statements following (no { } at all). Is
I'm working on a js file that resides in appname/static/js/ but for some
reason it seems to be cached. When I refresh the browser (even if I restart
the local web2py server) the page continues to load an old version. I
develop largely with custom modules, and those files are refreshing just
Yes, that was it. Thanks.
Ian
On Tuesday, May 8, 2012 1:34:30 PM UTC-4, Anthony wrote:
It's probably being cached by the browser, so you may need to clear the
browser cache (simply refreshing the page won't do it).
Anthony
On Tuesday, May 8, 2012 1:11:51 PM UTC-4, monotasker wrote:
I'm
Thanks very much for doing this. Have you considered putting it in a github
repo so that it's a bit easier to use and fork?
Ian
On Sunday, May 15, 2011 5:44:42 PM UTC-4, pancurster wrote:
Hi,
I was looking today for vim syntax for web2py templates but I didn't
find it. So I make my own.
I want to float a proposal for plugin infrastructure that I'd love to see
made part of the web2py core. It takes a bit of explanation, so bear with
the long post.
I'm starting to find that the syncing issue is a major one with the
(otherwise great) plugin infrastructure. I have a growing
I'm trying to set up unit testing using testRunner.py as laid out here:
http://www.web2pyslices.com/slice/show/1465/unittesting-doctesting-and-userinterface-testing
. When I run the tests I'm getting this error:
AttributeError: 'thread._local' object has no attribute 'app'
This is fixed if I
5, 2012 6:53:36 PM UTC-4, monotasker wrote:
I'm trying to set up unit testing using testRunner.py as laid out here:
http://www.web2pyslices.com/slice/show/1465/unittesting-doctesting-and-userinterface-testing
. When I run the tests I'm getting this error:
AttributeError: 'thread._local
I ran into analogous problems with sqlite on fluxflex. If you have a
working local version of the app, would it be simplest to just
re-initialize the fluxflex repo (and mysql db) and then push a fresh
version of the app to the fluxflex repo?
I have found that, in general, it doesn't work very
I'm coming at things backwards (as usual) and just now looking at writing
unit tests for a couple of apps I'm working on. The most recent forum
discussion of unit testing in general seems to be about a year old and
references an appliance in web2py_utils as the most complete solution to
that
No, I hadn't seen that. Thanks Anthony.
Ian
On Tuesday, April 3, 2012 4:56:54 PM UTC-4, Anthony wrote:
I'm coming at things backwards (as usual) and just now looking at writing
unit tests for a couple of apps I'm working on. The most recent forum
discussion of unit testing in general seems
Yes, and my frustration with the push toward node.js is that it seems to
come in part from the I learned js for webdev and I don't want to bother
learning another language impulse. I also think that's part of the
motivation behind pushing everything client-side (i.e. into the browser).
But I
fields. That's probably why it's not
documented in the book.
Anthony
On Saturday, March 31, 2012 12:25:50 PM UTC-4, monotasker wrote:
Maybe it's just me, but one of the things I find most confusing as I work
with web2py is figuring out what properties and methods each object has
I'm not convinced that the stats you cite about Python are statistically
meaningful over a one-year period (2.45% decline?). But it seems to me that
on the web the key issue is browser integration. JavaScript is the default
language of the web because browsers all interpret it internally. PHP,
own place, and
remember one of the keys to Web2Py is DRY.
On Friday, March 23, 2012 3:34:27 PM UTC-7, monotasker wrote:
Right. For something as simple as an RSS reader I see your point. But for
more complex applications (I'm working on a web-based educational game for
language instruction
turning into
another Pyjamas. Pyjamas has it's place, Web2Py has it's own place, and
remember one of the keys to Web2Py is DRY.
On Friday, March 23, 2012 3:34:27 PM UTC-7, monotasker wrote:
Right. For something as simple as an RSS reader I see your point. But for
more complex applications
As I suggested to Derek, I think I've caused some confusion by not being
clearer in my original question. I'm not thinking about client-only
web-apps. I'm thinking about locally installed apps that use an html5
front-end. This is what win8 is promoting, and that's also the thrust of
Mozilla's
Yes, I think web2py can already produce a self-contained local app running
from the rocket server. At least I think there was a recipe for that in the
last edition of the book (I haven't looked in a while).
The issue of web2py being 'thick' for the purpose is very much what I was
wondering
OK. That makes sense. A bit frustrating, though, that the Mozilla apps are
limited to js. I guess that's why I keep developing for the web--it's still
the only truly cross-platform environment with any kind of muscle in the
back end.
On Saturday, March 24, 2012 3:49:36 PM UTC-4, Anthony wrote:
I think I understand a bit what you mean about not feeling like you
understand the guts of web2py at first. The book wants to walk you
through app-building before introducing you to much of the core, even
conceptually. I think this is actually a good pedagogical move for lots of
people, but
I may be off target but I just recently noticed the .as_dict() method for
rows objects. This converts the rows object to a regular dict (instead of a
gluon storage object) which can be stored in session or cache (i.e., it's
picklable). If you need the query (not the resulting rows object) to be
I've been struck by the huge push lately for 'html5 apps' as a (partly)
cross-platform approach to mobile and desktop development. Now win8 is
integrating html5+js heafily into the desktop and the Mozilla app project
is pushing in a similar direction. In many ways I think it makes sense (I
from the network.
But what would be better is to rewrite it so it will retrieve the rss
feeds directly. Then you don't need the web2py piece at all.
And that's my point.
On Friday, March 23, 2012 2:53:15 PM UTC-7, monotasker wrote:
I've been struck by the huge push lately for 'html5 apps
This makes frameworks like Twitter Bootstrap even more attractive if they
get us part of the way there.
On Tuesday, March 20, 2012 8:14:26 AM UTC-4, rochacbruno wrote:
Useful information, worth reading it!
http://www.w3.org/TR/mwabp/
--
Bruno Rocha
[http://rochacbruno.com.br]
I had a nice query set up and working that looked for any match between
items in a list and records in a list-reference field:
catXtags = [2,4,6,7,9]
curr_loc.id = 6
db((db.paths.tags.contains(catXtags))
(db.paths.locations.contains(curr_loc.id))
I changed db.paths.tags to be a virtual
that rows.
On Thu, Mar 15, 2012 at 5:55 PM, monotasker wrote:
I had a nice query set up and working that looked for any match between
items in a list and records in a list-reference field:
catXtags = [2,4,6,7,9]
curr_loc.id = 6
db((db.paths.tags.contains(catXtags
In digging through the discussions here I've come across two auth methods
that allow for checking a user's authorization:
auth.is_logged_in()
and
auth.has_permission()
These are really useful, but aren't documented in the web2py book (They're
used a couple of times in other recipes, but
it
carefully.
http://web2py.com/books/default/chapter/29/9#Authorization-and-CRUD
Your is_member =
auth.has_membership(group_id, user_id, role)
*
*
*
*
Does it help?
Richard
On Mon, Mar 12, 2012 at 11:34 AM, monotasker wrote:
In digging through the discussions here I've come across
I want each of my app menu items to have a distinct class to ease theming
(I'm using background images to provide icons in place of text). It looks
like the MENU helper doesn't allow _class arguments in the items in
response.menu. So I can just modify the MENU helper, but am I missing some
way
That does it. Great! Was this in the book somewhere?
Ian
On Monday, March 12, 2012 2:08:18 PM UTC-4, Martin.Mulone wrote:
I think you can do:
(T('my item'), True, A('My item', _href=URL('default', 'index'), _class =
'my_item_class', id = 'my_item_id'), []),
2012/3/12 monotasker scotti
Can you post the parts of your css code that aren't working?
Ian
On Sunday, March 11, 2012 7:39:42 AM UTC-4, frasse wrote:
Hi
I like to use my custom css and add it to my application base.css mess
my application. I have remove base.css and move classes .flash
and .error to my custom
id=mellan
{{include}}
/div
/div
/body
/html
--
/F
On 12 mar, 19:43, monotasker scotti...@gmail.com wrote:
Can you post the parts of your css code that aren't working?
Ian
On Sunday, March 11
/index.load,page)
Anthony
On Wednesday, February 22, 2012 5:18:15 PM UTC-5, monotasker wrote:
I'm using an svg image as a navigation map, with areas that can be
clicked. I've got the interactivity working via an external javascript, but
when I try to call web2py_component() I get an error telling
I'm using an svg image as a navigation map, with areas that can be clicked.
I've got the interactivity working via an external javascript, but when I
try to call web2py_component() I get an error telling me that
web2py_component is not defined. I assumed that I could call it since this
script
I haven't been able to figure this out: I want to use the format
representation defined in my db model to represent the rows in a list of
query results. In other words, I'd like to be able to do something like
this:
rowlist = []
q = db(db.mytable.id 0).select()
for r in q:
Is the problem with passing db to the module function? I got tripped up
until I realized that current objects needed to be retrieved *within the
function* (i.e., after def myindex()). Here you seem to be passing the
current objects as arguments to the function. I don't know whether that
works
OK, I'm trying to create a generic controller function that will list the
rows in a table, representing each row using a flexible format that can be
user-defined (this is all for a plugin to provide a list-and-edit-records
widget).
My testing model includes this table definition:
Thank you sooo much! I never would have figured that out. I really
appreciate your help.
Ian
I'm using a lot of custom plugins to allow re-use of code across several of
my web2py apps. But since the plugins are in a state of constant updating,
it's getting to be a pain to keep them all in sync. I use git for version
control (one repo for each app) and for deployment (on Fluxflex). I've
I suppose I could! But I'd like to understand the underlying issue -- why
the form seems to submit blank when the component loads (hence the else
condition firing).
I'm continuing to work in fits and starts on my ajaxselect plugin (I'll
post an update and bugfix soon, hopefully with a proper demo). In the
process, I came across the ListWidget method in sqlhtml. It's quite a nice
way to implement multi-reference field. But it's not documented in the 4th
That's good news. I'm a bit confused, though, since it doesn't seem to be
the default widget for list:reference fields, which are presented by
default in a multiple select widget (or does list:reference not fall under
list:type?).
Also, the list widget isn't included in the list of available
Ah. Now I understand. Thanks a lot for explaining. Sometimes it's the
basic structural things I miss!
Great. Thanks again. I really appreciate your help.
OK, in that case maybe the book example should be changed since the code
doesn't quite work as given on p. 331.
In a few different places I'm finding that a SQLFORM form loaded in a
component is submitted automatically when the component first loads. It
doesn't pass the if form.process() test, and it doesn't throw errors, so I
get whatever the else condition is in the form submission process. Does
I include a comments plugin in my main view:
{{=plugin_comments()}}
That plugin calls this controller:
#checks to see whether hidden 'honeypot' field has any text in it
(presumably placed there by a bot)
def checkfilter(form):
form.vars.filter = request.vars.filter
if form.vars.filter
Thanks Benjamin. That sounds quite simple.
Thanks. I think I'll try the honeypot (hidden field) approach and see how
successful it is.
I'm trying to add a hidden form to a SQLFORM using the sample code on p.
331 of the 4th edition book (pdf):
form.vars.a = request.vars.a
form = SQLFORM(..., hidden=dict(a='b'))
When I submit the form, though, I get an error because I'm calling the
variable 'form' before assignment. If I
I'm about to deploy a simple blog platform for myself and have implemented
comments using something very much like Massimo's example in the components
chapter of the web2py book. What I'm wondering about, though, is spam
control. At the moment I think I'm just going to activate recaptcha for
Yeah, I'm not sure either. And I'm not sure it matters as much as having
good interactions going forward.
Well, I heard back about plugin development and it turns out that plugins
can only be written in Java. That rules me out. I'm still trying to get my
mind around Python. But the plugin API is available at
http://confluence.jetbrains.net/display/IDEADEV/PluginDevelopment if you or
anyone else
In case anyone else runs into a similar problem, it turns out that I was
handling DAL and Crud improperly in the modules I was trying to import. For
db, I added this in db.py right after the initial definition of db:
current.db = db
Then in my model, in any function that used db, I could just
I'm moving a whole bunch of (perfectly functional) business logic from
model files to custom modules. But when I try to import the modules in my
controllers custom_import is throwing an error. Here's the traceback:
File /home/ian/web2py/gluon/restricted.py, line 204, in restricted
exec
Sorry for the delayed response. I'm going to have to ask them about docs. I
haven't found them in the obvious places.
Well, I'd really like to use pydev, but I just find that it's too resource
intensive. I do a lot of work on a souped up netbook and eclipse *really*
churns. PyCharm is a Java application too, but it positively sings beside
eclipse. I'm generally really committed to open source (I eat sleep and
I had an email exchange over the last couple of days with a developer at
Jetbrains who works on PyCharm. The bad news is they've chosen not to work
on web2py integration any time soon. The even worse news (from my
perspective) is that they seem to have a very negative impression of the
web2py
I have a function in which I have two table names 'db.A' and 'db.B'. There
is a field in db.A that links to the id field of db.B. But I don't know
what that linking field is called in db.A. Is there a way to find this out
programmatically?
(This is the last nut to crack before I can release
Great! Thanks!
as
selectable options. You can download or clone the file from the github
repository: https://github.com/monotasker/plugin_ajaxselect
In one sense this is a duplication of the select_or_add module that has
been available on web2py slices. Under the hood, though, they are quite
different. My ajaxselect
I forgot to add that the one dependency of this plugin is jquery-ui (for
the dialog). I'd be interested to know what people think of this. Should I
write a little dialog script of my own so that there are no external
dependencies, or should I avoid reinventing the wheel and use jquery-ui?
Thanks, Bruno. I've been writing this for an app that isn't finished yet,
but I'll try to at least get some screenshots up soon.
And thanks, by the way, for all your coaching as I've been learning web2py.
I need to add a thanks section to the README.
OK, I've isolated the issue. Again, I've placed one of the form fields in a
LOAD wrapper. The POST action for the form does send a value for this field
(according to Firebug), but web2py doesn't receive a value for it. Printing
the form.error that is thrown results in this:
Storage {'author':
I succeeded in removing the DIV wrapper from the select widget, but that
didn't solve the problem. So I've got a perfectly formed HTML form, sent
properly by POST, but this one field isn't being processed! AARGH!
I voted too. +1
This is certainly my experience. Coming to programming backwards through
web-design, I stumbled into JavaScript first, then PHP. When I started
coding in Python it was like a breath of fresh air.
1 - 100 of 173 matches
Mail list logo