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

2012-06-22 Thread Doug Philips
On Wed, Jun 20, 2012 at 9:06 PM, Anthony  wrote:
>> Sooo Have I misunderstood the SQLite locking description?
>
>
> I believe so. The shared lock does not last forever -- only as long as it
> takes to execute the select. Once the data have been read, the shared lock
> (for that particular select) is released.

Yes, if autocommit is on. The part you didn't quote was that
autocommit can be disabled in which case a SHARED lock is held.
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.

Thanks for all the help,
   -Doug

-- 





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

2012-06-22 Thread Doug Philips
On Wed, Jun 20, 2012 at 7:04 PM, Niphlod  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.

> A little more complicated: get on an infinite loop inserting 10 rows,
> without committing. while the loop is running on 1, try a loop of 100
> updates to those records, then commit. Occasionally you'll be presented with
> "Database is locked" error.

OK.

But what I would prefer to do is actually reason about what should be
happening rather than just slapping code together and trying to hope
that my tests will be close enough to real world scenarios to be
valid.

Sure, there is documentation about the quirks of SQLite, but nothing
(unless I've missed it after repeated reading) about the
assumptions/defaults, etc of how the DAL uses the intermediate glue
layers (pysqlite, etc.). At this point, I think I'll just avoid using
the DAL unless it is part of the web2py application, it's easier to
write the external server to talk directly to the relevant database.

Thanks for your help!
-=Doug

-- 





[web2py] Re: How to remove 'default' from all URLs?

2012-06-22 Thread Annet
Hi Alec,

I had a routes related problem a few weeks ago. Jonathan and Anthony helped 
me solve it. The routes.py file that works i.e. remove default from the url 
reads like:


# -*- coding: utf-8 -*-

routers = dict(
   BASE = dict(
   default_application = 'init',
   applications = 'ALL',
   default_controller = 'default',
   controllers = 'DEFAULT',
   default_function = 'index',
   ),
   init = dict(
default_function = 'index',
functions =  ['index','user','register','basicRegister',
   'download','call','data','error']
   )
)


Kind regards,

Annet

-- 





[web2py] Re: How to remove 'default' from all URLs?

2012-06-22 Thread Annet
Hi Alec,

I had a routes related problem a few weeks ago. Jonathan and Anthony helped 
me solve it. The routes.py file that works i.e. remove default from the url 
reads like:


# -*- coding: utf-8 -*-

routers = dict(
   BASE = dict(
   default_application = 'init',
   applications = 'ALL',
   default_controller = 'default',
   controllers = 'DEFAULT',
   default_function = 'index',
   ),
   init = dict(
default_function = 'index',
functions =  ['index','user','register','basicRegister',
   'download','call','data','error']
   )
)


Kind regards,

Annet

-- 





[web2py] Re: bootstrap carousel web2py Nightly build

2012-06-22 Thread LightDot
Hi Paolo,

you're quite right about the amount of work needed to spot and properly 
resolve such css collisions. There are quite a few left too... I'm working 
on several projects using Bootstrap and dev web2py, so I needed a tool to 
let me anticipate possible problems.

I made a simple plugin out of it, "Bootstrap Plugin", here is a short 
description and the 
download,
 
perhaps it'll be useful to you or anyone else.

Regards,
Ales


On Wednesday, June 20, 2012 10:45:53 PM UTC+2, Paolo Caruccio wrote:
>
> @Andrew
>
> Yes. We could change the file, currently named bootswatch.css, to 
> automatize bootstrap carousel in web2py, but next time, when we will found 
> an incompatibility between bootstrap.min.css and web2py.css, we will have 
> to update again bootswatch.css. I don't think that it's good thing - in 
> this case - to update frequently a web2py file but it's better submit a big 
> patch. We should test all bootstrap's features to correct the eventual 
> collisions with web2py.css
>
> @LightDot
>
> Finding every collision between web2py.css and bootstrap.css it's not 
> simple and take much time, but the target will be achieved by testing the 
> bootstrap's features and by removing the collisions that will be meet. On 
> the other hand, it's my opinion that web2py developers didn't want 
> "bootstrapize" (what ugly word!) all our loved framework, but only the 
> topbar.
>
> Il giorno martedì 19 giugno 2012 21:35:42 UTC+2, Paolo Caruccio ha scritto:
>>
>> I'm building an app for trying carousel feature and I met the same your 
>> issue.
>>
>> My solution (note style statement):
>>
>> > style="width:40px;float:none;text-align:center;">›
>>
>> Maybe you should adapt the width to your necessity.
>>
>> The inline css style overwrites the ".right" rule in web2py.css
>>
>>
>> Il giorno martedì 19 giugno 2012 19:25:07 UTC+2, dundee ha scritto:
>>>
>>> Hey all,
>>>
>>> Anyone trying to use carousel in web2py nightly build?
>>> I used it exactly as stated on the bootstrap web site. However, the 
>>> controls are not rendered properly and I can only the next button works.
>>> The controls are positioned correctly but a big border is around the 
>>> controls.
>>>
>>> 
>>> ‹
>>> 
>>> ›
>>>
>>>
>>> I have attached a screenshot.
>>>
>>> Thanks.
>>>
>>

-- 





[web2py] Using admin interface on GAE, getting errors on update or insert

2012-06-22 Thread mike haberman
New to web2py and GAE.  But with a very simple example, I 
am unable to use web2py admin interface to modify the database

Using the admin interface for an application,
I can navigate to 'Administrative Interface' --> Applications --> (blog) 
 Edit --> Models --> database administration

I can update/insert on any of the auth_ tables
but I get the following error on any table that I create within models for 
web2py

 no matching 
index found. 
The suggested index for this query is: - kind: auth_user properties: - 
name: first_name - name: last_name

Is there something I need to do to the model definition to avoid this error 
?

(Also when trying to create a new entity via GAE's Datastore viewer, some 
fields are missing 
even though it displays all the fields for each entity from a query.  Is 
there something by default that
makes some fields not show up?)


thanks

mike

-- 





[web2py] Cygwin directory problem and plugin.wiki install

2012-06-22 Thread weldja
Hi
 
I am trying to install  plugin_wiki (add-on) but have a problem.
The plugin is downloaded to my Windows laptop c:/tmp/web2py.plugin.wiki.w2p
When I try to upload the plugin to my web2py 
http://127.0.0.1:8000/admin/default/design/myapp | edit | plugins, browse 
to c:/tmp/web2py.plugin.wiki.w2p & upload - I get a ticket:
 
  [Errno 2] No such file or directory: 
'/home/weldja/web2py/deposit/C:/tmp/web2py.plugin.wiki.w2p'
 
How should I handle the directory naming  in this cygwin installation so 
that Web2py can see the plugin
 
I am new to web2py.
 
Thanks
 
__Web2py_on_cygwin__
$ python web2py.py
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.99.7 (2012-03-04 22:12:08) stable
Database drivers available: SQLite3, pymysql, pg8000, IMAP
Starting hardcron...
choose a password:1234
please visit:
http://127.0.0.1:8000
use "kill -SIGTERM 9644" to shutdown the web2py server

-- 





[web2py] Web2py and pyjamas - redirecting controller to pyjamas html file

2012-06-22 Thread Daniel Gonzalez
Hi there,

Just starting in web2py, I hope I am getting things right. My setup is 
slightly complicated for a newbie, so I am running into tons of issues.

I am serving a pyjamas application with web2py. The backend will be in 
web2py, the frontent in pyjamas.
I have found this nice article on how to integrate 
both: http://web2py.com/books/default/chapter/29/10#JSONRPC-and-Pyjamas

I had to modify it a bit, since pyjamas has evolved. This is my view in 
default/todoAppl.html:


  


  Activity

  
  


  


Somehow this is loading the pyjamas application (I am not sure what the 
meta tag is doing there, but it is needed).
But actually, this solution is putting my pyjamas frontend inside an 
iframe, and my pyjamas CSSs are not being loaded.

What I would like at this stage is to completely skip the view, and 
redirect the /default/todoApp url to my pyjamas html, which is 
located in static/output/Portal.html.
I do not want to load the view in default/todoApp.html, but I guess I just 
want to tell the controller to load static/output/Portal.html.
Also, I do not want to issue a redirect to the browser. I just want web2py 
to know that the associated html is not in the usual views/default 
location, but in another place.
Is this at all possible in web2py?

BR,
Daniel

-- 





[web2py] Web2py and pyjamas - redirecting controller to pyjamas html

2012-06-22 Thread Daniel Gonzalez
Hi there,

I am starting with web2by, and my first project is a bit convoluted, so I 
am running into lots of different problems.

My goal is to have a web application with web2py for the backend 
operations, interfacing with a pyjamas frontend, via JSONRPC.
There is a nice article describing this setup here:
http://web2py.com/books/default/chapter/29/10#JSONRPC-and-Pyjamas

This is my views/default/todoApp.html (slightly modified, since pyjamas has 
evolved a bit):


  


  Activity

  
  


  


This is loading my pyjamas frontend, but inside an iframe. As a result, my 
CSSs are not loaded.
What I would like is to completely skip the views/default/todoApp.html.
I want to tell my controller (I guess this is the term) to serve my pyjamas 
html directly, not via the view template.
The pyjamas html is located in static/output/Portal.html.

I do not know how to do this. I guess I need a king of "redirect" directive 
for the web2py engine.
But it is important that this does not issue a redirect to the browser. It 
must be a web2py internal thing, which tells the engine that it must serve 
the html in the alternate location, instead of serving the usual view in 
/views/default/.html

Is this at all possible in web2py?

Thanks,
Daniel Gonzalez

-- 





[web2py] Re: unique field with case insensitivity

2012-06-22 Thread Corey Marques
OK, maybe this is a better question. How to I specify that the column is 
NOCASE using the DAL?


On Wednesday, June 20, 2012 4:33:55 PM UTC-4, Corey Marques wrote:
>
> Howdy,
>
> I'm trying to put together a quick proof of concept to use this framework 
> for porting our desktop application to the web.
>
> I ran into an issue where unique fields don't follow our rules. In our 
> database the 'nickname' field is unique and "JOE" is the same as "joe".
>
> I did a quick search and couldn't find an elegant solution to this 
> problem. I was hoping for something like
>
> Field('nickname', unique_ignore_case=True)
>
> Is there a simple and efficient way to do this? The only solution I was 
> able to find involved duplicating the field on the table and saving both 
> the field and it's lowercase equivalent.  
>
> Thanks for your time.
>
> Corey.
>

-- 





Re: [web2py] DAL performance vs executesql

2012-06-22 Thread pbreit
Interesting, I'll try that out.

I can see a million rows being slow but seems 5,000 should move pretty 
well. With the increasing usage of Javascript frameworks, it seems like 
more data is being retrieved for manipulating on the front-end. But in that 
case you just need JSON, I think with minimal processing by the server.

-- 





Re: [web2py] DAL performance vs executesql

2012-06-22 Thread Niphlod
BTW, 1) is quite achievable if not selecting from multiple tables (i.e. no 
print db.dogs.name, db.person.name) in a breeze:
from gluon.storage import Storage
raw_rowset = db.executesql("thequery", as_dict=True)
myrowset = [Storage(row) for row in raw_rowset]

No time to patch DAL's executesql and test the improvement in time right 
now but if in the need I could provide it.

On Saturday, June 23, 2012 12:14:02 AM UTC+2, Niphlod wrote:
>
>
>  @pbreit : if I'm not mistaken, the "parse()" function in DAL handles a 
> lot ... basically read just any value returned from the database to the 
> correct type (blob, integer, double, datetime,  list:*, just to say a 
> few), handles virtualfields and prepares the Rows object making the 
> Storage(). All the resultset is fetched, "parsed()" line by line, column by 
> column, and returned as a whole list. Also if operations were to be kept at 
> a minimum, building a simple list of 1 million record take some time, (and 
> memory).
> Obviously the first shortcut is use limitby. The second is selecting only 
> the needed columns (best practice anyway to limit the amount of wire 
> transfer). No other shoutcuts.
>
> @all: Giving that a million record is hardly displayed, SQLTABLEd, 
> SQLFORM.gridded, pickled, jsoned, etc.I think the "need" here is having 
> a Storage() object instead of a tuple for accessing the values as 
> row.idinstead of row[0], etc as in current executesql.
> I see two roads (to be considered as 1 AND 2 and also as 1 OR 2) here, but 
> I don't know the implications of having to deal with SQLFORM.grid, for 
> instance. 
> 1) skip the parse() and return a quasi-rows object "a la executesql", just 
> turning the list of tuples as list of row objects, skipping virtual fields, 
> references, etc.
> 2) approach the returned values as a generator, and optionally as an 
> only-forward iterator "a la web.py iterbetter()" (
> https://github.com/webpy/webpy/blob/master/web/db.py#L646), i.e. you can 
> fetch the results and cycle through them only one time 
>
> Downsides for method 1):
> - some types could not be converted at all, references would be 
> unavailable (but for million records you should anyway have done a join), 
> no virtualfields
> - building a list of million records still requires time
> - for large datasets having to work on them only "after" all the list is 
> prepared could be taking some time
> Downsides for method 2):
> - may work as expected only if underlying db driver supports it
> - in the need of cycling the resultset for the second time another query 
> is required or you have to come up with you own memoization (i.e. prepare 
> an empty list to append results you're interested in cycling again)
>
> I used web.py a lot and also for millions of records it's very fast for 
> returning results.
> NB: the "time cut" here is the one passing from the "db is ready to return 
> results" to "the queryset is done and prepared for me to work on it". 
> The assumption on 2) is that rarely you need to access randomly a million 
> of records - i.e. myrows[31289], myrows[129459] - and what you can do in 2 
> loops on the same dataset is usually "accomplishable" (that word even exist 
> ? :D) in a single one.
>
>

-- 





[web2py] Need DISTINCT query for combo box

2012-06-22 Thread Keith Edmunds
I have a combo box on a form to select a company name. The list of valid
company names is derived from a query, q, and so I have:

t = db.t_tasks
c = db.t_companies

t.f_company.requires = IS_EMPTY_OR(IS_IN_DB(
db(q), c.id, '%(f_name)s', zero="All"))
 
That works, but the query may return more than one row for any given
company, and thus the combo repeats the company name, once for each row. I
need to make the query DISTINCT, but can't see how to do that.

Can anyone help?

Thanks,
Keith
-- 
We're looking for good Linux people:
http://www.tiger-computing.co.uk/jobs

-- 





Re: [web2py] DAL performance vs executesql

2012-06-22 Thread Niphlod

 @pbreit : if I'm not mistaken, the "parse()" function in DAL handles a lot 
... basically read just any value returned from the database to the correct 
type (blob, integer, double, datetime,  list:*, just to say a few), 
handles virtualfields and prepares the Rows object making the Storage(). 
All the resultset is fetched, "parsed()" line by line, column by column, 
and returned as a whole list. Also if operations were to be kept at a 
minimum, building a simple list of 1 million record take some time, (and 
memory).
Obviously the first shortcut is use limitby. The second is selecting only 
the needed columns (best practice anyway to limit the amount of wire 
transfer). No other shoutcuts.

@all: Giving that a million record is hardly displayed, SQLTABLEd, 
SQLFORM.gridded, pickled, jsoned, etc.I think the "need" here is having 
a Storage() object instead of a tuple for accessing the values as row.id 
instead of row[0], etc as in current executesql.
I see two roads (to be considered as 1 AND 2 and also as 1 OR 2) here, but 
I don't know the implications of having to deal with SQLFORM.grid, for 
instance. 
1) skip the parse() and return a quasi-rows object "a la executesql", just 
turning the list of tuples as list of row objects, skipping virtual fields, 
references, etc.
2) approach the returned values as a generator, and optionally as an 
only-forward iterator "a la web.py iterbetter()" 
(https://github.com/webpy/webpy/blob/master/web/db.py#L646), i.e. you can 
fetch the results and cycle through them only one time 

Downsides for method 1):
- some types could not be converted at all, references would be unavailable 
(but for million records you should anyway have done a join), no 
virtualfields
- building a list of million records still requires time
- for large datasets having to work on them only "after" all the list is 
prepared could be taking some time
Downsides for method 2):
- may work as expected only if underlying db driver supports it
- in the need of cycling the resultset for the second time another query is 
required or you have to come up with you own memoization (i.e. prepare an 
empty list to append results you're interested in cycling again)

I used web.py a lot and also for millions of records it's very fast for 
returning results.
NB: the "time cut" here is the one passing from the "db is ready to return 
results" to "the queryset is done and prepared for me to work on it". 
The assumption on 2) is that rarely you need to access randomly a million 
of records - i.e. myrows[31289], myrows[129459] - and what you can do in 2 
loops on the same dataset is usually "accomplishable" (that word even exist 
? :D) in a single one.

-- 





[web2py] Re: Web2py hanging with no errors in the log

2012-06-22 Thread Derek
You should look in the error logs.
http://127.0.0.1:8000/admin/default/errors/examples
 

where "examples" is the name of your app that was crashing.

On Friday, June 22, 2012 1:34:35 PM UTC-7, magoo wrote:
>
> Hi all, 
>
> I have a web2py healthcheck monitoring application. Basically the only 
> thing the 
> application does is make database queries to find healthcheck data and 
> make REST 
> api calls to a separate web2py application for information on the 
> environment. 
>
> Recently the application has been "crashing" at least once a day. The 
> web2py 
> process still exists, but users are unable to connect to the application. 
> There 
> are no errors in the logs or any useful information in the httpserver.log, 
> it's 
> like web2py just hangs and I have to restart it. I'm at my wits end trying 
> to 
> figure out what is happening so I figured I'd see if anyone has 
> experienced this 
> before or has any tips on log files I'm unaware of to check. 
>
> Thanks! 
>
>

-- 





Re: [web2py] DAL performance vs executesql

2012-06-22 Thread pbreit
I'd be interested to understand what processing all goes on. It's 
definitely very pleasant working with DAL rows but in this case, not viable.

-- 





[web2py] Re: Image uploads to different server, mongodb with grid

2012-06-22 Thread Niphlod
I can only answer for the first one: if you're willing to store image on 
the database the fix is right that: all images in one server.

If you're looking to store uploaded files into one and only server and one 
and only folder, you have to share the folder via NFS or samba on the 
central server and mount that folder on all "slaves" under the correct dir 
(with defaults, it's web2py/applications/yourapp/uploads)


On Friday, June 22, 2012 10:33:52 PM UTC+2, Bruce Wade wrote:
>
> Hi,
>
> I have 2 questions:
>
> First what is the process of having images uploaded from 1 or more servers 
> to be stored on a single server using web2py upload field?
>
> Second is it yet possible to use SQLFORM.grid with mongodb? If so what is 
> the process for it or is it the same regardless of the db backend?
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>  

-- 





[web2py] Web2py hanging with no errors in the log

2012-06-22 Thread magoo
Hi all,

I have a web2py healthcheck monitoring application. Basically the only thing 
the 
application does is make database queries to find healthcheck data and make 
REST 
api calls to a separate web2py application for information on the environment. 

Recently the application has been "crashing" at least once a day. The web2py 
process still exists, but users are unable to connect to the application. There 
are no errors in the logs or any useful information in the httpserver.log, it's 
like web2py just hangs and I have to restart it. I'm at my wits end trying to 
figure out what is happening so I figured I'd see if anyone has experienced 
this 
before or has any tips on log files I'm unaware of to check.

Thanks!

-- 





[web2py] Image uploads to different server, mongodb with grid

2012-06-22 Thread Bruce Wade
Hi,

I have 2 questions:

First what is the process of having images uploaded from 1 or more servers
to be stored on a single server using web2py upload field?

Second is it yet possible to use SQLFORM.grid with mongodb? If so what is
the process for it or is it the same regardless of the db backend?

-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com

-- 





Re: [web2py] import module fails

2012-06-22 Thread wdtatenh
Thanks.  I do but I still get the same problem.  It's interesting that I 
have another 3rd party module that I added and it works but mine which just 
has some functions test functions in it does not.  

I created that file under the module folder through the web2py web 
interface.


-- 





Re: [web2py] How to remove 'default' from all URLs?

2012-06-22 Thread Jonathan Lundell
On Jun 22, 2012, at 11:57 AM, Alec Taylor wrote:
> In my models/db.py I have this line:
> 
> auth.settings.login_next = URL(f='profile')

You might want to explicitly set the controller on that line, unless you have 
only one controller. As a practical matter it may not be an issue, since it's 
quite possible that the current controller is 'default' any time you care about 
login_next, but in general you could have any controller when you come through 
your model, and it does no harm to be explicit. (I don't think that's your 
problem, though.)

You wrote:

Yet the URL continues to present at: http://brian.com/default/profile#_=_

Where's the '#_=_' coming from? That seems odd. And URL() doesn't generate the 
scheme and domain unless you explicitly tell it to. Are you looking at the page 
source?

> 
> The profile function is defined in controllers/default.py
> 
> On Sat, Jun 23, 2012 at 4:46 AM, Jonathan Lundell  wrote:
>> On Jun 22, 2012, at 11:00 AM, Alec Taylor wrote:
>>> 
>>> (just tried that, didn't work) - Looking forward to when you get the
>>> chance to pass it through unit-tests :)
>> 
>> OK, I tried it and it seemed to work OK. Here's my test case:
>> 
>>router = dict(
>>   BASE = dict(
>>   default_application = 'init',
>>   applications = 'INIT',
>>   ),
>>   init = dict(
>>   controllers = ['default', 'ctr'],
>>   functions = ['index','user','register','basicRegister',
>>   'download','call','data','error']
>>   ),
>>)
>> 
>> The applications= and controllers= lines are in there because of the unit 
>> test environment; you don't need them as a rule.
>> 
>> The test case:
>> 
>>self.assertEqual(str(URL(a='init', c='default', f='register')), 
>> "/register")
>> 
>> How are you generating your URL? You have to use URL() to do it; that's 
>> where the router gets invoked.
>> 
>> --



-- 





Re: [web2py] How to remove 'default' from all URLs?

2012-06-22 Thread Alec Taylor
In my models/db.py I have this line:

auth.settings.login_next = URL(f='profile')

The profile function is defined in controllers/default.py

On Sat, Jun 23, 2012 at 4:46 AM, Jonathan Lundell  wrote:
> On Jun 22, 2012, at 11:00 AM, Alec Taylor wrote:
>>
>> (just tried that, didn't work) - Looking forward to when you get the
>> chance to pass it through unit-tests :)
>
> OK, I tried it and it seemed to work OK. Here's my test case:
>
>        router = dict(
>           BASE = dict(
>               default_application = 'init',
>                   applications = 'INIT',
>           ),
>           init = dict(
>                   controllers = ['default', 'ctr'],
>                   functions = ['index','user','register','basicRegister',
>                       'download','call','data','error']
>           ),
>        )
>
> The applications= and controllers= lines are in there because of the unit 
> test environment; you don't need them as a rule.
>
> The test case:
>
>        self.assertEqual(str(URL(a='init', c='default', f='register')), 
> "/register")
>
> How are you generating your URL? You have to use URL() to do it; that's where 
> the router gets invoked.
>
> --
>
>
>

-- 





Re: [web2py] How to remove 'default' from all URLs?

2012-06-22 Thread Jonathan Lundell
On Jun 22, 2012, at 11:00 AM, Alec Taylor wrote:
> 
> (just tried that, didn't work) - Looking forward to when you get the
> chance to pass it through unit-tests :)

OK, I tried it and it seemed to work OK. Here's my test case:

router = dict(
   BASE = dict(
   default_application = 'init',
   applications = 'INIT',
   ),
   init = dict(
   controllers = ['default', 'ctr'],
   functions = ['index','user','register','basicRegister',
   'download','call','data','error']
   ),
)

The applications= and controllers= lines are in there because of the unit test 
environment; you don't need them as a rule.

The test case:

self.assertEqual(str(URL(a='init', c='default', f='register')), 
"/register")

How are you generating your URL? You have to use URL() to do it; that's where 
the router gets invoked.

-- 





Re: [web2py] Re: Nightly Build (for testers) for windows

2012-06-22 Thread Javier Pepe
Thanks

I expect the final version


On Fri, Jun 22, 2012 at 3:20 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> There are some known issue with the windows nightly build because we are
> moving from python 2.5 to 2.7. He hope to resolve them soon.
>
>
> On Friday, 22 June 2012 11:53:42 UTC-5, Javier wrote:
>>
>> Hello
>>
>> I'm trying to use de lastest binary version and get the follow error:
>>
>> Traceback (most recent call last):
>>File "web2pypy", line 16, in 
>> zipimport.ZipImportError: can't find module 'gluon'
>>
>> I need use this version to use scheduler.
>>
>> Thanks
>>
>>
>>  --
>

-- 





[web2py] Re: Nightly Build (for testers) for windows

2012-06-22 Thread Massimo Di Pierro
There are some known issue with the windows nightly build because we are 
moving from python 2.5 to 2.7. He hope to resolve them soon.

On Friday, 22 June 2012 11:53:42 UTC-5, Javier wrote:
>
> Hello
>
> I'm trying to use de lastest binary version and get the follow error:
>
> Traceback (most recent call last):
>File "web2pypy", line 16, in 
> zipimport.ZipImportError: can't find module 'gluon'
>
> I need use this version to use scheduler.
>
> Thanks
>
>
>

-- 





Re: [web2py] How to remove 'default' from all URLs?

2012-06-22 Thread Alec Taylor
(just tried that, didn't work) - Looking forward to when you get the
chance to pass it through unit-tests :)

On Sat, Jun 23, 2012 at 3:06 AM, Jonathan Lundell  wrote:
> On Jun 22, 2012, at 10:02 AM, Alec Taylor wrote:
>>
>> I got a syntax error on your last code modification (pointing out the
>> = on social=).
>
> My dumb mistake; you need a comma after the BASE dict:
>
> routers = dict(
>  BASE=dict(
>      default_application='social',
>  ),
>  social=dict(
>      functions = ['index', 'profile', 'user'],
>  )
> )
>
> I'll try adding your case to the unit tests and see what's what. I might not 
> be able to do it right away, but soon.
>
>
>>
>> And yes, I have restarted the server. (I even rebooted my machine [for
>> an unrelated reason])
>>
>> Still being directed to http://brian.com/default/profile#_=_ rather
>> than http://brian.com/profile
>>
>> On Sat, Jun 23, 2012 at 12:32 AM, Jonathan Lundell  
>> wrote:
>>> On Jun 22, 2012, at 7:29 AM, Alec Taylor wrote:

 I modified the route.py as you suggested:

 routers = dict(
    BASE=dict(
        default_application='social',
        functions = ['index', 'profile', 'user'],
    )
 )

 Yet the URL continues to present at: http://brian.com/default/profile#_=_
>>
>
>
> --
>
>
>

-- 





Re: [web2py] How to remove 'default' from all URLs?

2012-06-22 Thread Jonathan Lundell
On Jun 22, 2012, at 10:02 AM, Alec Taylor wrote:
> 
> I got a syntax error on your last code modification (pointing out the
> = on social=).

My dumb mistake; you need a comma after the BASE dict:

routers = dict(
  BASE=dict(
  default_application='social',
  ),
  social=dict(
  functions = ['index', 'profile', 'user'],
  )
)

I'll try adding your case to the unit tests and see what's what. I might not be 
able to do it right away, but soon.


> 
> And yes, I have restarted the server. (I even rebooted my machine [for
> an unrelated reason])
> 
> Still being directed to http://brian.com/default/profile#_=_ rather
> than http://brian.com/profile
> 
> On Sat, Jun 23, 2012 at 12:32 AM, Jonathan Lundell  wrote:
>> On Jun 22, 2012, at 7:29 AM, Alec Taylor wrote:
>>> 
>>> I modified the route.py as you suggested:
>>> 
>>> routers = dict(
>>>BASE=dict(
>>>default_application='social',
>>>functions = ['index', 'profile', 'user'],
>>>)
>>> )
>>> 
>>> Yet the URL continues to present at: http://brian.com/default/profile#_=_
> 


-- 





Re: [web2py] How to remove 'default' from all URLs?

2012-06-22 Thread Alec Taylor
I got a syntax error on your last code modification (pointing out the
= on social=).

And yes, I have restarted the server. (I even rebooted my machine [for
an unrelated reason])

Still being directed to http://brian.com/default/profile#_=_ rather
than http://brian.com/profile

On Sat, Jun 23, 2012 at 12:32 AM, Jonathan Lundell  wrote:
> On Jun 22, 2012, at 7:29 AM, Alec Taylor wrote:
>>
>> I modified the route.py as you suggested:
>>
>> routers = dict(
>>    BASE=dict(
>>        default_application='social',
>>        functions = ['index', 'profile', 'user'],
>>    )
>> )
>>
>> Yet the URL continues to present at: http://brian.com/default/profile#_=_
>
> Did you restart web2py (or otherwise reload the routing table)? You'll need 
> to do that.
>
> The router I gave you (above) is slightly defective (though it shouldn't have 
> kept function removal from working). The functions info should go in an 
> app-specific section, thus:
>
> routers = dict(
>   BASE=dict(
>       default_application='social',
>   )
>   social=dict(
>       functions = ['index', 'profile', 'user'],
>   )
> )
>
> --
>
>
>

-- 





[web2py] Nightly Build (for testers) for windows

2012-06-22 Thread Javier Pepe
Hello

I'm trying to use de lastest binary version and get the follow error:

Traceback (most recent call last):
   File "web2pypy", line 16, in 
zipimport.ZipImportError: can't find module 'gluon'

I need use this version to use scheduler.

Thanks

-- 





[web2py] Standalone DAL leaves mysql connections opened

2012-06-22 Thread demetrio

Hi everyone,

I have connected WebDAV and SVN auth with a wsgi script. I needed to use a 
standalone DAL. When you do a dav petition with the navigator it makes a 
lot of petitions. Well, the thing is that always there is a connection 
opened (i can see them with PhpMyAdmin)

if self.db: 
self.db._adapter.close()

seeing this issue: 
http://code.google.com/p/web2py/issues/detail?id=731

I have tried a lot of the lines that i found there

something like:

if self.db:
from gluon.dal import BaseAdapter
BaseAdapter.close_all_instances(None)
BaseAdapter.close_all_instances('commit')
BaseAdapter.close_all_instances('rollback')

something like:
if self.db:
from gluon.dal import thread as dal_thread
dal_thread.instances.remove(self.db._adapter)
self.db._adapter.close()

and even something desesperated like:
if self.db:
from gluon.dal import thread as dal_thread
dal_thread.instances.remove(self.db._adapter)
self.db._adapter.close()
self.db._adapter.close_all_instances(None)
self.db._adapter.close_all_instances('commit')
self.db._adapter.close_all_instances('rollback')

from gluon.dal import ConnectionPool
ConnectionPool.close_all_instances(None)
ConnectionPool.close_all_instances('commit')
ConnectionPool.close_all_instances('rollback')

from gluon.dal import BaseAdapter
BaseAdapter.close_all_instances(None)
BaseAdapter.close_all_instances('commit')
BaseAdapter.close_all_instances('rollback')

But always, in the best, it leaves at least one connection opened, and i 
don't know how to deal with it.

I have using web2py 1.99.7 in both development and production environments.

Any ideas? in this moment we are building a python mysql script, but we 
want to use DAL to make it runnable on any of the web2py/DAL supported db

Thanks in advance

-- 





Re: [web2py] DAL performance vs executesql

2012-06-22 Thread Anthony

>
> I wish it was possible to use other time-saving tools like SQLFORM.grid 
> with db.executesql().
>
> At the moment most of the representation tools like SQLTABLE and 
> plugin_wiki's jqgrid suppose DAL usage.
>

Maybe it would be possible to convert the results of executesql() to a 
pseudo-Rows object (without all the processing of each individual field 
value) so it could be used with the grid, etc.

Anthony 

-- 





[web2py] Re: Parsing python from db fields?

2012-06-22 Thread Anthony
How about replacing context=response._vars with context=globals()?

Anthony

On Friday, June 22, 2012 10:46:31 AM UTC-4, RKS wrote:
>
> Okay, so that works on everything except href="{{=URL('something')}} it 
> returns the error "URL is not defined." I'm going to try the other anchor 
> method available and see if that works.
>
> The {{=blog.title}} and {{include 'postviews3.html'}} works fine with this 
> solution.
>

-- 





Re: [web2py] Parsing python from db fields?

2012-06-22 Thread Jonathan Lundell
On Jun 22, 2012, at 7:46 AM, RKS wrote:
> Okay, so that works on everything except href="{{=URL('something')}} it 
> returns the error "URL is not defined." I'm going to try the other anchor 
> method available and see if that works.
> 
> The {{=blog.title}} and {{include 'postviews3.html'}} works fine with this 
> solution.
> 
> 


I think you might need to pass URL in with the context:

{{import os}}
{{from gluon.template import render}}
{{=XML(render(blog.body, path=os.path.join(request.folder, 'views'),
  context=dict(response._vars, URL=URL)))}}


(If this is a general issue, perhaps gluon.template ought to be importing URL 
and some of the other implicitly global symbols.)

-- 





[web2py] Re: DAL IMAP errors

2012-06-22 Thread Alan Etkin
I've sent a possible patch here:
http://code.google.com/p/web2py/issues/detail?id=644#c7

Seems that will solve the issue (there were no errors with the last trunk 
version)

-- 





[web2py] Re: Parsing python from db fields?

2012-06-22 Thread RKS
Okay, so that works on everything except href="{{=URL('something')}} it 
returns the error "URL is not defined." I'm going to try the other anchor 
method available and see if that works.

The {{=blog.title}} and {{include 'postviews3.html'}} works fine with this 
solution.

-- 





Re: [web2py] How to remove 'default' from all URLs?

2012-06-22 Thread Jonathan Lundell
On Jun 22, 2012, at 7:29 AM, Alec Taylor wrote:
> 
> I modified the route.py as you suggested:
> 
> routers = dict(
>BASE=dict(
>default_application='social',
>functions = ['index', 'profile', 'user'],
>)
> )
> 
> Yet the URL continues to present at: http://brian.com/default/profile#_=_

Did you restart web2py (or otherwise reload the routing table)? You'll need to 
do that.

The router I gave you (above) is slightly defective (though it shouldn't have 
kept function removal from working). The functions info should go in an 
app-specific section, thus:

routers = dict(
   BASE=dict(
   default_application='social',
   )
   social=dict(
   functions = ['index', 'profile', 'user'],
   )
)

-- 





Re: [web2py] How to remove 'default' from all URLs?

2012-06-22 Thread Alec Taylor
(brian.com is an entry in my /etc/hosts pointing to 127.0.0.1 as a
workaround for localhost with Facebook OAuth2)

On Sat, Jun 23, 2012 at 12:29 AM, Alec Taylor  wrote:
> I modified the route.py as you suggested:
>
> routers = dict(
>    BASE=dict(
>        default_application='social',
>        functions = ['index', 'profile', 'user'],
>    )
> )
>
> Yet the URL continues to present at: http://brian.com/default/profile#_=_
>
> On Sat, Jun 23, 2012 at 12:15 AM, Jonathan Lundell  wrote:
>> On Jun 22, 2012, at 7:06 AM, Alec Taylor wrote:
>>> Just tried that, it's still prepending the URL with "default".
>>>
>>> E.g.: http://localhost/default/profile rather than http://localhost/profile
>>
>> If you want the router to omit the default controller when you specify a 
>> non-default function, then you need to list your functions.
>>
>> routers = dict(
>>   BASE = dict(
>>       default_application = 'social',
>>       functions = ['index', 'profile', ... ],
>>   ),
>> )
>>
>> The functions list must be a complete list of the callable functions in the 
>> default controller.
>>
>> Otherwise, the router could ambiguously interpret http://localhost/profile 
>> as /myapp/default/index/profile.
>>
>> You can extend this functionality by defining functions as a dict of lists, 
>> where the dict keys are controller names. That allows dropping of functions 
>> in non-default controllers. The hazard of doing this is that the function 
>> list(s) really, really must be complete.
>>
>>
>>>
>>> On Fri, Jun 22, 2012 at 10:57 PM, Jonathan Lundell  
>>> wrote:
 On Jun 22, 2012, at 3:08 AM, Alec Taylor wrote:
>
> My web2py\routes.py:
>
> routers = dict( BASE=dict( default_application='social',
> default_controller='default', default_function='index' ) )
> myapps = ['social']
> routes_in = [
>  ('/admin/$anything', '/admin/$anything'),
> ]
> for app in myapps:
>    routes_in += [ ('/%s/static/$anything' % app,
> '/%s/static/$anything' % app), ('/%s/appadmin/$anything' % app,
> '/%s/appadmin/$anything' % app), ('/%s/$anything' % app,
> '/%s/default/$anything' % app) ]
> routes_out = [(b, a) for (a, b) in routes_in]
>
> It correctly defaults the landing page to the 'social' app, but it
> isn't removing 'default' from my URLs.
>
> (I got the above from
> https://groups.google.com/forum/#!topic/web2py/QU71v2-GFaM)
>
> How can I remove 'default' from my URLs?
>
> Thanks for all suggestions,

 Don't mix the two routers. In particular, don't define routers if you're 
 going to define routes_in/out.

 All you need is:

 routers = dict(
    BASE = dict(
        default_application = 'social',
    ),
 )

 --
>>
>>
>>
>> --
>>
>>
>>

-- 





Re: [web2py] How to remove 'default' from all URLs?

2012-06-22 Thread Alec Taylor
I modified the route.py as you suggested:

routers = dict(
BASE=dict(
default_application='social',
functions = ['index', 'profile', 'user'],
)
)

Yet the URL continues to present at: http://brian.com/default/profile#_=_

On Sat, Jun 23, 2012 at 12:15 AM, Jonathan Lundell  wrote:
> On Jun 22, 2012, at 7:06 AM, Alec Taylor wrote:
>> Just tried that, it's still prepending the URL with "default".
>>
>> E.g.: http://localhost/default/profile rather than http://localhost/profile
>
> If you want the router to omit the default controller when you specify a 
> non-default function, then you need to list your functions.
>
> routers = dict(
>   BASE = dict(
>       default_application = 'social',
>       functions = ['index', 'profile', ... ],
>   ),
> )
>
> The functions list must be a complete list of the callable functions in the 
> default controller.
>
> Otherwise, the router could ambiguously interpret http://localhost/profile as 
> /myapp/default/index/profile.
>
> You can extend this functionality by defining functions as a dict of lists, 
> where the dict keys are controller names. That allows dropping of functions 
> in non-default controllers. The hazard of doing this is that the function 
> list(s) really, really must be complete.
>
>
>>
>> On Fri, Jun 22, 2012 at 10:57 PM, Jonathan Lundell  
>> wrote:
>>> On Jun 22, 2012, at 3:08 AM, Alec Taylor wrote:

 My web2py\routes.py:

 routers = dict( BASE=dict( default_application='social',
 default_controller='default', default_function='index' ) )
 myapps = ['social']
 routes_in = [
  ('/admin/$anything', '/admin/$anything'),
 ]
 for app in myapps:
    routes_in += [ ('/%s/static/$anything' % app,
 '/%s/static/$anything' % app), ('/%s/appadmin/$anything' % app,
 '/%s/appadmin/$anything' % app), ('/%s/$anything' % app,
 '/%s/default/$anything' % app) ]
 routes_out = [(b, a) for (a, b) in routes_in]

 It correctly defaults the landing page to the 'social' app, but it
 isn't removing 'default' from my URLs.

 (I got the above from
 https://groups.google.com/forum/#!topic/web2py/QU71v2-GFaM)

 How can I remove 'default' from my URLs?

 Thanks for all suggestions,
>>>
>>> Don't mix the two routers. In particular, don't define routers if you're 
>>> going to define routes_in/out.
>>>
>>> All you need is:
>>>
>>> routers = dict(
>>>    BASE = dict(
>>>        default_application = 'social',
>>>    ),
>>> )
>>>
>>> --
>
>
>
> --
>
>
>

-- 





[web2py] Re: Auto-generate PUT and DELETE methods

2012-06-22 Thread Massimo Di Pierro
wow. done that.

On Thursday, 21 June 2012 18:04:04 UTC-5, Anthony wrote:
>
> Using my new Google Groups super 
> powers, 
> I have edited your original post, so if you'd like, you can delete this 
> correction and we can pretend this never happened. ;-)
>
> Anthony
>
> On Thursday, June 21, 2012 6:40:37 PM UTC-4, Massimo Di Pierro wrote:
>>
>> Silly me. This
>>
>> def PUT(table_name,record_id):
>>
>> return db(db[table_name]._id==record_id).delete()
>>
>>
>> was supposed to be
>>
>>
>> def DELETE(table_name,record_id):
>>
>> return db(db[table_name]._id==record_id).delete()
>>
>>
>> On Thursday, 21 June 2012 13:38:01 UTC-5, Derek wrote:
>>>
>>> Looks like you have Get, Post, and PUT and PUT. Where's Delete?
>>>
>>> On Wednesday, June 20, 2012 4:39:33 PM UTC-7, Massimo Di Pierro wrote:

 You can do

 @request.restful()
 def api():
 response.view = 'generic.'+request.extension
 def GET(*args,**vars):
 patterns = 'auto'
 parser = db.parse_as_rest(patterns,args,vars)
 if parser.status == 200:
 return dict(content=parser.response)
 else:
 raise HTTP(parser.status,parser.error)
 def POST(table_name,**vars):
 return db[table_name].validate_and_insert(**vars)

 def PUT(table_name,record_id,**vars):

 return db(db[table_name]._id==record_id).update(**vars)

 def PUT(table_name,record_id):

 return db(db[table_name]._id==record_id).delete()

 return locals()


 On Wednesday, 20 June 2012 11:30:26 UTC-5, Osama Hussain wrote:
>
> Using the following code web2py generated all possible patterns for 
> all my tables for GET and POST methods:
>
> @request.restful()
> def api():
> response.view = 'generic.'+request.extension
> def GET(*args,**vars):
> patterns = 'auto'
> parser = db.parse_as_rest(patterns,args,vars)
> if parser.status == 200:
> return dict(content=parser.response)
> else:
> raise HTTP(parser.status,parser.error)
> def POST(table_name,**vars):
> return db[table_name].validate_and_insert(**vars)
> return locals()
>
>
> Is it possible to have patterns generated for PUT and DELETE methods?
>
>

-- 





Re: [web2py] How to remove 'default' from all URLs?

2012-06-22 Thread Jonathan Lundell
On Jun 22, 2012, at 7:06 AM, Alec Taylor wrote:
> Just tried that, it's still prepending the URL with "default".
> 
> E.g.: http://localhost/default/profile rather than http://localhost/profile

If you want the router to omit the default controller when you specify a 
non-default function, then you need to list your functions.

routers = dict(
   BASE = dict(
   default_application = 'social',
   functions = ['index', 'profile', ... ],
   ),
)

The functions list must be a complete list of the callable functions in the 
default controller.

Otherwise, the router could ambiguously interpret http://localhost/profile as 
/myapp/default/index/profile.

You can extend this functionality by defining functions as a dict of lists, 
where the dict keys are controller names. That allows dropping of functions in 
non-default controllers. The hazard of doing this is that the function list(s) 
really, really must be complete.


> 
> On Fri, Jun 22, 2012 at 10:57 PM, Jonathan Lundell  wrote:
>> On Jun 22, 2012, at 3:08 AM, Alec Taylor wrote:
>>> 
>>> My web2py\routes.py:
>>> 
>>> routers = dict( BASE=dict( default_application='social',
>>> default_controller='default', default_function='index' ) )
>>> myapps = ['social']
>>> routes_in = [
>>>  ('/admin/$anything', '/admin/$anything'),
>>> ]
>>> for app in myapps:
>>>routes_in += [ ('/%s/static/$anything' % app,
>>> '/%s/static/$anything' % app), ('/%s/appadmin/$anything' % app,
>>> '/%s/appadmin/$anything' % app), ('/%s/$anything' % app,
>>> '/%s/default/$anything' % app) ]
>>> routes_out = [(b, a) for (a, b) in routes_in]
>>> 
>>> It correctly defaults the landing page to the 'social' app, but it
>>> isn't removing 'default' from my URLs.
>>> 
>>> (I got the above from
>>> https://groups.google.com/forum/#!topic/web2py/QU71v2-GFaM)
>>> 
>>> How can I remove 'default' from my URLs?
>>> 
>>> Thanks for all suggestions,
>> 
>> Don't mix the two routers. In particular, don't define routers if you're 
>> going to define routes_in/out.
>> 
>> All you need is:
>> 
>> routers = dict(
>>BASE = dict(
>>default_application = 'social',
>>),
>> )
>> 
>> --



-- 





Re: [web2py] How to remove 'default' from all URLs?

2012-06-22 Thread Alec Taylor
Just tried that, it's still prepending the URL with "default".

E.g.: http://localhost/default/profile rather than http://localhost/profile

On Fri, Jun 22, 2012 at 10:57 PM, Jonathan Lundell  wrote:
> On Jun 22, 2012, at 3:08 AM, Alec Taylor wrote:
>>
>> My web2py\routes.py:
>>
>> routers = dict( BASE=dict( default_application='social',
>> default_controller='default', default_function='index' ) )
>> myapps = ['social']
>> routes_in = [
>>  ('/admin/$anything', '/admin/$anything'),
>> ]
>> for app in myapps:
>>    routes_in += [ ('/%s/static/$anything' % app,
>> '/%s/static/$anything' % app), ('/%s/appadmin/$anything' % app,
>> '/%s/appadmin/$anything' % app), ('/%s/$anything' % app,
>> '/%s/default/$anything' % app) ]
>> routes_out = [(b, a) for (a, b) in routes_in]
>>
>> It correctly defaults the landing page to the 'social' app, but it
>> isn't removing 'default' from my URLs.
>>
>> (I got the above from
>> https://groups.google.com/forum/#!topic/web2py/QU71v2-GFaM)
>>
>> How can I remove 'default' from my URLs?
>>
>> Thanks for all suggestions,
>
> Don't mix the two routers. In particular, don't define routers if you're 
> going to define routes_in/out.
>
> All you need is:
>
> routers = dict(
>    BASE = dict(
>        default_application = 'social',
>    ),
> )
>
> --
>
>
>

-- 





[web2py] Re: how to limit a label width in a form?

2012-06-22 Thread Paolo Caruccio
Try to apply on label this css rule:

white-space: pre-wrap; 

The white-space property is supported in all major browsers. (
http://www.w3schools.com/cssref/pr_text_white-space.asp)

Il giorno venerdì 22 giugno 2012 15:35:18 UTC+2, Marco Prosperi ha scritto:
>
>
> hi all, I would like to limit the width of a SQLFORM label so that the 
> text appears on more lines if it is too long. I've tried to put
>
> label {max-width:200px;}
>
> in base.css but without effect. Any suggestion?
>
> thanks in advance,
>
> Marco
>

-- 





[web2py] how to limit a label width in a form?

2012-06-22 Thread Marco Prosperi

hi all, I would like to limit the width of a SQLFORM label so that the text 
appears on more lines if it is too long. I've tried to put

label {max-width:200px;}

in base.css but without effect. Any suggestion?

thanks in advance,

Marco

-- 





Re: [web2py] Re: Email form contents after submission

2012-06-22 Thread Anthony

>
> thanks a lot for that. But I think I made a mistake in asking the 
> question. What i want to know more than just this is how to set up a mail 
> server... or how to set up the mail 'mailer' object... and how should i 
> configure it.
>

Setting up the web2py mailer is covered in the book: 
http://web2py.com/books/default/chapter/29/8#Setting-up-email. Assuming you 
have any existing email account that lets you send mail by communicating 
with the SMTP server, you don't have to set up your own mail server -- just 
provide the server details and credentials for that account, as shown in 
the book. If you want to set up your own mail server, that is outside the 
scope of web2py. Others on the list may have some advice, though you can 
probably find lots of helpful resources on the internet as well.

Anthony 

-- 





Re: [web2py] How to remove 'default' from all URLs?

2012-06-22 Thread Jonathan Lundell
On Jun 22, 2012, at 3:08 AM, Alec Taylor wrote:
> 
> My web2py\routes.py:
> 
> routers = dict( BASE=dict( default_application='social',
> default_controller='default', default_function='index' ) )
> myapps = ['social']
> routes_in = [
>  ('/admin/$anything', '/admin/$anything'),
> ]
> for app in myapps:
>routes_in += [ ('/%s/static/$anything' % app,
> '/%s/static/$anything' % app), ('/%s/appadmin/$anything' % app,
> '/%s/appadmin/$anything' % app), ('/%s/$anything' % app,
> '/%s/default/$anything' % app) ]
> routes_out = [(b, a) for (a, b) in routes_in]
> 
> It correctly defaults the landing page to the 'social' app, but it
> isn't removing 'default' from my URLs.
> 
> (I got the above from
> https://groups.google.com/forum/#!topic/web2py/QU71v2-GFaM)
> 
> How can I remove 'default' from my URLs?
> 
> Thanks for all suggestions,

Don't mix the two routers. In particular, don't define routers if you're going 
to define routes_in/out.

All you need is:

routers = dict(
BASE = dict(
default_application = 'social',
),
)

-- 





Re: [web2py] Re: Email form contents after submission

2012-06-22 Thread Omar Technologies
Anthony,

thanks a lot for that. But I think I made a mistake in asking the question.
What i want to know more than just this is how to set up a mail server...
or how to set up the mail 'mailer' object... and how should i configure it.

Is that something I can learn from these forums...

But thanks anyway :)

Regards,
Omar



On Thu, Jun 21, 2012 at 5:50 PM, Anthony  wrote:

> Assuming you have defined the "mail" mailer object as in the "welcome" app
> db.py, something like this:
>
> if form.process().accepted:
> message = ''.join(['%s: %s' % (f, XML(form.vars[f], sanitize=
> True))
> for f in db.suggestions.fields])
> mail.send(to='ad...@yoursite.com', reply_to=form.vars.email,
> subject='Suggestion',
> message='%s' % message)
>
> Anthony
>
> On Thursday, June 21, 2012 2:04:54 AM UTC-4, Omar Ali wrote:
>>
>>
>> I'm making a one-page web-app which has one table.. that accepts
>> suggestions (like a feeback thingie)..
>>
>> I'm using SQLFORM to render the form and accept and it's adding
>> everything in the database as expected. But I would like to do an
>> additional step upon submission of form.
>>
>> I want to send an email with the form's contents to an admin's email id
>> with a reply to of the person who sent in the suggestion. How can i
>> configure this on a windows server..
>>
>> Here's the code so far:
>>
>> db.py:
>>
>> db = DAL('sqlite://storage.db')
>>
>> db.define_table('suggestions',
>> Field('type', requires=IS_IN_SET(['شكوى', 'مقترح'])),
>> Field('created_on', 'datetime', default=request.now),
>> Field('Name', 'string', notnull=True),
>> Field('Gender', requires=IS_IN_SET(['انثى', 'ذكر'])),
>> Field('Description', 'text'),
>> Field('email', requires=IS_EMAIL(error_**message='Invalid Email
>> !')),
>> Field('usercat', requires=IS_IN_SET(['فرد', 'مكتب عقاري'])),
>> Field('education', requires=IS_IN_SET(['ابتدائي', 'ثانوي',
>> 'دبلوم', 'جامعي', 'دراسات عليا'])),
>> Field('homenumber', 'integer'),
>> Field('mobilenumber', 'integer'),
>> Field('age', 'integer'),
>> Field('pobox', 'integer'),
>> Field('nationality', 'string'),)
>>
>> default.py
>>
>> def viewall():
>> recs = db().select(db.suggestions.**ALL, orderby=db.suggestions.**
>> created_on)
>> return dict(recs=recs)
>>
>> def index():
>>form = SQLFORM(db.suggestions,labels=**{'type':'نوع','created_on':'**
>> التاريخ','Name':'الأسم','**Gender':'الجنس','Description':**
>> 'موضوع','email':'E-Mail','**usercat':'نوع المتعامل','education':'المؤهل
>> العلمي','homenumber':'هاتف منزل','mobilenumber':'هاتف
>> متحرك','age':'العمر','pobox':'**صندوق بريد','nationality':'الجنسية'}**
>> ,submit_button='إرسل')
>>
>>if form.process().accepted:
>>response.flash = 'تم ألإرسال'
>>
>>elif form.errors:
>>response.flash = 'يرجى ملء كافة الحقول'
>>else:
>>pass
>>return dict(form=form)
>>
>> default/index.html:
>>
>> {{extend 'layout.html'}}
>>
>> > />إقترحات و شكاوة
>> 
>> {{=form}}
>>
>>  --
>

-- 





[web2py] Jeditable and SQLTables

2012-06-22 Thread Simon Ashley
Does anyone have any native python/ web2py code for a jeditable call in a 
table that they are willing to share i.e. a web2py version of save.php?   

-- 





[web2py] Re: how to write on the wall of Facebook Friends?

2012-06-22 Thread Alec Taylor
Use the Python Facebook SDK (was official, now community maintained):  
https://github.com/pythonforfacebook/facebook-sdk 

On Friday, June 22, 2012 4:47:56 PM UTC+10, Amit wrote:
>
>
> Hi,
> I have to develop one web2py application which can write on the wall of 
> Facebook friends and send mail as well, how to achieve it in web2py?
>
> regards,
> Amit

-- 





Re: [web2py] DAL performance vs executesql

2012-06-22 Thread Johann Spies
On 22 June 2012 10:21, Michele Comitini  wrote:

> The DAL is a pure python implementation so it is slower than a C
> implementation.
> With large datasets the overhead is high so it is better to use executesql.
> Often there's no other way than pulling all the records at once, but
> sometimes a lazy approach to data extraction with the use of limitby
> can give the best results: speed and DAL ease of use.
>
>
I wish it was possible to use other time-saving tools like SQLFORM.grid
with db.executesql().

At the moment most of the representation tools like SQLTABLE and
plugin_wiki's jqgrid suppose DAL usage.

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

-- 





[web2py] How to remove 'default' from all URLs?

2012-06-22 Thread Alec Taylor
My web2py\routes.py:

routers = dict( BASE=dict( default_application='social',
default_controller='default', default_function='index' ) )
myapps = ['social']
routes_in = [
  ('/admin/$anything', '/admin/$anything'),
]
for app in myapps:
routes_in += [ ('/%s/static/$anything' % app,
'/%s/static/$anything' % app), ('/%s/appadmin/$anything' % app,
'/%s/appadmin/$anything' % app), ('/%s/$anything' % app,
'/%s/default/$anything' % app) ]
routes_out = [(b, a) for (a, b) in routes_in]

It correctly defaults the landing page to the 'social' app, but it
isn't removing 'default' from my URLs.

(I got the above from
https://groups.google.com/forum/#!topic/web2py/QU71v2-GFaM)

How can I remove 'default' from my URLs?

Thanks for all suggestions,

Alec Taylor

-- 





Re: [web2py] DAL performance vs executesql

2012-06-22 Thread Michele Comitini
The DAL is a pure python implementation so it is slower than a C implementation.
With large datasets the overhead is high so it is better to use executesql.
Often there's no other way than pulling all the records at once, but
sometimes a lazy approach to data extraction with the use of limitby
can give the best results: speed and DAL ease of use.

mic

2012/6/22 Alec Taylor :
> From what I understand people use DAL or ORM layers for abstraction purposes.
>
> So a struct with pointer to functions in C will have less overhead
> than a class with member functions in C++. However working at this
> higher level of abstraction allows for some fancy time-saving
> mechanisms such as multiple inheritance, templates, encapsulation and
> subtype polymorphism.
>
> In the database world: queries would of course run much faster when
> written by hand, and stored-procedures will speed up the equivalent
> function built inn Python with the layer in-between. Does this mean we
> should just write pure SQL and stored-procedures?
>
> Yes and no. It depends on what you are setting out to do. If
> performance is your goal and your willing to sacrifice abstraction to
> achieve it, then do as much as you can database and query side.
>
> {An additional advantage of using DAL or ORM layers is the ability to
> move to a different database engine (e.g.: a NoSQL one or from sqlite
> to postgres [use one for dev one for production])/}
>
>  ideas on how to speed up queries without sacrificing abstraction I'm
> sure your patches will be accepted :]>
>
> On Fri, Jun 22, 2012 at 4:54 PM, pbreit  wrote:
>> I have an app where I pull down 5,000 records. I started with DAL and
>> db.item.ALL and it was taking around 4 seconds. I added 5 fields to the
>> select() which got it down to around 2 seconds. Then I implemented the same
>> thing with executesql and got it down to 500 ms.
>>
>> So, selecting only the fields you need is a good optimization. But going
>> with raw SQL is much better.
>>
>> --
>
> --
>
>
>

-- 





[web2py] Re: menu.append() more than one argument

2012-06-22 Thread Annet
Hi Anthony,

Thanks for your reply.  This works, so problem solved.


response.site_submenu = []
if session.vcardsettings:
response.site_submenu += [
['Logo',request.function=='uploadLogo',URL('uploadLogo')],
['Tagline',request.function=='tagline',URL('tagline')],
['Text',request.function=='note',URL('note')]]
elif session.sitesettings:
response.site_submenu += [
['Hero_unit',request.function=='heroUnit',URL('heroUnit')],

['Hero_unit_BG',request.function=='uploadHeroUnitBG',URL('uploadHeroUnitBG')],
['carousel',request.function=='carousel',URL('carousel')]]
response.site_submenu += [
['Gerelateerde_namen',request.function=='relatedNames',URL('relatedNames')],
['Social_media',request.function=='socialMedia',URL('socialMedia')],
['Css',request.function=='theme',URL('theme')],
['Maatwerk_css',request.function=='customTheme',URL('customTheme')]]


Kind regards,

Annet

-- 





Re: [web2py] DAL performance vs executesql

2012-06-22 Thread Alec Taylor
>From what I understand people use DAL or ORM layers for abstraction purposes.

So a struct with pointer to functions in C will have less overhead
than a class with member functions in C++. However working at this
higher level of abstraction allows for some fancy time-saving
mechanisms such as multiple inheritance, templates, encapsulation and
subtype polymorphism.

In the database world: queries would of course run much faster when
written by hand, and stored-procedures will speed up the equivalent
function built inn Python with the layer in-between. Does this mean we
should just write pure SQL and stored-procedures?

Yes and no. It depends on what you are setting out to do. If
performance is your goal and your willing to sacrifice abstraction to
achieve it, then do as much as you can database and query side.

{An additional advantage of using DAL or ORM layers is the ability to
move to a different database engine (e.g.: a NoSQL one or from sqlite
to postgres [use one for dev one for production])/}



On Fri, Jun 22, 2012 at 4:54 PM, pbreit  wrote:
> I have an app where I pull down 5,000 records. I started with DAL and
> db.item.ALL and it was taking around 4 seconds. I added 5 fields to the
> select() which got it down to around 2 seconds. Then I implemented the same
> thing with executesql and got it down to 500 ms.
>
> So, selecting only the fields you need is a good optimization. But going
> with raw SQL is much better.
>
> --

--