Re: [web2py] Form not processed on first submit

2012-06-27 Thread Johann Spies
On 27 June 2012 17:51, Anthony  wrote:

> Perhaps form.process() is failing the first time because the _formkey in
> the session isn't matching for some reason (don't know why, though).
>

I am definitely going to investigate this possibility.  The previous page
was a page with components with more than one form/grid on it. I will
report back.

Thanks.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


Re: [web2py] Routes - simple requirement, but how??

2012-06-27 Thread Jonathan Lundell
On Jun 27, 2012, at 10:33 PM, Anthony wrote:
> It is usually a good thing that we have choices,  but not choices of blind 
> alleys.  IMO  there should be one comprehensive way for web2py to do routes. 
> If regex patterns are the only way to solve all situations then so be it - we 
> should just get used to it.  All our efforts can then go in building up a 
> comprehensive list of recipes and off-the-shelf regex patterns that we can 
> all just use.
> 
> The parameter-based system already exists. Can't we keep it and still build 
> up a list of regex recipes? I'm not sure, but I think some of the things the 
> router handles might get a little hairy with regexes (particularly if 
> combined). I think it works well to have any easy to use router system that 
> handles the most common cases, and then a more advanced (but harder to use) 
> system for the trickier cases.
>  
> The fact that there doesn't seem to be a clear answer to my easy question 
> already says it all,  but the idea of renaming plugin_wiki as a work-around 
> puts the issue beyond doubt  :)
> 
> Is plugin_wiki the core of your site? If so, perhaps you could use the router 
> and make plugin_wiki the default controller (so it is removed from the URL 
> altogether).
> 

A controller-name map (or perhaps some generalization of that concept) would be 
relatively straightforward in the parametric router. Not sure how generally 
useful it'd be.

Or give the plugin controller the idea of an alias.

Re: [web2py] Routes - simple requirement, but how??

2012-06-27 Thread Anthony

>
> It is usually a good thing that we have choices,  but not choices of blind 
> alleys.  IMO  there should be one comprehensive way for web2py to do 
> routes. If regex patterns are the only way to solve all situations then so 
> be it - we should just get used to it.  All our efforts can then go in 
> building up a comprehensive list of recipes and off-the-shelf regex 
> patterns that we can all just use.
>

The parameter-based system already exists. Can't we keep it and still build 
up a list of regex recipes? I'm not sure, but I think some of the things 
the router handles might get a little hairy with regexes (particularly if 
combined). I think it works well to have any easy to use router system that 
handles the most common cases, and then a more advanced (but harder to use) 
system for the trickier cases.
 

> The fact that there doesn't seem to be a clear answer to my easy question 
> already says it all,  but the idea of renaming plugin_wiki as a work-around 
> puts the issue beyond doubt  :)
>

Is plugin_wiki the core of your site? If so, perhaps you could use the 
router and make plugin_wiki the default controller (so it is removed from 
the URL altogether).

Anthony


Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-27 Thread Michael Toomim
This is all a great unearthing of the Mystery of Transactions. Thanks for 
the investigation, Doug.

This was difficult for me to learn when I got into web2py as well. Perhaps 
we could write up all this knowledge somewhere, now that you're figuring it 
out?

Can we have a section on Transactions in the book, or somewhere?


Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-27 Thread Jonathan Lundell
On Jun 27, 2012, at 9:08 PM, Anthony wrote:
> SQLite is a file-based database, so has to have more course locking than a 
> typical client/server database. Other databases have "select for update" 
> functionality, which allows you to select a set of records and lock them. 
> web2py actually supports this, via .select(..., for_update=True).
> 

The SQLite adapter simulates select for update by wrapping the select+update in 
a transaction. Not too efficient, since it has to lock the entire database, but 
it'll do it.

Re: [web2py] Quoting reserved words in DAL

2012-06-27 Thread Michael Toomim
Ok, here's one step closer to a fix!

This is what had to be manually changed in order to quote the names of 
tables/fields to load a postgres database into MySQL.

This won't work for other databases. And this only works for importing a 
database—table creation, with foreign keys, and insert statements. Nothing else 
(e.g. selects, updates) was tested. And we had to guide it manually through the 
table creation, to get foreign key constraints satisfied in the right order.

But this will show an interested developer exactly where to begin fixing the 
code for this bug... that seems to be biting a few of us.

On Jun 20, 2012, at 1:19 PM, Rene Dohmen wrote:

> I'm having the same problem:
> https://groups.google.com/d/msg/web2py/hCsxVaDLfT4/K6UMbG5p5uAJ
> 
> 
> On Mon, Jun 18, 2012 at 9:30 AM, Michael Toomim  wrote:
> I just got bit by the reserved-word problem:
> https://groups.google.com/d/msg/web2py/aSPtD_mGXdM/c7et_2l_54wJ
> 
> I am trying to port a postgres database to a friend's mysql database, but we 
> are stuck because the DAL does not quote identifiers.
> 
> This problem has been discussed a fair amount:
> https://groups.google.com/d/msg/web2py/QKktETHk3yo/Mwm3D-JhNmAJ
> 
> ...and it seems all we need to do is add some quoting mechanisms to the DAL. 
> In postgresql you surround names with "quotes" and in mysql you use 
> `backticks`.
> 
> Does anyone have ideas for what to do?
> 
> -- 

On Jun 20, 2012, at 1:19 PM, Rene Dohmen wrote:I'm having the same problem:https://groups.google.com/d/msg/web2py/hCsxVaDLfT4/K6UMbG5p5uAJ

On Mon, Jun 18, 2012 at 9:30 AM, Michael Toomim  wrote:

I just got bit by the reserved-word problem:https://groups.google.com/d/msg/web2py/aSPtD_mGXdM/c7et_2l_54wJ

I am trying to port a postgres database to a friend's mysql database, but we are stuck because the DAL does not quote identifiers.This problem has been discussed a fair amount:

https://groups.google.com/d/msg/web2py/QKktETHk3yo/Mwm3D-JhNmAJ...and it seems all we need to do is add some quoting mechanisms to the DAL. In postgresql you surround names with "quotes" and in mysql you use `backticks`.

Does anyone have ideas for what to do?


-- 




dal.py.changes
Description: Binary data


Re: [web2py] Re: Best practice using scheduler as a task queue?

2012-06-27 Thread Michael Toomim
:)

Because I'm a perfectionist, and I want other developers to be able to 
install my system by just unzipping the code, running ./serve, and have it 
just work. So I want to use the built-in webserver and scheduler. There's 
no reason they shouldn't be able to manage these race conditions correctly.

I'm super excited that the Ctrl-C bug was fixed!

Your idea of putting the initializer in the @cron reboot is very appealing! 
I will think about this and see if I can come up with a nice solution with 
it. Ideally I could re-use this "daemon_task" setup for other projects as 
well, as I find it to be a quite common scenario. I understand you do not 
find it to be common. I am not sure why we have different experiences.

Would portalocker be a good thing to use for this situation? I would like 
to be cross-platform instead of relying on postgres locks.

On Wednesday, June 27, 2012 12:37:27 PM UTC-7, Niphlod wrote:
>
> uhm. why not having them started with systemd or upstart or 
> supervisord ?
>
> Scheduler is "by design" allowed to run with multiple instances (to 
> process a longer queue you may want to start more of them), but if you're 
> really loosing money why didn't you rely on that services to be sure that 
> there's only one instance running?
> There are a lot of nice implementations out there and the one I 
> mentioned are pretty much "state-of-the-art" :D (while contributing to fix 
> current issues)
>
> BTW: - "responding to ctrl+c" fixed in trunk recently 
>- "os messed up maybe" require you to check the os, python 
> programs can't be omniscient :D
>- "messy developers", no easy fix for that too 
>
>
> On Wednesday, June 27, 2012 9:18:06 PM UTC+2, Michael Toomim wrote:
>>
>> The problem with terminating the processes is:
>>   • sometimes they don't respond to control-c, and need a kill -9
>>   • or sometimes that doesn't work, maybe the os is messed up
>>   • or sometimes the developer might run two instances simultaneously, 
>> forgetting that one was already running
>>
>> You're right that usually I can shut them both down with control-c, but I 
>> need a safeguard. My application spends money on mechanical turk and I'll 
>> spend erroneous money and upset my users if it goes wrong by accident.
>>
>> On Wednesday, June 27, 2012 12:56:52 AM UTC-7, Niphlod wrote:
>>>
>>> BTW: I'm pretty sure that when you say "scheduler should be terminated 
>>> alongside web2py" you're not perfectly grasping how webdevelopment in 
>>> production works. If you're using "standalone" versions, i.e. not mounted 
>>> on a webserver, you can start your instances as web2py -a mypassword & 
>>> web2py -K myapp and I'm pretty sure when hitting ctrl+c both will shutdown. 
>>>
>>

Re: [web2py] web2py ported to bottle, flask, pyramid, tornado, wsgiref

2012-06-27 Thread Steve Witham


On Tuesday, March 13, 2012 6:48:04 PM UTC-4, nekrox wrote:
>
> This week i try to make my tiny version of web2py with werkzeug.
>
nekrox, how far did you get with that? 


Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-27 Thread Anthony
SQLite is a file-based database, so has to have more course locking than a 
typical client/server database. Other databases have "select for update" 
functionality, which allows you to select a set of records and lock them. 
web2py actually supports this, via .select(..., for_update=True).

Anyway, you might be better off looking into using the 
scheduler,
 
or a third-party task queue like Celery  (a 
web2py Celery plugin  was started 
at some point, though not sure it is complete).

Anthony
 

> Ok, so if (and I'm looking for a more general that just SQLite answer 
> here), I want to get exclusive access to the DB, I should first do a 
> 'dummy' change. 
>
> More explicitly, if the server process were first to 'update' a record 
> (solely for the purpose of locking the DB), then read through pending 
> entries, it could mark them as 'working on by server process x', 
> commit, and be sure that no other process (such as another 
> worker/server or even a user coming in through web2py proper) would be 
> able to also pick up that work? Even if that just works for SQLite, 
> I'm cool, but I'd like a solution that worked for all DBs if that is 
> possible without a lot of machinations. 
>
> In slightly more detail, there could be a server's table, and as each 
> server 'wakes up' looking for work to do, it could udpate its own row 
> in that table (hence provoking a lock), look for work, flag the work 
> as being handled by itself, then commit. It could then take its own 
> sweet time to do the work, knowing that no other server process would 
> have also claimed that work? 
>
> -=Doug 
>


Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-27 Thread Doug Philips
On Wed, Jun 27, 2012 at 11:53 AM, Anthony  wrote:
>> > Yes, it does release the lock, as soon as the select is complete. You do
>> > not
>> > have to do db.commit() after a select.
>> Please show me where that is documented.
>> Section 7 of http://www.sqlite.org/lockingv3.html says that ONLY
>> happens when autocommit is on, and you have stated that it is off
>> (contrary to my mistaken memory).
>
>
> End of Section 4:
>
> Once all reading has completed, the SHARED lock is dropped.

Thanks, I had missed that part.


>> Further, The Book says that only
>> inside of a Web2py app does commit/rollback back happen automatically.
>
>
> Commit is not needed for a select. Committing is for committing changes to
> the database -- selects only read from the database.

Ok, so if (and I'm looking for a more general that just SQLite answer
here), I want to get exclusive access to the DB, I should first do a
'dummy' change.

More explicitly, if the server process were first to 'update' a record
(solely for the purpose of locking the DB), then read through pending
entries, it could mark them as 'working on by server process x',
commit, and be sure that no other process (such as another
worker/server or even a user coming in through web2py proper) would be
able to also pick up that work? Even if that just works for SQLite,
I'm cool, but I'd like a solution that worked for all DBs if that is
possible without a lot of machinations.

In slightly more detail, there could be a server's table, and as each
server 'wakes up' looking for work to do, it could udpate its own row
in that table (hence provoking a lock), look for work, flag the work
as being handled by itself, then commit. It could then take its own
sweet time to do the work, knowing that no other server process would
have also claimed that work?

-=Doug


[web2py] wempy published in the Python Cheese Shop

2012-06-27 Thread G. Clifford Williams
Hey fellow web-2-pirates / web2py-rats. Just thought I'd share with you the
fact that I've hijacked the template engine from web2py and made a command
line utility similar to Ruby's ERB. I've also stripped down the library a
removed gluon integration wrappers and HTML escaping to make it a generally
useful library outside of web2py.

This is a separate project and not a part of web2py. I'm not trying to
replace the template engine….just make use of it from the command line and
make it easier to use in other projects.


currently on the list of todos for the wempy shell utility:


   - add a switch for passing environment variables from the shell to the
   execution context for templates
   - add recursive processing of a directory
   - add an output extension to batch process files

Todo's for the wemplate library:

   - Try to improve speed (Thadeus already had a very lean approach so
   there may not be much I can do here)
   - extend to facilitate batch processing with multiple contexts


Any feed back you have would be greatly appreciated.

packages.python.org: http://pypi.python.org/pypi/wempy
home page: http://www.wempy.org


[web2py] Re: Sending message.html to single new user?

2012-06-27 Thread RKS
Ah, I see. Can't test now but I will in the morning. Thanks.

On Wednesday, June 27, 2012 7:30:14 PM UTC-5, Anthony wrote:
>
> mail.send(to=['form.vars.email'],subject='Your Registration 
>> Details',message=response.render('new_user.html'))
>>
>
> You have put form.vars.email in quotes, as if that is the literal email 
> address. Just do to=[form.vars.email].
>
> Anthony 
>


[web2py] Re: Suggestion to add more mod_wsgi info to help new users -- WSGIPassAuthorization for instance

2012-06-27 Thread Larry Weinberg
In order to have the web2py examples work out of the box on Apache with 
mod_wsgi, an extra directive is needed in the Apache configuration for the 
VirtualHost

WSGIPassAuthorization On

This allows basic authentication to proceed through. 

It looks like there are some good reasons why mod_wsgi in apache strips 
authorization by default:
The link to the info is: 
http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPassAuthorization





Re: [web2py] Re: Multi_tenant

2012-06-27 Thread Massimo Di Pierro
I would suggest you use a different database (a different connection 
string) for each hospital depending on the hostname.

.domain.com 
import re; regex = re.compile('.*\://(.*?)/.*
db = DAL('postgresq:///%s' % 
regex.match(request.env.http_host).group(1))

In this way you keep your data separate (which is better for security) and 
will allow you scale horizontally by setting up multiple db server 
instances.



On Wednesday, 27 June 2012 18:07:44 UTC-5, Ovidio Marinho wrote:
>
> I am making an application to control government medical appointments 
> in more than fifty hospitals all use a single postgres database, but 
> each hospital must have administrator access, Operator and User, and 
> each access must be made with the view of their unique data . 
>
> is this. 
>
>
>

[web2py] Re: Sending message.html to single new user?

2012-06-27 Thread Anthony

>
> mail.send(to=['form.vars.email'],subject='Your Registration 
> Details',message=response.render('new_user.html'))
>

You have put form.vars.email in quotes, as if that is the literal email 
address. Just do to=[form.vars.email].

Anthony 


Re: [web2py] Re: Routes - simple requirement, but how??

2012-06-27 Thread Jonathan Lundell
On Jun 27, 2012, at 5:15 PM, villas wrote:
> With regards testing routes.  I notice there seems to be a way of logging and 
> there are some doc tests too,  not that I know how they work (please forgive 
> me).  However,  I wonder whether there is some way I can do something like 
> this (all strings just random) so I can test my ideas without changing the 
> routes.py and stopping and starting the server and then typing urls into the 
> browser to see what happens.
> 
> myroute = (r'.*/blah/foo(?P.*)', r'\g')
> myurl = 'adsf.com/blah/etc/test'
> show_transformed_route(myroute, myurl)
> this/is/your/blah/foo/new/route
> 
> Many thanks, David

The doctests are really what you want to use, and not that hard. Just run your 
routes.py with python. (Delete the existing tests that fail because you've 
changed the routes from the example, or convert them to conform to your routes).

>>> filter_url('http://adsf.com/blah/etc/test')
"what you expect"

You don't even have to get "what you expect" right, since the doctest will tell 
you what it actually got.

[web2py] Using web toolkits with web2py

2012-06-27 Thread Daniel Gonzalez
Hi,

I am struggling to get web2py my web application (desktop-like, with 
buttons and so on) properly rendered in the different browser versions.
I would like to use a Web Toolkit to render my components, but still 
implement all the business logic in a web2py application.
Has somebody experience in this area? What are the best options? How 
satisfying are the results?

Thanks,
Daniel


[web2py] Re: Routes - simple requirement, but how??

2012-06-27 Thread villas
With regards testing routes.  I notice there seems to be a way of logging 
and there are some doc tests too,  not that I know how they work (please 
forgive me).  However,  I wonder whether there is some way I can do 
something like this (all strings just random) so I can test my ideas 
without changing the routes.py and stopping and starting the server and 
then typing urls into the browser to see what happens.

myroute = (r'.*/blah/foo(?P.*)', r'\g')
myurl = 'adsf.com/blah/etc/test'
show_transformed_route(myroute, myurl)
this/is/your/blah/foo/new/route

Many thanks, David



[web2py] Sending message.html to single new user?

2012-06-27 Thread RKS
In the book it mentions sending message.html to every person in the 
database. I know you know where it is already but for posterity 
sake...http://web2py.com/books/default/chapter/29/8.

There now seems to be a problem with my code as it only sends the first 
mail.send and not the other. I really would like to take the 
form.vars.email and send them message.html that is a template with their 
login info and how to login as well as some other form.vars I have in the 
form they fill out.

My controller:

def new_post():
form = SQLFORM(db.post)
if form.accepts(request, formname=None):
mail.send(to=['r...@rks.com'],subject='New Registration at 
RKS',message=', '.join('%s: %s' % (k, v) for (k, v) in 
request.vars.iteritems()))
mail.send(to=['form.vars.email'],subject='Your Registration 
Details',message=response.render('new_user.html'))
return DIV("Test")
elif form.errors:
return TABLE(*[TR(k, v) for k, v in form.errors.items()])

My view:


First Name *
Last Name *
Email *



It seems my default code does not recognize form.vars.email because I'm not 
defining it in the form inside the controller? That's the only thing I can 
think of there. Plus I realize now that I'm not going to get vars from one 
view in another or auth.user vars from a non-logged in user? Correct?


[web2py] Re: Best practice using scheduler as a task queue?

2012-06-27 Thread ptressel
Michael --

Here's a common scenario. I'm looking for the best implementation using the 
> scheduler.
>
> I want to support a set of background tasks (task1, task2...), where each 
> task:
>   • processes a queue of items
>   • waits a few seconds
>
> It's safe to have task1 and task2 running in parallel, but I cannot have 
> two task1s running in parallel. They will duplicately process the same 
> queue of items 
>

>
> So how can I ensure there is always EXACTLY ONE of each task in the 
> database?
>

This won't solve your installation / setup issue, but I wonder if it would 
help with the overrun and timeout problems...  Instead of scheduling a 
periodic task, what about having the task reschedule itself?  When it's 
done with the queue, schedule itself for later.  Remove the time limit so 
it can take whatever time it needs to finish the queue.  Or maybe launch a 
process on startup outside of the scheduler -- when it exhausts the queue, 
have it sleep and either wake periodically to check the queue, or have it 
waked when something is inserted.

Is the transaction processing issue you encountered with PostgreSQL 
preventing you from setting up your queue as a real producer consumer 
queue, where you could have multiple workers?

Re. inserting tasks only once:  We have a "first run" check in our models 
to assure that setup code only runs once -- this only runs if the database 
is empty -- but that's not adequate if you update code on a running system 
and add a new task.  We added an "update check" using a version number -- 
we write a breadcrumb file into the models directory with the current 
version, and then check that against a version in the code that is changed 
by the developers when some update code needs to run or the site needs to 
take some action -- you might do something like that to insert new tasks 
just once.  (Details:  The breadcrumb file is named so it's run first 
before other models, and contains one statement that sets a global with the 
version number found during the previous models run.  The first "real" 
model file compares that last version against the current version.  If the 
breadcrumb file didn't exist or the version is different, it runs some 
update code and rewrites the breadcrumb file.  IIRC we open the breadcrumb 
file for exclusive access and spin if it's locked -- will need to make sure 
I did that...)

I don't think this would help with your case, but will mention...  I'm 
working on chaining scheduler tasks -- letting one task conditionally 
release held tasks or insert new ones.  Our need was different from yours 
-- we didn't know which task(s) we wanted to run until we read remote data 
(via a task for that purpose).  So our reader task fetches the data, 
figures out what needs to run and puts work in queues, releases previously 
scheduled tasks.  Since this mod made changes like having unique names for 
all tasks independent of the task function, there may be some issues with 
having a task reschedule itself using an unmodified scheduler that I'm not 
thinking of.

As an aside, there's always a problem with processing items in a queue (at 
least if the items are consumable rather than a persistent to-do list) 
namely, how do you assure that each item is completely processed, and the 
work within one item gets done only once, if the worker processing them 
might fail in the middle of processing an item?  If the worker takes the 
item out of the queue before starting work, then the item is lost if the 
worker dies.  If it leaves the item in the queue but marks it as being 
worked on by itself, another worker can redo it, but encounters the issue 
of picking up where the previous one left off.  For a database, that might 
be solved with transactions and rollback (assuming that's working...).  
This isn't a problem with the scheduler per se -- it's a generic queue 
processing issue.

I'm probably missing some aspect of your situation, so let me say sorry! in 
advance if this isn't relevant.

-- Pat


[web2py] Re: Is there a place to vote to add an id or class to user forms?

2012-06-27 Thread Anthony
http://code.google.com/p/web2py/issues/list

In the meantime, you might change your user() function to something like 
this:

def user():
form = auth()
if isinstance(form, FORM):
form['_id'] = 'auth_%s__form' % request.args(0)
return dict(form=form)

Anthony

On Wednesday, June 27, 2012 7:18:52 PM UTC-4, RKS wrote:
>
> Don't want to be a prude but do you happen to have that URL handy?
>
> On Wednesday, June 27, 2012 6:00:11 PM UTC-5, Massimo Di Pierro wrote:
>>
>> Make a proposal on googlecode issues
>>
>> On Wednesday, 27 June 2012 16:41:23 UTC-5, RKS wrote:
>>>
>>> I think it might be pretty simple just to add a class or id to the 
>>> auth.user forms by default. It's unsemantic to have to wrap it in a div 
>>> just to target those specific inputs or tedious to target them in the 
>>> stylesheet by #auth_user_first_name__row input {} etc or by the 
>>> #auth_user_first_name__label etc when I want every single one to look the 
>>> same. Much easier to target #w2p_auth_login__form input etc.
>>>
>>

[web2py] Re: Is there a place to vote to add an id or class to user forms?

2012-06-27 Thread RKS
Don't want to be a prude but do you happen to have that URL handy?

On Wednesday, June 27, 2012 6:00:11 PM UTC-5, Massimo Di Pierro wrote:
>
> Make a proposal on googlecode issues
>
> On Wednesday, 27 June 2012 16:41:23 UTC-5, RKS wrote:
>>
>> I think it might be pretty simple just to add a class or id to the 
>> auth.user forms by default. It's unsemantic to have to wrap it in a div 
>> just to target those specific inputs or tedious to target them in the 
>> stylesheet by #auth_user_first_name__row input {} etc or by the 
>> #auth_user_first_name__label etc when I want every single one to look the 
>> same. Much easier to target #w2p_auth_login__form input etc.
>>
>

Re: [web2py] Re: Multi_tenant

2012-06-27 Thread Ovidio Marinho
I am making an application to control government medical appointments
in more than fifty hospitals all use a single postgres database, but
each hospital must have administrator access, Operator and User, and
each access must be made with the view of their unique data .

is this.



       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



2012/6/27 pbreit :
> I just started using it and it works fine.
>
> First, figure out what identifier you want to use to identify the tenant.
> The Web2py book shows an example that bases it on the URL's sub-domain (ex:
> tenant1.mysite.com, tenant2.mysite.com, etc.). I'm using the "id" field of a
> "shop" table so I have added this Field() to my tables:
>
> Field('request_tenant', default=shop_id, writable=False)
>
> I have code in my model to figure out "shop_id". Something like shop_id =
> db.shop(auth.user.shop_id)
>
> Then, for any query against a table with a request_tenant field, web2py
> automatically adds (db.shop.request_tenant==shop_id) to the query.
>
> Let us know if you have any specific questions.
>
>


Re: [web2py] Re: web2py crashing

2012-06-27 Thread Jonathan Lundell
On Jun 27, 2012, at 4:02 PM, Massimo Di Pierro wrote:
> I agree. Please check.

That's better; thanks.

> 
> On Wednesday, 27 June 2012 17:53:25 UTC-5, Jonathan Lundell wrote:
> On Jun 27, 2012, at 3:45 PM, Massimo Di Pierro wrote:
>> ok.please check the solution in trunk.
> 
> OK, but I think that SocketClosed might be a better exception. And maybe a 
> comment pointing to this thread or something else explaining what it's doing 
> there (it's a pretty odd piece of code otherwise).
> 
>> 
>> On Wednesday, 27 June 2012 08:20:12 UTC-5, Jonathan Lundell wrote:
>> On Jun 27, 2012, at 6:12 AM, Massimo Di Pierro wrote:
>>> We acn catch it but what do we do? Report "this is a python bug"?
>> 
>> The crash is a python bug. The connection failure isn't (near as I can 
>> tell). Just treat it as a dropped connection.
>> 
>>> 
>>> On Tuesday, 26 June 2012 20:01:49 UTC-5, Jonathan Lundell wrote:
>>> On Jun 26, 2012, at 5:25 PM, Massimo Di Pierro wrote:
 Looks like a buggy socket.py or ssl.py. Is this an occasional error (which 
 may depend on parameters such as certificates) or it reproducible?
>>> 
>>> This was fixed in Python 2.7. The underlying error is "Transport endpoint 
>>> is not connected", which of course shouldn't cause a crash. I suppose we 
>>> could catch the exception in Rocket as a workaround.
>>> 
>> 
>> 
> 
> 




Re: [web2py] Re: web2py crashing

2012-06-27 Thread Massimo Di Pierro
I agree. Please check.

On Wednesday, 27 June 2012 17:53:25 UTC-5, Jonathan Lundell wrote:
>
> On Jun 27, 2012, at 3:45 PM, Massimo Di Pierro wrote:
>
> ok.please check the solution in trunk.
>
>
> OK, but I think that SocketClosed might be a better exception. And maybe a 
> comment pointing to this thread or something else explaining what it's 
> doing there (it's a pretty odd piece of code otherwise).
>
>
> On Wednesday, 27 June 2012 08:20:12 UTC-5, Jonathan Lundell wrote:
>>
>> On Jun 27, 2012, at 6:12 AM, Massimo Di Pierro wrote:
>>
>> We acn catch it but what do we do? Report "this is a python bug"?
>>
>>
>> The crash is a python bug. The connection failure isn't (near as I can 
>> tell). Just treat it as a dropped connection.
>>
>>
>> On Tuesday, 26 June 2012 20:01:49 UTC-5, Jonathan Lundell wrote:
>>>
>>> On Jun 26, 2012, at 5:25 PM, Massimo Di Pierro wrote:
>>>
>>> Looks like a buggy socket.py or ssl.py. Is this an occasional error 
>>> (which may depend on parameters such as certificates) or it reproducible?
>>>
>>>
>>> This was fixed in Python 2.7. The underlying error is "Transport 
>>> endpoint is not connected", which of course shouldn't cause a crash. I 
>>> suppose we could catch the exception in Rocket as a workaround.
>>>
>>
>>
>>
>>
>
>

[web2py] Re: Suggestion to add more mod_wsgi info to help new users -- WSGIPassAuthorization for instance

2012-06-27 Thread Massimo Di Pierro
Please. Tell us more.

On Wednesday, 27 June 2012 16:41:39 UTC-5, Larry Weinberg wrote:
>
> I'm a newbie to apache configuration, so I just spent hours trying to 
> determine why none of the REST-api-with-authentication web2py examples 
> were working for me. All worked fine without authentication.
>
> It turns out the apache server with mod_wsgi strips the authorization out 
> by default.
> A one line sentence about this in the web2py manual would have left me 
> with more hair!
>
> Thanks for listening.
>


[web2py] Re: Is there a place to vote to add an id or class to user forms?

2012-06-27 Thread Massimo Di Pierro
Make a proposal on googlecode issues

On Wednesday, 27 June 2012 16:41:23 UTC-5, RKS wrote:
>
> I think it might be pretty simple just to add a class or id to the 
> auth.user forms by default. It's unsemantic to have to wrap it in a div 
> just to target those specific inputs or tedious to target them in the 
> stylesheet by #auth_user_first_name__row input {} etc or by the 
> #auth_user_first_name__label etc when I want every single one to look the 
> same. Much easier to target #w2p_auth_login__form input etc.
>


[web2py] Re: SQLdesigner still down for maintenance?

2012-06-27 Thread Massimo Di Pierro
Sorry I forgot. it is up.

On Wednesday, 27 June 2012 11:48:05 UTC-5, Alec Taylor wrote:
>
> I remember trying out the designer when I first started using web2py, 
> but wanted to improve my web2py knowledge before using it (especially 
> how to do n+1 unrolling). 
>
> I tried to access it about a week ago, but it was down. 
>
> Just tried now, it still seems down. 
>
> Can I assist somehow with the maintenance in order to get the designer 
> back up again? 
>
> All the best, 
>
> Alec Taylor 
>


[web2py] Re: Webservice to upload files

2012-06-27 Thread Massimo Di Pierro
if you use web2py trunk you should be able to do something easy like

@auth.requires_login()
def upload():
  if request.post_vars:
   db.table.insert(upload_fieldname=request.post_vars['fieldname'])

then do a post using basic auth.



On Wednesday, 27 June 2012 06:10:30 UTC-5, Adriano Almeida wrote:
>
> Hello Gentleman
>
> Is this possible to create a webservice with web2py to upload files 
> (ex:pictures)? How could this be done if I want to have some security 
> (password verification) on it?
>
> I would like to integrate a web2py service with a mobile  application, 
> dropbox style. 
>
> Thanks in advance
>
> Adriano
>


Re: [web2py] Re: web2py crashing

2012-06-27 Thread Jonathan Lundell
On Jun 27, 2012, at 3:45 PM, Massimo Di Pierro wrote:
> ok.please check the solution in trunk.

OK, but I think that SocketClosed might be a better exception. And maybe a 
comment pointing to this thread or something else explaining what it's doing 
there (it's a pretty odd piece of code otherwise).

> 
> On Wednesday, 27 June 2012 08:20:12 UTC-5, Jonathan Lundell wrote:
> On Jun 27, 2012, at 6:12 AM, Massimo Di Pierro wrote:
>> We acn catch it but what do we do? Report "this is a python bug"?
> 
> The crash is a python bug. The connection failure isn't (near as I can tell). 
> Just treat it as a dropped connection.
> 
>> 
>> On Tuesday, 26 June 2012 20:01:49 UTC-5, Jonathan Lundell wrote:
>> On Jun 26, 2012, at 5:25 PM, Massimo Di Pierro wrote:
>>> Looks like a buggy socket.py or ssl.py. Is this an occasional error (which 
>>> may depend on parameters such as certificates) or it reproducible?
>> 
>> This was fixed in Python 2.7. The underlying error is "Transport endpoint is 
>> not connected", which of course shouldn't cause a crash. I suppose we could 
>> catch the exception in Rocket as a workaround.
>> 
> 
> 




Re: [web2py] Form not processed on first submit

2012-06-27 Thread Massimo Di Pierro
This can happen if you have a broken link the page (for example an img src) 
which accidentally reload the page itself in background.

On Wednesday, 27 June 2012 10:51:44 UTC-5, Anthony wrote:
>
> Perhaps form.process() is failing the first time because the _formkey in 
> the session isn't matching for some reason (don't know why, though).
>
> Anthony
>
> On Wednesday, June 27, 2012 8:42:56 AM UTC-4, Johann Spies wrote:
>>
>> Reloading the page after the form appeared the first time, works.  But 
>> why?
>>
>> Regards
>> Johann
>>
>>
>> -- 
>> Because experiencing your loyal love is better than life itself, 
>> my lips will praise you.  (Psalm 63:3)
>>
>>

[web2py] Re: long text as content for PluginMModal

2012-06-27 Thread Massimo Di Pierro
1) the newline are respected but not converted into . You have to do 
this manually if that is what you want to do.

db.table.field.represent=lambda value, row: DIV(*[P(p) for p in 
value.split('\n')])

2) check your layout. Perhaps it sends an encoding other than utf8

On Wednesday, 27 June 2012 10:27:52 UTC-5, Marco Prosperi wrote:
>
>
> hi all, I'm putting a long text in a PluginMModal content but I face 2 
> problems:
> - carriage returns of the text are not respected (also if I put some \n in 
> the string)
> - characters with accents (it is an Italian string) are not shown correctly
>
> which are the solutions?
>
> thanks in advance
>
> Marco
>


[web2py] Re: Two questions about models

2012-06-27 Thread cyan

Thanks guys! Very helpful comments and explanations!


Re: [web2py] Re: web2py crashing

2012-06-27 Thread Massimo Di Pierro
ok.please check the solution in trunk.

On Wednesday, 27 June 2012 08:20:12 UTC-5, Jonathan Lundell wrote:
>
> On Jun 27, 2012, at 6:12 AM, Massimo Di Pierro wrote:
>
> We acn catch it but what do we do? Report "this is a python bug"?
>
>
> The crash is a python bug. The connection failure isn't (near as I can 
> tell). Just treat it as a dropped connection.
>
>
> On Tuesday, 26 June 2012 20:01:49 UTC-5, Jonathan Lundell wrote:
>>
>> On Jun 26, 2012, at 5:25 PM, Massimo Di Pierro wrote:
>>
>> Looks like a buggy socket.py or ssl.py. Is this an occasional error 
>> (which may depend on parameters such as certificates) or it reproducible?
>>
>>
>> This was fixed in Python 2.7. The underlying error is "Transport endpoint 
>> is not connected", which of course shouldn't cause a crash. I suppose we 
>> could catch the exception in Rocket as a workaround.
>>
>
>
>
>

Re: [web2py] How to change a form.vars.field value after validation?

2012-06-27 Thread Bruno Rocha
SO I think you have to inspect and edit the attributes of *
form.custom.widget.captcha*
*
*
after the .validate() check the attr's of form.custom.widget.captcha anc
change them.

*Bruno Cezar Rocha*

http://www.CursoDePython.com.br
[image: Facebook]  [image:
Twitter] [image:
LinkedIn]  [image:
about.me] [image:
Amazon]  [image:
AngelList] [image:
Blog RSS]  [image:
Facebook Page]  [image:
foursquare] [image:
Google Plus]  [image:
pinterest]  [image:
SlideShare] [image:
YouTube] 
 [image: Google Talk] rochacbruno [image: Skype] blouweb
Blog: Generate a thumbnail that fits in a
box
  Get a signature like this.

Click
here.



On Wed, Jun 27, 2012 at 6:51 PM, vinicius...@gmail.com <
vinicius...@gmail.com> wrote:

> form.custom.widget.captcha


Re: [web2py] How to change a form.vars.field value after validation?

2012-06-27 Thread vinicius...@gmail.com

Yes, I was rendering {{=form.custom.widget.captcha}} in my view.

Why is this strange?



On 06/27/2012 05:58 PM, pbreit wrote:

Wow, that is some strange code.

What does your view code look like? How are you rendering the captcha
widget?





[web2py] Suggestion to add more mod_wsgi info to help new users -- WSGIPassAuthorization for instance

2012-06-27 Thread Larry Weinberg
I'm a newbie to apache configuration, so I just spent hours trying to 
determine why none of the REST-api-with-authentication web2py examples 
were working for me. All worked fine without authentication.

It turns out the apache server with mod_wsgi strips the authorization out 
by default.
A one line sentence about this in the web2py manual would have left me with 
more hair!

Thanks for listening.


[web2py] Is there a place to vote to add an id or class to user forms?

2012-06-27 Thread RKS
I think it might be pretty simple just to add a class or id to the 
auth.user forms by default. It's unsemantic to have to wrap it in a div 
just to target those specific inputs or tedious to target them in the 
stylesheet by #auth_user_first_name__row input {} etc or by the 
#auth_user_first_name__label etc when I want every single one to look the 
same. Much easier to target #w2p_auth_login__form input etc.


[web2py] Re: Multi_tenant

2012-06-27 Thread pbreit
I just started using it and it works fine.

First, figure out what identifier you want to use to identify the tenant. 
The Web2py book shows an example that bases it on the URL's sub-domain (ex: 
tenant1.mysite.com, tenant2.mysite.com, etc.). I'm using the "id" field of 
a "shop" table so I have added this Field() to my tables:

Field('request_tenant', default=shop_id, writable=False)

I have code in my model to figure out "shop_id". Something like shop_id = 
db.shop(auth.user.shop_id)

Then, for any query against a table with a request_tenant field, web2py 
automatically adds (db.shop.request_tenant==shop_id) to the query.

Let us know if you have any specific questions.




Re: [web2py] How to change a form.vars.field value after validation?

2012-06-27 Thread pbreit
Wow, that is some strange code.

What does your view code look like? How are you rendering the captcha 
widget?



[web2py] Re: App does not exist or your are not authorized when deploying layout plugin

2012-06-27 Thread François Delpierre
Then I do not understand why when I 
deploy web2py.plugin.layout_Compromise.w2p from the web interface it 
overwrites the view/layout.html file!

pivert@skinner:~/Downloads/web2py/applications/Incident_report_2$ ls -lh 
views/layout.html 
-rw-r--r-- 1 pivert pivert 6.2K Jun 26 23:49 views/layout.html
pivert@skinner:~/Downloads/web2py/applications/Incident_report_2$ # I deploy 
the plugin through the web interface
pivert@skinner:~/Downloads/web2py/applications/Incident_report_2$ ls -lh 
views/layout.html 
-rw-r--r-- 1 pivert pivert 5.5K Nov  3  2010 views/layout.html
pivert@skinner:~/Downloads/web2py/applications/Incident_report_2$ 




Re: [web2py] How to change a form.vars.field value after validation?

2012-06-27 Thread vinicius...@gmail.com

Here it is: http://pastebin.com/2zMNYWnX



On 06/27/2012 05:20 PM, Richard Vézina wrote:

Would you show you SQLFORM.factory code?

Richard

On Wed, Jun 27, 2012 at 4:14 PM, vinicius...@gmail.com
 mailto:vinicius...@gmail.com>> wrote:

Hi guys.

I'm facing a problem I didn't find a pure web2py solution.

I have a SQLFORM.factory() with some fields, including one captcha
field.
Every time the form is showed, the input captcha field must be
empty. The form may have error in other fields and the captcha could
be filled right, but a new one is generated every time the form is
showed. As password fields, the captcha must be always presented
empty to the user.

So, I tried to do form.vars.captcha = '' just before my return
dict(form=form), but the value user filled in keeps showing.
I also tried playing with form.request_vars.captcha but
unsuccessfull again.

I found a workaround hardcoding the  tag in my view, instead
of {{=form.custom.widget.captcha}__} as I usually do with other fields.

Does anybody has any suggestion about it? How to change a
form.vars.field value after validation?

I think a custom validator would solve my problem. But I think it
shouldn't be necessary in a so simple cenario.

--
Vinicius Assef






Re: [web2py] How to change a form.vars.field value after validation?

2012-06-27 Thread Richard Vézina
Would you show you SQLFORM.factory code?

Richard

On Wed, Jun 27, 2012 at 4:14 PM, vinicius...@gmail.com <
vinicius...@gmail.com> wrote:

> Hi guys.
>
> I'm facing a problem I didn't find a pure web2py solution.
>
> I have a SQLFORM.factory() with some fields, including one captcha field.
> Every time the form is showed, the input captcha field must be empty. The
> form may have error in other fields and the captcha could be filled right,
> but a new one is generated every time the form is showed. As password
> fields, the captcha must be always presented empty to the user.
>
> So, I tried to do form.vars.captcha = '' just before my return
> dict(form=form), but the value user filled in keeps showing.
> I also tried playing with form.request_vars.captcha but unsuccessfull
> again.
>
> I found a workaround hardcoding the  tag in my view, instead of
> {{=form.custom.widget.captcha}**} as I usually do with other fields.
>
> Does anybody has any suggestion about it? How to change a form.vars.field
> value after validation?
>
> I think a custom validator would solve my problem. But I think it
> shouldn't be necessary in a so simple cenario.
>
> --
> Vinicius Assef
>


[web2py] How to change a form.vars.field value after validation?

2012-06-27 Thread vinicius...@gmail.com

Hi guys.

I'm facing a problem I didn't find a pure web2py solution.

I have a SQLFORM.factory() with some fields, including one captcha field.
Every time the form is showed, the input captcha field must be empty. 
The form may have error in other fields and the captcha could be filled 
right, but a new one is generated every time the form is showed. As 
password fields, the captcha must be always presented empty to the user.


So, I tried to do form.vars.captcha = '' just before my return 
dict(form=form), but the value user filled in keeps showing.

I also tried playing with form.request_vars.captcha but unsuccessfull again.

I found a workaround hardcoding the  tag in my view, instead of 
{{=form.custom.widget.captcha}} as I usually do with other fields.


Does anybody has any suggestion about it? How to change a 
form.vars.field value after validation?


I think a custom validator would solve my problem. But I think it 
shouldn't be necessary in a so simple cenario.


--
Vinicius Assef


[web2py] Re: Parsing python from db fields?

2012-06-27 Thread RKS
Unless you're very curious about this problem I wouldn't try too hard. I'm 
under a deadline so I just used an if statement to wrap the include file I 
need and referenced the specific pages inside the if.

Might not be the most elegant way to do things and certainly it falls into 
the workaround way of doing it, but for now it's what I'm going to do. 

Thanks, both of you, for all your help on this.


[web2py] Fwd: Multi_tenant

2012-06-27 Thread Ovidio Marinho
       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




-- Forwarded message --
From: Ovidio Marinho 
Date: 2012/6/27
Subject: Multi_tenant
To: web2py@googlegroups.com


Procurei isto nas listas todo mundo fala e ninguem esclarece como esta
coisa funciona com claridade.

I tried that lists everyone talks and no one explains how this thing
works with clarity.



       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


[web2py] Multi_tenant

2012-06-27 Thread Ovidio Marinho
Procurei isto nas listas todo mundo fala e ninguem esclarece como esta
coisa funciona com claridade.

I tried that lists everyone talks and no one explains how this thing
works with clarity.



       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


Re: [web2py] Re: Best practice using scheduler as a task queue?

2012-06-27 Thread Niphlod
uhm. why not having them started with systemd or upstart or supervisord 
?

Scheduler is "by design" allowed to run with multiple instances (to process 
a longer queue you may want to start more of them), but if you're really 
loosing money why didn't you rely on that services to be sure that there's 
only one instance running?
There are a lot of nice implementations out there and the one I 
mentioned are pretty much "state-of-the-art" :D (while contributing to fix 
current issues)

BTW: - "responding to ctrl+c" fixed in trunk recently 
   - "os messed up maybe" require you to check the os, python 
programs can't be omniscient :D
   - "messy developers", no easy fix for that too 


On Wednesday, June 27, 2012 9:18:06 PM UTC+2, Michael Toomim wrote:
>
> The problem with terminating the processes is:
>   • sometimes they don't respond to control-c, and need a kill -9
>   • or sometimes that doesn't work, maybe the os is messed up
>   • or sometimes the developer might run two instances simultaneously, 
> forgetting that one was already running
>
> You're right that usually I can shut them both down with control-c, but I 
> need a safeguard. My application spends money on mechanical turk and I'll 
> spend erroneous money and upset my users if it goes wrong by accident.
>
> On Wednesday, June 27, 2012 12:56:52 AM UTC-7, Niphlod wrote:
>>
>> BTW: I'm pretty sure that when you say "scheduler should be terminated 
>> alongside web2py" you're not perfectly grasping how webdevelopment in 
>> production works. If you're using "standalone" versions, i.e. not mounted 
>> on a webserver, you can start your instances as web2py -a mypassword & 
>> web2py -K myapp and I'm pretty sure when hitting ctrl+c both will shutdown. 
>>
>

Re: [web2py] Re: Best practice using scheduler as a task queue?

2012-06-27 Thread Niphlod
I don't find that this is a common scenario, anyway my idea was put the 
insertion/update of the task at cron @reboot, wrap that code in a 
try:except pass block and let the maintenance task to do the honours of 
checking if other 3 functions are ok. maintenance will run let's say, with 
a period of 40 secs, so no problem there.

btw, scheduler may need to be run outside web2py -K, so there is no 
"without locks" solution; we'll be forced to add also to that call all 
scheduler_task parameters (except for repeats=0) to maximize flexibility.

maybe adding a unique column to scheduler tasks that gets evaluated by 
default to a uuid will solve the problem...e.g.
db.scheduler_task.insert(function_name='abcd', repeats=0, ., 
unique_column='abcd') would close the deal for your requirements.
you'd have to wrap that in a try:except call for obvious reason.

as of parameters passed to scheduler, if you have in models 
Scheduler(parameters) they're correctly evaluated.
For greater flexibility you'd have to hack something.. but it's not 
really difficult. 
for w2p_tvseries I needed to define a Scheduler() in models and have to run 
the same Scheduler with other parameters for a cron task "executed outside 
web2py" like a "normal cron" . 
Check 
https://github.com/niphlod/w2p_tvseries/blob/master/private/w2p_tvseries.py#L40


  

On Wednesday, June 27, 2012 8:52:33 PM UTC+2, Michael Toomim wrote:
>
> I'm totally interested in solutions! It's a big problem I need to solve.
>
> The recurring maintenance task does not fix the initialization 
> problem—because now you need to initialize the recurring maintenance task. 
> This results in the same race condition. It does fine with the 40,000 
> records problem. But it's just a lot of complexity we're introducing to 
> solve a simple problem (looping tasks) with a complex solution (scheduler).
>
> I'd still love to find a clean way to do this. Maybe we should extend the 
> scheduler like this:
>   • Add a daemon_tasks parameter when you call it from models 
> "Scheduler(db, daemon_tasks=[func1, func2])"
>   • When scheduler boots up, it handles locks and everything and ensures 
> there are two tasks that just call these functions
>   • Then it dispatches the workers processes as usual
>
> ...ah, shoot, looking in widget.py, it looks like the code that starts 
> schedulers doesn't have access to the parameters passed to Scheduler() 
> because models haven't been run yet. Hmph.
>
> On Wednesday, June 27, 2012 12:56:52 AM UTC-7, Niphlod wrote:
>>
>> I don't know if continuing to give you fixes and alternative 
>> implementations is to be considered as harassment at this point, stop me if 
>> you're not interested into those.
>>
>> There is a very biiig problem in your statements: if your vision is 
>>
>> Woohoo, this scheduler will *automatically handle locks*—so I don't need 
>> to worry about stray background processes running in parallel 
>> automatically, and it will *automatically start/stop the processes* with 
>> the web2py server with -K, which makes it much easier to deploy the code!
>>
>> then the scheduler is the right tool for you. it's your app that doesn't 
>> handle locks, because of your initialization code put into models.
>>
>> At least 2 of your problems (initialization and 40,000 scheduler_run 
>> records) could be fixed by a "recurring maintenance" task that will do 
>> check_daemon() without advisory locks and prune the scheduler_run table.
>>
>> BTW: I'm pretty sure that when you say "scheduler should be terminated 
>> alongside web2py" you're not perfectly grasping how webdevelopment in 
>> production works. If you're using "standalone" versions, i.e. not mounted 
>> on a webserver, you can start your instances as web2py -a mypassword & 
>> web2py -K myapp and I'm pretty sure when hitting ctrl+c both will shutdown. 
>>
>

Re: [web2py] Re: How to populate list:reference field?

2012-06-27 Thread Anthony
Have you read this section: 
http://web2py.com/books/default/chapter/29/6#One-to-many-relation? (Think 
person=group and dog=event.)

On Wednesday, June 27, 2012 12:42:40 PM UTC-4, Alec Taylor wrote:
>
> I was planning to have a many groups to 1 event relation, but now that 
> I think of it, there are better ways of accomplishing that. 
>
> How do I do the n+1 unrolling simply? 
>
> I.e.: how do I create a list using SQLFORM (or similar) which finds 
> and displays in a list all [events in [db.event for each group in 
> db.group_of_events]]?` 
>
> On Thu, Jun 28, 2012 at 2:34 AM, Anthony wrote: 
> > Actually, why do you need the "events" field in group_of_events? If you 
> want 
> > a one-to-many relation with db.event, you've already got it with the 
> > db.event.group_id field. What workflow are you trying to create? 
> > 
> > Anthony 
> > 
> > 
> > On Wednesday, June 27, 2012 12:09:50 PM UTC-4, Alec Taylor wrote: 
> >> 
> >> Thanks, that fixed some other problems, but my initial problem of not 
> >> getting the list of events associated with each group is still 
> >> present. 
> >> 
> >> >> db.define_table( 
> >> >> 'group_of_events', 
> >> >> Field('group_name', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 
> >> >> 'group_of_events.group_name')]), 
> >> >> Field('events', 'list:reference db.event', 
> requires=[IS_IN_DB(db, 
> >> >> 'event.id', '%(event_name)s [%(group_id)s]', multiple=True)]) 
> >> > 
> >> > 
> >> > When you put the IS_IN_DB validator in a list, you do not get the 
> >> > standard 
> >> > dropdown (for single items) or multiple select widget (for multiple 
> >> > items). 
> >> > Change the above to: 
> >> > 
> >> > requires=IS_IN_DB(db, 'event.id', '%(event_name)s 
> [%(group_id)s]', 
> >> > multiple=True) 
> >> > Anthony 
> >> > 
> >> > -- 
> >> > 
> >> > 
> >> > 
> > 
> > -- 
> > 
> > 
> > 
>


Re: [web2py] Re: Best practice using scheduler as a task queue?

2012-06-27 Thread Michael Toomim
The problem with terminating the processes is:
  • sometimes they don't respond to control-c, and need a kill -9
  • or sometimes that doesn't work, maybe the os is messed up
  • or sometimes the developer might run two instances simultaneously, 
forgetting that one was already running

You're right that usually I can shut them both down with control-c, but I 
need a safeguard. My application spends money on mechanical turk and I'll 
spend erroneous money and upset my users if it goes wrong by accident.

On Wednesday, June 27, 2012 12:56:52 AM UTC-7, Niphlod wrote:
>
> BTW: I'm pretty sure that when you say "scheduler should be terminated 
> alongside web2py" you're not perfectly grasping how webdevelopment in 
> production works. If you're using "standalone" versions, i.e. not mounted 
> on a webserver, you can start your instances as web2py -a mypassword & 
> web2py -K myapp and I'm pretty sure when hitting ctrl+c both will shutdown. 
>


Re: [web2py] Re: How to populate list:reference field?

2012-06-27 Thread Andrew
Oops.  Didn't see Anthony's post.


Re: [web2py] Re: How to populate list:reference field?

2012-06-27 Thread Andrew
Suggestion.  Don't have list of events in the table.   It is a 1:m 
relationship.  Querying the events table, with a join will give you the list of 
events for a group.  
Would that work.  I think it is a lot simpler.
What happens when someone adds a new event, does the group automatically get 
updated ? 


Re: [web2py] Re: Best practice using scheduler as a task queue?

2012-06-27 Thread Michael Toomim
I'm totally interested in solutions! It's a big problem I need to solve.

The recurring maintenance task does not fix the initialization 
problem—because now you need to initialize the recurring maintenance task. 
This results in the same race condition. It does fine with the 40,000 
records problem. But it's just a lot of complexity we're introducing to 
solve a simple problem (looping tasks) with a complex solution (scheduler).

I'd still love to find a clean way to do this. Maybe we should extend the 
scheduler like this:
  • Add a daemon_tasks parameter when you call it from models 
"Scheduler(db, daemon_tasks=[func1, func2])"
  • When scheduler boots up, it handles locks and everything and ensures 
there are two tasks that just call these functions
  • Then it dispatches the workers processes as usual

...ah, shoot, looking in widget.py, it looks like the code that starts 
schedulers doesn't have access to the parameters passed to Scheduler() 
because models haven't been run yet. Hmph.

On Wednesday, June 27, 2012 12:56:52 AM UTC-7, Niphlod wrote:
>
> I don't know if continuing to give you fixes and alternative 
> implementations is to be considered as harassment at this point, stop me if 
> you're not interested into those.
>
> There is a very biiig problem in your statements: if your vision is 
>
> Woohoo, this scheduler will *automatically handle locks*—so I don't need 
> to worry about stray background processes running in parallel 
> automatically, and it will *automatically start/stop the processes* with 
> the web2py server with -K, which makes it much easier to deploy the code!
>
> then the scheduler is the right tool for you. it's your app that doesn't 
> handle locks, because of your initialization code put into models.
>
> At least 2 of your problems (initialization and 40,000 scheduler_run 
> records) could be fixed by a "recurring maintenance" task that will do 
> check_daemon() without advisory locks and prune the scheduler_run table.
>
> BTW: I'm pretty sure that when you say "scheduler should be terminated 
> alongside web2py" you're not perfectly grasping how webdevelopment in 
> production works. If you're using "standalone" versions, i.e. not mounted 
> on a webserver, you can start your instances as web2py -a mypassword & 
> web2py -K myapp and I'm pretty sure when hitting ctrl+c both will shutdown. 
>


[web2py] Re: Reopening: problems running from subfolder with mod_wsgi

2012-06-27 Thread Larry Weinberg
Here is a summary of what I have found.
1 -- My inconsistent problems look like they were due to trying to run two 
different versions of web2py inside one WSGIProcessGroup or mod_wsgi.  This 
was probably a very bad idea on my part.  Needs to be done in separate 
virtual hosts with separate WSGIProcessGroups.  Fixing that fixed a number 
of my weird issues.

2 - It does look like web2py's  rewrite.py has a hardcoded href to /admin 
for the ticket html itself.  So this does look like a small problem in 
web2py trunk when trying to run it using urls underneath a subfolder.  Most 
else seems to works fine so far.



On Monday, June 25, 2012 5:40:08 PM UTC-7, Larry Weinberg wrote:
>
> This error is always repeatable:
>
> The "Internal error" page always links incorrectly to the ticket.
>
> It links back to the top site.
>
> admin/default/ticket/up/10.102.67.127.2012-06-25.17-37-36.38cfaa82-a858-4e7b-9a69-9afc0fb3e7e7
>
> If I visit the errors link normally I can see the error.
>
>

-- 





[web2py] SQLdesigner still down for maintenance?

2012-06-27 Thread Alec Taylor
I remember trying out the designer when I first started using web2py,
but wanted to improve my web2py knowledge before using it (especially
how to do n+1 unrolling).

I tried to access it about a week ago, but it was down.

Just tried now, it still seems down.

Can I assist somehow with the maintenance in order to get the designer
back up again?

All the best,

Alec Taylor

-- 





Re: [web2py] Re: How to populate list:reference field?

2012-06-27 Thread Alec Taylor
I was planning to have a many groups to 1 event relation, but now that
I think of it, there are better ways of accomplishing that.

How do I do the n+1 unrolling simply?

I.e.: how do I create a list using SQLFORM (or similar) which finds
and displays in a list all [events in [db.event for each group in
db.group_of_events]]?`

On Thu, Jun 28, 2012 at 2:34 AM, Anthony  wrote:
> Actually, why do you need the "events" field in group_of_events? If you want
> a one-to-many relation with db.event, you've already got it with the
> db.event.group_id field. What workflow are you trying to create?
>
> Anthony
>
>
> On Wednesday, June 27, 2012 12:09:50 PM UTC-4, Alec Taylor wrote:
>>
>> Thanks, that fixed some other problems, but my initial problem of not
>> getting the list of events associated with each group is still
>> present.
>>
>> >> db.define_table(
>> >>     'group_of_events',
>> >>     Field('group_name', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
>> >> 'group_of_events.group_name')]),
>> >>     Field('events', 'list:reference db.event', requires=[IS_IN_DB(db,
>> >> 'event.id', '%(event_name)s [%(group_id)s]', multiple=True)])
>> >
>> >
>> > When you put the IS_IN_DB validator in a list, you do not get the
>> > standard
>> > dropdown (for single items) or multiple select widget (for multiple
>> > items).
>> > Change the above to:
>> >
>> >     requires=IS_IN_DB(db, 'event.id', '%(event_name)s [%(group_id)s]',
>> > multiple=True)
>> > Anthony
>> >
>> > --
>> >
>> >
>> >
>
> --
>
>
>

-- 





Re: [web2py] Webservice to upload files

2012-06-27 Thread Jason Brower

Sure.  Easy.
Make your model that will hold the files.
Create pages that handle the uploading of files.
Create pages to handle the downloading of files.
The hard part is in the details, for example, what features do you want 
to have. Which is really something web2py can do be I think you should 
give it a shot first.

BR,
Jason
On 06/27/2012 02:10 PM, Adriano Almeida wrote:

Hello Gentleman

Is this possible to create a webservice with web2py to upload files 
(ex:pictures)? How could this be done if I want to have some security 
(password verification) on it?


I would like to integrate a web2py service with a mobile  application, 
dropbox style.


Thanks in advance

Adriano
--






--





[web2py] Re: Forms - MVC model

2012-06-27 Thread Anthony
Follow the examples in the book. Most of the form handling (including 
creation of the FORM/SQLFORM) object should be handled in the controller. 
In the view, you can handle the display of the form, but web2py will give 
you a default display if you just do:

{{=form}}

Anthony

On Wednesday, June 27, 2012 7:08:19 AM UTC-4, Pedro Casalinho wrote:
>
> This may be a dumb question but, should forms be created in controllers 
> and passed to the view or should they be created in the view, taking into 
> consideration the MVC model

-- 





Re: [web2py] Forms - MVC model

2012-06-27 Thread Jason Brower

On 06/27/2012 07:30 PM, Jonathan Lundell wrote:

On Jun 27, 2012, at 4:08 AM, Pedro Casalinho wrote:
This may be a dumb question but, should forms be created in 
controllers and passed to the view or should they be created in the 
view, taking into consideration the MVC model





MVC is a pretty leaky abstraction, especially in the context of 
web2py, where you start creating the view in your model (with explicit 
or implicit control over the representation of fields).


At any rate, create your forms in the controller, because you need to 
deal with their submission there.

--



OK, hate to nag about it, but your declaring a type of field in the 
model.  Sometimes you have to make your own type of field. If you create 
your field types correctly in the model, then web2py knows what to do 
when creating the view. :) That's one thing about Web2py I go giddy over. :)

BR,
Jason

--





Re: [web2py] Forms - MVC model

2012-06-27 Thread Anthony

>
> # controllers\default.py 
> def index(): 
> return dict(authed_users=SQLTABLE(db().select(db.auth_user.ALL))) 
>
> # views\default\index.html 
> {{if 'authed_users' in globals():}} 
> {{=T('Registered users:')}} 
> {{=authed_users}} 
>

This example does not show a form -- it shows a table with the results of a 
select.

Anthony 

-- 





Re: [web2py] Re: How to populate list:reference field?

2012-06-27 Thread Anthony
Actually, why do you need the "events" field in group_of_events? If you 
want a one-to-many relation with db.event, you've already got it with the 
db.event.group_id field. What workflow are you trying to create?

Anthony

On Wednesday, June 27, 2012 12:09:50 PM UTC-4, Alec Taylor wrote:
>
> Thanks, that fixed some other problems, but my initial problem of not 
> getting the list of events associated with each group is still 
> present. 
>
> >> db.define_table( 
> >> 'group_of_events', 
> >> Field('group_name', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 
> >> 'group_of_events.group_name')]), 
> >> Field('events', 'list:reference db.event', requires=[IS_IN_DB(db, 
> >> 'event.id', '%(event_name)s [%(group_id)s]', multiple=True)]) 
> > 
> > 
> > When you put the IS_IN_DB validator in a list, you do not get the 
> standard 
> > dropdown (for single items) or multiple select widget (for multiple 
> items). 
> > Change the above to: 
> > 
> > requires=IS_IN_DB(db, 'event.id', '%(event_name)s [%(group_id)s]', 
> > multiple=True) 
> > Anthony 
> > 
> > -- 
> > 
> > 
> > 
>

-- 





Re: [web2py] Forms - MVC model

2012-06-27 Thread Jonathan Lundell
On Jun 27, 2012, at 4:08 AM, Pedro Casalinho wrote:
> This may be a dumb question but, should forms be created in controllers and 
> passed to the view or should they be created in the view, taking into 
> consideration the MVC model
> 
> 

MVC is a pretty leaky abstraction, especially in the context of web2py, where 
you start creating the view in your model (with explicit or implicit control 
over the representation of fields). 

At any rate, create your forms in the controller, because you need to deal with 
their submission there.

-- 





[web2py] Re: IMG ignores css tag x columns

2012-06-27 Thread Anthony
The IMG function just creates a standard HTML  tag. If you want it 
styled in a particular way, you have to add the relevant CSS. If your CSS 
is based on a particular class, you have to add that class to the IMG() 
call:

IMG(_src=..., _class='logo')

Anthony

On Wednesday, June 27, 2012 12:03:10 PM UTC-4, BlueShadow wrote:
>
> Hi I like to make my Logo on my webpage a link to the index page.
> I found this line of code: 
> {{=TD(A(IMG(_src=URL(r=request,c='static',f='images/Logo.png')),_href=URL(r=request,f='index')))}}
> But the web2py IMG function ignores the CSS tag which specifies that the 
> logo should be adjusted to 12 columns.
> Now the Logo is gigantic :-(
> Can anyone help.
>

-- 





Re: [web2py] Forms - MVC model

2012-06-27 Thread Alec Taylor
Create them in the controller, call them from the template (view).

Example:

# controllers\default.py
def index():
return dict(authed_users=SQLTABLE(db().select(db.auth_user.ALL)))

# views\default\index.html
{{if 'authed_users' in globals():}}
{{=T('Registered users:')}}
{{=authed_users}}
{{else:}}
{{=BEAUTIFY(response._vars)}}
{{pass}}

On Wed, Jun 27, 2012 at 9:08 PM, Pedro Casalinho
 wrote:
> This may be a dumb question but, should forms be created in controllers and
> passed to the view or should they be created in the view, taking into
> consideration the MVC model
>
> --
>
>
>

-- 





[web2py] Re: Two questions about models

2012-06-27 Thread villas
1.  I often look at the code.  You might like to use this resource...

http://www.web2py.com/examples/static/epydoc/index.html

For example look in:  gluon/tools.py  / Class Auth  
you will see the code to create the forms.

2.  Depends on how many tables and functions you have.  Unless you really 
feel that you will definitely have performance issues,  I would recommend 
keeping them all initially in the same directory   yourapp/models.   Later 
when you need to optimize for performance,  it is not so difficult to 
re-factor

Regards, David

On Wednesday, June 27, 2012 1:52:11 PM UTC+1, cyan wrote:
>
>
> Hi,
>
> 1. In the web2py book, there is an example for Auth settings, which 
> presumably resides at top-level inside a model:
>
> auth.settings.register_onaccept.append(lambda form: mail.send(to='
> y...@example.com', subject='new user', message="new user email is %s' % 
> form.vars.email))
>
> and I wonder where exactly do these 'form' and 'form.vars.email' variables 
> come from and how do we know which specific variables are available for 
> which functions in web2py, such information seems to be poorly documented 
> in the manual.
>
> 2. Is it advisable to organize models into different folders named by 
> their related controllers? For example, for all account-related 
> functionalities, I create a model called 'account.py' and put it at 
> 'my_app/models/account/account.py', so that only this model will be 
> executed for all account-related requests. Similarly, a model named 
> 'content.py' is created in 'my_app/models/content/content.py', so that only 
> this model will be executed for all the requests relating to user-generated 
> content. By doing this (as opposed to put all the models in 
> 'my_app/models/'), we can avoid executing models we don't need for certain 
> requests, but we may need to duplicate some code (e.g. create db 
> connections) for different models. Is this a good practice in web2py?
>

On Wednesday, June 27, 2012 1:52:11 PM UTC+1, cyan wrote:
>
>
> Hi,
>
> 1. In the web2py book, there is an example for Auth settings, which 
> presumably resides at top-level inside a model:
>
> auth.settings.register_onaccept.append(lambda form: mail.send(to='
> y...@example.com', subject='new user', message="new user email is %s' % 
> form.vars.email))
>
> and I wonder where exactly do these 'form' and 'form.vars.email' variables 
> come from and how do we know which specific variables are available for 
> which functions in web2py, such information seems to be poorly documented 
> in the manual.
>
> 2. Is it advisable to organize models into different folders named by 
> their related controllers? For example, for all account-related 
> functionalities, I create a model called 'account.py' and put it at 
> 'my_app/models/account/account.py', so that only this model will be 
> executed for all account-related requests. Similarly, a model named 
> 'content.py' is created in 'my_app/models/content/content.py', so that only 
> this model will be executed for all the requests relating to user-generated 
> content. By doing this (as opposed to put all the models in 
> 'my_app/models/'), we can avoid executing models we don't need for certain 
> requests, but we may need to duplicate some code (e.g. create db 
> connections) for different models. Is this a good practice in web2py?
>

-- 





Re: [web2py] Re: How to populate list:reference field?

2012-06-27 Thread Alec Taylor
Thanks, that fixed some other problems, but my initial problem of not
getting the list of events associated with each group is still
present.

On Thu, Jun 28, 2012 at 1:44 AM, Anthony  wrote:
>> db.define_table(
>>     'group_of_events',
>>     Field('group_name', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
>> 'group_of_events.group_name')]),
>>     Field('events', 'list:reference db.event', requires=[IS_IN_DB(db,
>> 'event.id', '%(event_name)s [%(group_id)s]', multiple=True)])
>
>
> When you put the IS_IN_DB validator in a list, you do not get the standard
> dropdown (for single items) or multiple select widget (for multiple items).
> Change the above to:
>
>     requires=IS_IN_DB(db, 'event.id', '%(event_name)s [%(group_id)s]',
> multiple=True)
> Anthony
>
> --
>
>
>

-- 





[web2py] IMG ignores css tag x columns

2012-06-27 Thread BlueShadow
Hi I like to make my Logo on my webpage a link to the index page.
I found this line of code: 
{{=TD(A(IMG(_src=URL(r=request,c='static',f='images/Logo.png')),_href=URL(r=request,f='index')))}}
But the web2py IMG function ignores the CSS tag which specifies that the 
logo should be adjusted to 12 columns.
Now the Logo is gigantic :-(
Can anyone help.

-- 





[web2py] Re: Examples for SQLFORM.grid oncreate, onupdate, ondelete

2012-06-27 Thread k0aun9
Maybe you've already found a way but here's for others who stumbled upon 
this thread from search. lol

I believe this should be the way

db.define_table('employee',
Field('name','string'),
Field('department','string')
)

inside the controller,

def do_something(form):
name = form.vars.name
department = form.vars.department

def employee_records():
grid = SQLFORM.grid(db.employee,oncreate=do_something)
return dict(grid=grid)

On Thursday, 1 March 2012 23:31:16 UTC+8, Tito Garrido wrote:
>
> Hey Folks,
>
> I have been reading the grid and smartgrid section of the book and I am 
> missing some examples on each parameter...
>
> Does anybody has examples of oncreate, onupdate and ondelete?
>
> Thanks!
>
> Tito
>
> -- 
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___
>

-- 





[web2py] Forms - MVC model

2012-06-27 Thread Pedro Casalinho
This may be a dumb question but, should forms be created in controllers and 
passed to the view or should they be created in the view, taking into 
consideration the MVC model

-- 





[web2py] Re: sending email with gmail has stopped working

2012-06-27 Thread Brandon Roberts
I have found our firewall was blocking port 587.  Once that was open, my 
emails started sending again. Check with your IT department.  

On Monday, June 11, 2012 6:17:04 AM UTC-4, david.waldrop wrote:
>
> I have several applications that use gmail to send invitations and for 
> authorization.  Recently they have both stopped working in the production 
> environments yet continue to work when running on my development machines. 
>  I have looked at the message boards and tried everything I saw 
> (ensuring the sender is form the same domain, changing the login 
> credentials, etc) but am still stuck.  Here is the basic config:
>
> ## configure email
> mail=auth.settings.mailer
> mail.settings.server = 'smtp.gmail.com:587'
> mail.settings.sender = 'x...@gmail.com'
> mail.settings.login = 'id:pw'
>
> My hunch is gmail is blocking the calls but I do not know how to diagnose 
> or fix.  Any ideas or suggestions would be greatly appreciated.  
>
>
>
>
>
On Monday, June 11, 2012 6:17:04 AM UTC-4, david.waldrop wrote:
>
> I have several applications that use gmail to send invitations and for 
> authorization.  Recently they have both stopped working in the production 
> environments yet continue to work when running on my development machines. 
>  I have looked at the message boards and tried everything I saw 
> (ensuring the sender is form the same domain, changing the login 
> credentials, etc) but am still stuck.  Here is the basic config:
>
> ## configure email
> mail=auth.settings.mailer
> mail.settings.server = 'smtp.gmail.com:587'
> mail.settings.sender = 'x...@gmail.com'
> mail.settings.login = 'id:pw'
>
> My hunch is gmail is blocking the calls but I do not know how to diagnose 
> or fix.  Any ideas or suggestions would be greatly appreciated.  
>
>
>
>
>
On Monday, June 11, 2012 6:17:04 AM UTC-4, david.waldrop wrote:
>
> I have several applications that use gmail to send invitations and for 
> authorization.  Recently they have both stopped working in the production 
> environments yet continue to work when running on my development machines. 
>  I have looked at the message boards and tried everything I saw 
> (ensuring the sender is form the same domain, changing the login 
> credentials, etc) but am still stuck.  Here is the basic config:
>
> ## configure email
> mail=auth.settings.mailer
> mail.settings.server = 'smtp.gmail.com:587'
> mail.settings.sender = 'x...@gmail.com'
> mail.settings.login = 'id:pw'
>
> My hunch is gmail is blocking the calls but I do not know how to diagnose 
> or fix.  Any ideas or suggestions would be greatly appreciated.  
>
>
>
>
>

-- 





Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-27 Thread Anthony

>
> > Yes, it does release the lock, as soon as the select is complete. You do 
> not 
> > have to do db.commit() after a select. 
> Please show me where that is documented. 
> Section 7 of http://www.sqlite.org/lockingv3.html says that ONLY 
> happens when autocommit is on, and you have stated that it is off 
> (contrary to my mistaken memory).


End of Section 4:

*Once all reading has completed, the SHARED lock is dropped.*

 

> Further, The Book says that only 
> inside of a Web2py app does commit/rollback back happen automatically.


Commit is not needed for a select. Committing is for committing *changes*to the 
database -- selects only read from the database.

Anthony

-- 





Re: [web2py] Form not processed on first submit

2012-06-27 Thread Anthony
Perhaps form.process() is failing the first time because the _formkey in 
the session isn't matching for some reason (don't know why, though).

Anthony

On Wednesday, June 27, 2012 8:42:56 AM UTC-4, Johann Spies wrote:
>
> Reloading the page after the form appeared the first time, works.  But why?
>
> Regards
> Johann
>
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>
>

-- 





[web2py] Re: How to populate list:reference field?

2012-06-27 Thread Anthony

>
> db.define_table( 
> 'group_of_events', 
> Field('group_name', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 
> 'group_of_events.group_name')]), 
> Field('events', 'list:reference db.event', requires=[IS_IN_DB(db, 
> 'event.id', '%(event_name)s [%(group_id)s]', multiple=True)])
>

When you put the IS_IN_DB validator in a list, you do not get the standard 
dropdown (for single items) or multiple select widget (for multiple items). 
Change the above to:

requires=IS_IN_DB(db, 'event.id', '%(event_name)s [%(group_id)s]', 
multiple=True)
Anthony

-- 





[web2py] long text in PluginMModal content

2012-06-27 Thread Marco Prosperi

hi all, I'm trying to put a long string as content of a PluginMModal but I 
face 2 problems:
- carriage returns in the string are not rendered (even if I put some \n in 
the string)
- characters with accents (it is an Italian text) are not shown correctly

how can I solve these?

thanks in advance for hints,

Marco

-- 





[web2py] long text as content for PluginMModal

2012-06-27 Thread Marco Prosperi

hi all, I'm putting a long text in a PluginMModal content but I face 2 
problems:
- carriage returns of the text are not respected (also if I put some \n in 
the string)
- characters with accents (it is an Italian string) are not shown correctly

which are the solutions?

thanks in advance

Marco

-- 





[web2py] Re: Two questions about models

2012-06-27 Thread Anthony

>
> 1. In the web2py book, there is an example for Auth settings, which 
> presumably resides at top-level inside a model:
>
> auth.settings.register_onaccept.append(lambda form: mail.send(to='
> y...@example.com', subject='new user', message="new user email is %s' % 
> form.vars.email))
>
> and I wonder where exactly do these 'form' and 'form.vars.email' variables 
> come from and how do we know which specific variables are available for 
> which functions in web2py, such information seems to be poorly documented 
> in the manual.
>
After accepting the submitted registration form, the register() function 
will pass the processed registration SQLFORM object to each 
register_onaccept function. It's just a regular SQLFORM object 
(post-processing), so it has form.vars, etc. Note, you don't have to call 
it "form" in your lambda function definition.
 

> 2. Is it advisable to organize models into different folders named by 
> their related controllers? For example, for all account-related 
> functionalities, I create a model called 'account.py' and put it at 
> 'my_app/models/account/account.py', so that only this model will be 
> executed for all account-related requests. Similarly, a model named 
> 'content.py' is created in 'my_app/models/content/content.py', so that only 
> this model will be executed for all the requests relating to user-generated 
> content. By doing this (as opposed to put all the models in 
> 'my_app/models/'), we can avoid executing models we don't need for certain 
> requests, but we may need to duplicate some code (e.g. create db 
> connections) for different models. Is this a good practice in web2py?
>
Yes, this is fine, but you shouldn't duplicate any code. Instead, if there 
is model code needed for more than one controller (including the database 
connection statement), you should put that in the root /models folder so it 
gets executed before the controller-specific model files.

Anthony 
 

-- 





Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-27 Thread Doug Philips
On Wed, Jun 27, 2012 at 10:13 AM, Anthony  wrote:
>> Again, with autocommit off:
>> The server process does a query/select to see if there is any work to
>> do. This provokes SQLite to acquire a SHARED lock. Then the server
>> process decides "oops, no work to do, let's go to sleep for a minute".
>> Notice that it does nothing to release that lock.
>
>
> Yes, it does release the lock, as soon as the select is complete. You do not
> have to do db.commit() after a select.

Please show me where that is documented.
Section 7 of http://www.sqlite.org/lockingv3.html says that ONLY
happens when autocommit is on, and you have stated that it is off
(contrary to my mistaken memory). Further, The Book says that only
inside of a Web2py app does commit/rollback back happen automatically.
Thanks,
--Doug

-- 





Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-27 Thread Niphlod
Some nice assumptions here... are you actually suggesting that:
- could ever be a stable release of web2py out there that will hold the 
lock for any pending select ?
- the book suggesting a good behaviour is absolutely wrong ?

Web2py developers and testers in general would spot that in a breeze while 
testing trunk, and it'll be fixed in the following stable release.

There are no evil people among web2py trying to make queries go slower, 
block wherever they want your code, and generally having to make you code 
crappy workarounds.

Anyway, if you are so concerned about those problems and want to mantain 
your own forked DAL version where you are in control of every aspect, be my 
guest. but it kind of defeat the "I'll adopt a framework" paradigm.
When you face something like frameworks, you have to "give some credit" to 
the fact that n contributors, often very well versed in at least the piece 
of code they submitted/tested/patched - the 90% of the times surely more 
informed than yourself - did a good job.


-- 





Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-27 Thread Anthony

>
> Again, with autocommit off: 
> The server process does a query/select to see if there is any work to 
> do. This provokes SQLite to acquire a SHARED lock. Then the server 
> process decides "oops, no work to do, let's go to sleep for a minute". 
> Notice that it does nothing to release that lock.


Yes, it does release the lock, as soon as the select is complete. You do 
not have to do db.commit() after a select.

Anthony

-- 





Re: [web2py] Two questions about models

2012-06-27 Thread Jonathan Lundell
On Jun 27, 2012, at 5:52 AM, cyan wrote:
> 1. In the web2py book, there is an example for Auth settings, which 
> presumably resides at top-level inside a model:
> 
> 
> auth.settings.register_onaccept.append(lambda form: 
> mail.send(to='y...@example.com', subject='new user', message="new user email 
> is %s' % form.vars.email))
> 
> and I wonder where exactly do these 'form' and 'form.vars.email' variables 
> come from and how do we know which specific variables are available for which 
> functions in web2py, such information seems to be poorly documented in the 
> manual.
> 

'form' here is a formal argument to the lambda expression, and not otherwise a 
variable. Have a look at the standard Python docs for more on lambdas.

web2py globals have their own section in the book: 
http://web2py.com/books/default/chapter/29/4#API
> 2. Is it advisable to organize models into different folders named by their 
> related controllers? For example, for all account-related functionalities, I 
> create a model called 'account.py' and put it at 
> 'my_app/models/account/account.py', so that only this model will be executed 
> for all account-related requests. Similarly, a model named 'content.py' is 
> created in 'my_app/models/content/content.py', so that only this model will 
> be executed for all the requests relating to user-generated content. By doing 
> this (as opposed to put all the models in 'my_app/models/'), we can avoid 
> executing models we don't need for certain requests, but we may need to 
> duplicate some code (e.g. create db connections) for different models. Is 
> this a good practice in web2py?
> 

I'd say it's generally premature optimization.

That said, I do a little of that myself, but via conditional logic in a common 
model (db.py) that looks at request.controller to decide which actions to take.

-- 





Re: [web2py] PythonAnywhere issue with mercurial

2012-06-27 Thread Richard Vézina
Maybe this could help :
http://www.web2pyslices.com/slice/show/1433/mercurial-plugin

I don't know if it still the same but branching was not supported.

Richard

On Wed, Jun 27, 2012 at 5:57 AM, Nico Zanferrari  wrote:

> Hello!
>
> I'm currently playing with PythonAnywhere (http://www.pythonanywhere.com).
> Among tons of other features, it allows you to create a free Web2py site
> with a quick setup procedure.
> With https you can use the usual Administrative interface, but I was not
> able to use its versioning feature. It says "Sorry, could not find
> mercurial installed". In fact, mercurial is installed in the system but I
> am not able to make Web2py able to see / use it.
>
> Any ideas?
>
> Thank you,
> Nico
>
> --
>
>
>
>

-- 





Re: [web2py] How to populate list:reference field?

2012-06-27 Thread Richard Vézina
Maybe this could help :
http://web2py.com/books/default/chapter/29/14?search=dummy#Populating-database-with-dummy-data

On Wed, Jun 27, 2012 at 4:13 AM, Alec Taylor  wrote:

> Here's a simple test-case:
>
> # Models
> db.define_table(
>'group_of_events',
>Field('group_name', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
> 'group_of_events.group_name')]),
>Field('events', 'list:reference db.event', requires=[IS_IN_DB(db,
> 'event.id', '%(event_name)s [%(group_id)s]', multiple=True)]), #
> populate with: WHERE db.event.group_id == self.id
>format='%(group_name)s'
> )
>
> db.define_table(
>'event',
>Field('event_name', requires=IS_NOT_EMPTY()),
>Field('group_id', 'reference db.group_of_events'),
>format='%(event_name)s'
> )
>
> # Controllers
> def index():
>return dict(groups_list=SQLTABLE(db().select(db.group_of_events.ALL)))
>
> # Views
> {{if 'groups_list' in globals():}}
> {{=groups_list}}
> {{else:}}
> group_list not found :\
> {{pass}}
>
> # {{pass}}!
>
> How do I populate the group_of_events events field with events from
> the event table?
>
> Thanks for all suggestions,
>
> Alec Taylor
>
> --
>
>
>
>

-- 





[web2py] Re: Two questions about models

2012-06-27 Thread Cliff Kachinske
Look here for more information about Auth and auth:  
http://web2py.com/books/default/chapter/29/3#Adding-Authentication

Having your models in different folders can reduce the overhead per 
request.  

When your controller uses multiple tables , you can use symbolic links to 
bring in the models you need.  Models execute in alphabetical order, which 
has implications for foreign keys.  Name your soft links accordingly.


On Wednesday, June 27, 2012 8:52:11 AM UTC-4, cyan wrote:
>
>
> Hi,
>
> 1. In the web2py book, there is an example for Auth settings, which 
> presumably resides at top-level inside a model:
>
> auth.settings.register_onaccept.append(lambda form: mail.send(to='
> y...@example.com', subject='new user', message="new user email is %s' % 
> form.vars.email))
>
> and I wonder where exactly do these 'form' and 'form.vars.email' variables 
> come from and how do we know which specific variables are available for 
> which functions in web2py, such information seems to be poorly documented 
> in the manual.
>
> 2. Is it advisable to organize models into different folders named by 
> their related controllers? For example, for all account-related 
> functionalities, I create a model called 'account.py' and put it at 
> 'my_app/models/account/account.py', so that only this model will be 
> executed for all account-related requests. Similarly, a model named 
> 'content.py' is created in 'my_app/models/content/content.py', so that only 
> this model will be executed for all the requests relating to user-generated 
> content. By doing this (as opposed to put all the models in 
> 'my_app/models/'), we can avoid executing models we don't need for certain 
> requests, but we may need to duplicate some code (e.g. create db 
> connections) for different models. Is this a good practice in web2py?
>

-- 





Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-27 Thread Anthony

>
> Well, earlier it was claimed that the DAL for SQLite left autocommit 
> on,


A quote from my earlier response:

*web2py is just using the Python standard library sqlite3 module. According 
to the 
docs,
 
it looks like it does not default to autocommit mode.*


So now I have an extra place to go look and try to figure out, does 
> the DAL actually implement DBAPI with autocommit or does the DAL 
> implement DBAPI but with an exception re: autocommit? Having more 
> places to look is not 'ease of documentation' from a user's 
> perspective. :-/ 
>

The DAL does not implement DBAPI at all. The DAL simply uses Python drivers 
for databases, and those drivers are supposed to implement the DBAPI 
specifications (and it looks like the SQLite driver does correctly 
implement the specification regarding autocommit). More importantly, it 
appears that autocommit is irrelevant to the issue at hand.
 

> It matters if the query at the top of the loop holds a lock on the DB, 
> which means that when there are no rows found to process, the database 
> remains locked while the server is sleeping...
>

No, that's my point, it doesn't matter. The shared lock only lasts as long 
as it takes to read the records -- by the time it hits the for loop (even 
if the loop doesn't get entered due to no records), the shared lock is 
released. Whether or not autocommit is on shouldn't matter, so there's 
nothing in particular to document here that makes a difference for how to 
code a background task like this. As the docs say, when making changes to 
the db outside an HTTP request (e.g., in a background task script), do 
db.commit(). Other than that, nothing to worry about.

Anthony

-- 





Re: [web2py] Re: static files extending layout.html

2012-06-27 Thread Jonathan Lundell
On Jun 27, 2012, at 6:15 AM, Massimo Di Pierro wrote:
> Me neither but look into routes.

There's an obscure reason that this message can be generated: if init/compiled/ 
exists, but init/compiled/controllers_default_generic.pyc does not, you'll get 
it.

(The main reason is that the controller exists but the function-finding regex 
doesn't find the function.)

> 
> On Wednesday, 27 June 2012 01:40:50 UTC-5, Annet wrote:
> I have the following menu:
> 
> response.util_menu=[
> ['Disclaimer',request.function=='generic' and 
> request.args(0)=='disclaimer',URL('util','generic',args='disclaimer')],
> ['Privacy',request.function=='generic' and 
> request.args(0)=='privacy',URL('util','generic',args='privacy')],
> ['Copyright',request.function=='generic' and 
> request.args(0)=='copyright',URL('util','generic',args='copyright')],
> ['Cookies',request.function=='generic' and 
> request.args(0)=='cookies',URL('util','generic',args='cookies')],
> ['Site map',request.function=='generic' and 
> request.args(0)=='sitemap',URL('util','generic',args='sitemap')],
> ['Contact',request.function=='contact',URL('util','contact')]]
> 
> ... and in a controller util.py the following function:
> 
> def generic():
> if request.args(0) in 
> ['disclaimer','privacy','copyright','cookies','sitemap']:
> response.view='util/' + str(request.args(0)) + '.html'
> else:
> redirect(URL('default','error'))
> return dict()
> 
> ... and the following view named util/disclaimer.html:
> 
> {{extend 'default/layout.html'}}
> 
> 
>   
> Disclaimer text here
>
>  
> 
> When I request: http://127.0.0.1:8000/init/util/generic/disclaimer
> I get: invalid function (default/util)
> 
> I don't understand why.


-- 





Re: [web2py] Re: web2py crashing

2012-06-27 Thread Jonathan Lundell
On Jun 27, 2012, at 6:12 AM, Massimo Di Pierro wrote:
> We acn catch it but what do we do? Report "this is a python bug"?

The crash is a python bug. The connection failure isn't (near as I can tell). 
Just treat it as a dropped connection.

> 
> On Tuesday, 26 June 2012 20:01:49 UTC-5, Jonathan Lundell wrote:
> On Jun 26, 2012, at 5:25 PM, Massimo Di Pierro wrote:
>> Looks like a buggy socket.py or ssl.py. Is this an occasional error (which 
>> may depend on parameters such as certificates) or it reproducible?
> 
> This was fixed in Python 2.7. The underlying error is "Transport endpoint is 
> not connected", which of course shouldn't cause a crash. I suppose we could 
> catch the exception in Rocket as a workaround.
> 


-- 





[web2py] Re: static files extending layout.html

2012-06-27 Thread Massimo Di Pierro
Me neither but look into routes.

On Wednesday, 27 June 2012 01:40:50 UTC-5, Annet wrote:
>
> I have the following menu:
>
> response.util_menu=[
> ['Disclaimer',request.function=='generic' and 
> request.args(0)=='disclaimer',URL('util','generic',args='disclaimer')],
> ['Privacy',request.function=='generic' and 
> request.args(0)=='privacy',URL('util','generic',args='privacy')],
> ['Copyright',request.function=='generic' and 
> request.args(0)=='copyright',URL('util','generic',args='copyright')],
> ['Cookies',request.function=='generic' and 
> request.args(0)=='cookies',URL('util','generic',args='cookies')],
> ['Site map',request.function=='generic' and 
> request.args(0)=='sitemap',URL('util','generic',args='sitemap')],
> ['Contact',request.function=='contact',URL('util','contact')]]
>
> ... and in a controller util.py the following function:
>
> def generic():
> if request.args(0) in 
> ['disclaimer','privacy','copyright','cookies','sitemap']:
> response.view='util/' + str(request.args(0)) + '.html'
> else:
> redirect(URL('default','error'))
> return dict()
>
> ... and the following view named util/disclaimer.html:
>
> {{extend 'default/layout.html'}}
>
> 
>   
> Disclaimer text here
>
>  
>
> When I request: http://127.0.0.1:8000/init/util/generic/disclaimer
> I get: invalid function (default/util)
>
> I don't understand why.
>
>
> Annet.
>

-- 





[web2py] Re: App does not exist or your are not authorized when deploying layout plugin

2012-06-27 Thread Massimo Di Pierro
A plugin is a tar gzipped file. The admin interface only allow you to tar 
gzip files and folder with the plugin_* prefix but from the shell there is 
no similtation

cd applications/yourapp
tar zcvf web2py.plugin.name.w2p [list of files to include]

if you include views/layout.html  you will accomplish the goal.

On Wednesday, 27 June 2012 00:09:16 UTC-5, François Delpierre wrote:
>
> Ok, so it means that the solution from Massimo is not working anymore :
> http://permalink.gmane.org/gmane.comp.python.web2py/71241
>
> How can I then make plugins that automatically change the layout of the 
> application without having to leave web interface ?
>
> That's strange, as one of the downloadable layout does exactly that, and 
> works :
> pivert@skinner:~/Downloads$ tar -ztvf web2py.plugin.layout_Compromise.w2p 
> -rw-r--r-- mdipierro/staff 5559 2010-11-03 17:09 views/layout.html
> -rw-r--r-- mdipierro/staff 3359 2010-11-03 17:03 
> static/plugin_layouts/superfish.css
> -rw-r--r-- mdipierro/staff 3714 2010-11-03 17:03 
> static/plugin_layouts/superfish.js
> -rw-r--r-- mdipierro/staff 5559 2010-11-03 17:07 
> views/plugin_layouts/layouts/Compromise.html
> drwxr-xr-x mdipierro/staff0 2010-10-20 07:09 
> static/plugin_layouts/layouts/Compromise/
> drwxr-xr-x mdipierro/staff0 2010-10-20 07:09 
> static/plugin_layouts/layouts/Compromise/images/
> -rw-r--r-- mdipierro/staff 6452 2010-10-20 07:09 
> static/plugin_layouts/layouts/Compromise/index.html
> -rw-r--r-- mdipierro/staff 13901 2010-10-20 07:09 
> static/plugin_layouts/layouts/Compromise/license.txt
> -rw-r--r-- mdipierro/staff 18861 2010-10-20 07:09 
> static/plugin_layouts/layouts/Compromise/preview.png
> -rw-r--r-- mdipierro/staff  4856 2010-10-20 07:09 
> static/plugin_layouts/layouts/Compromise/style.css
> -rw-r--r-- mdipierro/staff  1631 2010-10-20 07:09 
> static/plugin_layouts/layouts/Compromise/images/img01.gif
> -rw-r--r-- mdipierro/staff   413 2010-10-20 07:09 
> static/plugin_layouts/layouts/Compromise/images/img02.jpg
> -rw-r--r-- mdipierro/staff  2496 2010-10-20 07:09 
> static/plugin_layouts/layouts/Compromise/images/img03.jpg
> -rw-r--r-- mdipierro/staff  9087 2010-10-20 07:09 
> static/plugin_layouts/layouts/Compromise/images/img04.jpg
> -rw-r--r-- mdipierro/staff  2989 2010-10-20 07:09 
> static/plugin_layouts/layouts/Compromise/images/img05.gif
>
>
>

-- 





Re: [web2py] Re: web2py crashing

2012-06-27 Thread Massimo Di Pierro
We acn catch it but what do we do? Report "this is a python bug"?

On Tuesday, 26 June 2012 20:01:49 UTC-5, Jonathan Lundell wrote:
>
> On Jun 26, 2012, at 5:25 PM, Massimo Di Pierro wrote:
>
> Looks like a buggy socket.py or ssl.py. Is this an occasional error (which 
> may depend on parameters such as certificates) or it reproducible?
>
>
> This was fixed in Python 2.7. The underlying error is "Transport endpoint 
> is not connected", which of course shouldn't cause a crash. I suppose we 
> could catch the exception in Rocket as a workaround.
>
>
> On Tuesday, 26 June 2012 12:30:58 UTC-5, msmagoo wrote:
>>
>> Hi all,
>>
>> I have a healthcheck web2py application that simply reads healthcheck 
>> information from a database and makes a few REST api calls to a separate 
>> web2py application. Over the past while the application has been crashing 
>> at least once, sometimes twice a day with few errors in the logs. Most are 
>> connection reset by peer errors, which I found out to be nothing that would 
>> crash the application. An error I have been seeing frequently is:
>> ERROR:Rocket.Errors.Thread-8:Traceback (most recent call last):
>>
>>   File "/opt/apps/web2py/gluon/rocket.py", line 1302, in run
>> self.run_app(conn)
>>
>>   File "/opt/apps/web2py/gluon/rocket.py", line 1986, in run_app
>> self.environ = environ = self.build_environ(sock_file, conn)
>>
>>   File "/opt/apps/web2py/gluon/rocket.py", line 1807, in build_environ
>> request = self.read_request_line(sock_file)
>>
>>   File "/opt/apps/web2py/gluon/rocket.py", line 1363, in read_request_line
>> d = sock_file.readline()
>>
>>   File "/usr/lib/python2.6/socket.py", line 406, in readline
>> data = self._sock.recv(self._rbufsize)
>>
>>   File "/usr/lib/python2.6/ssl.py", line 96, in 
>> self.recv = lambda buflen=1024, flags=0: SSLSocket.recv(self, buflen, 
>> flags)
>>
>>   File "/usr/lib/python2.6/ssl.py", line 224, in recv
>> return socket.recv(self, buflen, flags)
>>
>> TypeError: 'member_descriptor' object is not callable
>>
>> ERROR:Rocket.Errors.Thread-8:Tried to send "500 Server Error" to client 
>> but received socket error
>>
>>
>> I have web2py running on https with some certs set up. Any help would be 
>> very appreciated.
>>
>> Thanks!
>>
>
>
>
>
>

-- 





[web2py] Two questions about models

2012-06-27 Thread cyan


Hi,

1. In the web2py book, there is an example for Auth settings, which 
presumably resides at top-level inside a model:

auth.settings.register_onaccept.append(lambda form: mail.send(to=
'y...@example.com', subject='new user', message="new user email is %s' % 
form.vars.email))

and I wonder where exactly do these 'form' and 'form.vars.email' variables 
come from and how do we know which specific variables are available for 
which functions in web2py, such information seems to be poorly documented 
in the manual.

2. Is it advisable to organize models into different folders named by their 
related controllers? For example, for all account-related functionalities, 
I create a model called 'account.py' and put it at 
'my_app/models/account/account.py', so that only this model will be 
executed for all account-related requests. Similarly, a model named 
'content.py' is created in 'my_app/models/content/content.py', so that only 
this model will be executed for all the requests relating to user-generated 
content. By doing this (as opposed to put all the models in 
'my_app/models/'), we can avoid executing models we don't need for certain 
requests, but we may need to duplicate some code (e.g. create db 
connections) for different models. Is this a good practice in web2py?

-- 





Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-27 Thread Doug Philips
On Sat, Jun 23, 2012 at 1:24 PM, Anthony  wrote:
> No, when autocommit is disabled, that doesn't immediately result in a shared
> lock being acquired and held indefinitely. A shared lock is acquired when a
> select is made, but only held as long as it takes to actually do the reading
> for that select. Just do a commit after your inserts/updates/deletes, and
> you should be fine.

I don't think you are understanding, I'm not concerned about the case
when the query/select finds work to do, I'm concerned about the case
when the server looks, and finds nothing. I agree, when autocommit is
on, the lock will be dropped after the query returns. However, it
autocommit is off, and again referring to
http://www.sqlite.org/lockingv3.html section 7:
  "After a BEGIN command, a SHARED lock will be acquired when the
first SELECT statement is executed. ... The SQL command "COMMIT" does
not actually commit the changes to disk. It just turns autocommit back
on."

Again, with autocommit off:
The server process does a query/select to see if there is any work to
do. This provokes SQLite to acquire a SHARED lock. Then the server
process decides "oops, no work to do, let's go to sleep for a minute".
Notice that it does nothing to release that lock. So the Web2py
process is now locked out of doing any updates because the SHARED lock
will block the acquisition of locks needed to actually write/update
the database. I didn't find anything in the SQLite documentation that
would indicate otherwise, but if you do, please point me to the
specific document/section. (I just searched through The Book again and
found no mention of autocommit. Searching for just 'commit' finds only
a handful of places that make no mention of it either.)



>> Since the documentation about what the DAL uses/needs/assumes about
>> the underlying Python layer (pysqlite in this case) isn't there, its
>> just easier to avoid using it outside of a Web2py application.
>
>
> Seems rather extreme. What information do you need that would impact your
> usage? Note, the good thing about open source is that you can just look at
> the source code.

Technically True. And that has allowed me to do my own work arounds
(and submit patches), which has been extremely helpful.
So for fixing bugs, it's great!
However...
One of the things I really like about Web2py is the promise of
backwards compatibility.
Is that promise meant to encompass all the current decisions embodied
in the implementation?
I wouldn't assume so.
The Book does not say: "For anything not covered here, read the source
and base your expectation of backwards compatibility on that."
The Book does say: "web2py has always been built from the user
perspective and is constantly optimized internally to become faster
and leaner, whilst always maintaining backward compatibility." and
"The source code of the Database Abstraction Layer was completely
rewritten in 2010. While it stays backward compatible, the rewrite
made it more modular and easier to extend."
So I should fully expect the implementation to change; anything I find
by "reading the source" is clearly something that is, and has been,
subject to change. Sorry, but the only sane thing to do is to rely
only on what is documented and covered under the blanket promise of
backwards compatibility.

-=D

-- 





Re: [web2py] Form not processed on first submit

2012-06-27 Thread Johann Spies
Reloading the page after the form appeared the first time, works.  But why?

Regards
Johann


-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-27 Thread Doug Philips
On Sat, Jun 23, 2012 at 1:54 PM, Anthony  wrote:
>> > You're forgetting another "layer".  DAL leverages on DBAPI
>> > implementation of sql drivers.
>>
>> Well, that's not exactly good news for transparency and ease of
>> documentation.
>
> DB API is just a specification for Python database drivers to follow to
> ensure some degree of similarity and
> portability: http://www.python.org/dev/peps/pep-0249/. On net, this is
> probably good news for transparency and ease of documentation because you
> have some consistency across drivers. What alternative would you propose for
> greater transparency and ease of documentation?

Well, earlier it was claimed that the DAL for SQLite left autocommit
on, but the DBAPI says:
"Note that if the database supports an auto-commit feature, this must
be initially off."
So now I have an extra place to go look and try to figure out, does
the DAL actually implement DBAPI with autocommit or does the DAL
implement DBAPI but with an exception re: autocommit? Having more
places to look is not 'ease of documentation' from a user's
perspective. :-/


> Again, what specific assumptions about the "intermediate glue layers" would
> affect the code you would write in this case? If the issue is
> auto-committing, I believe the recommended code would work in either case.
> I'm not saying I would mind seeing a little more documentation regarding the
> differences across some of the databases and their drivers -- I'm just
> wondering how much it matters in this particular case.

It matters if the query at the top of the loop holds a lock on the DB,
which means that when there are no rows found to process, the database
remains locked while the server is sleeping...

-=Doug

-- 





Re: [web2py] Form not processed on first submit

2012-06-27 Thread Johann Spies
On 27 June 2012 12:12, stefaan  wrote:

>
>>  I cannot solve your problem, but if all else fails it may help to insert
> print statements in the controller, to see which lines you reach,
> so you can find out if e.g. one of the lines that come before the call to
> form.process() throws an exception.
>

Have done that.  In the first round it just bypasses the form.process()
block.

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





[web2py] Webservice to upload files

2012-06-27 Thread Adriano Almeida
Hello Gentleman

Is this possible to create a webservice with web2py to upload files 
(ex:pictures)? How could this be done if I want to have some security 
(password verification) on it?

I would like to integrate a web2py service with a mobile  application, 
dropbox style. 

Thanks in advance

Adriano

-- 





Re: [web2py] Form not processed on first submit

2012-06-27 Thread stefaan

>
>
>  I cannot solve your problem, but if all else fails it may help to insert 
print statements in the controller, to see which lines you reach, 
so you can find out if e.g. one of the lines that come before the call to 
form.process() throws an exception.

-- 





[web2py] PythonAnywhere issue with mercurial

2012-06-27 Thread Nico Zanferrari
Hello! 

I'm currently playing with PythonAnywhere (http://www.pythonanywhere.com). 
Among tons of other features, it allows you to create a free Web2py site 
with a quick setup procedure.
With https you can use the usual Administrative interface, but I was not 
able to use its versioning feature. It says "Sorry, could not find 
mercurial installed". In fact, mercurial is installed in the system but I 
am not able to make Web2py able to see / use it.

Any ideas?

Thank you,
Nico

-- 





Re: [web2py] Form not processed on first submit

2012-06-27 Thread Johann Spies
form=SQLFORM.factory(db.akb_articles)

the .factory was not originally there and is not now.  I just used it to
see if I the process worked if I manually insert the data.

That line should read form=SQLFORM(db.akb_articles)

The problem is still a problem.

Thanks for your attention.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





[web2py] How to populate list:reference field?

2012-06-27 Thread Alec Taylor
Here's a simple test-case:

# Models
db.define_table(
'group_of_events',
Field('group_name', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
'group_of_events.group_name')]),
Field('events', 'list:reference db.event', requires=[IS_IN_DB(db,
'event.id', '%(event_name)s [%(group_id)s]', multiple=True)]), #
populate with: WHERE db.event.group_id == self.id
format='%(group_name)s'
)

db.define_table(
'event',
Field('event_name', requires=IS_NOT_EMPTY()),
Field('group_id', 'reference db.group_of_events'),
format='%(event_name)s'
)

# Controllers
def index():
return dict(groups_list=SQLTABLE(db().select(db.group_of_events.ALL)))

# Views
{{if 'groups_list' in globals():}}
{{=groups_list}}
{{else:}}
group_list not found :\
{{pass}}

# {{pass}}!

How do I populate the group_of_events events field with events from
the event table?

Thanks for all suggestions,

Alec Taylor

-- 





  1   2   >