[web2py] Re: why does this not work f=locals()['IS_IN_SET'] ?

2013-02-18 Thread Anthony
locals() returns the variables in the current namespace -- in the shell, 
that is the global web2py environment, which includes the web2py API 
objects, but in a controller function, it is just the function's namespace. 
You could do f=locals()['IS_IN_SET'] outside a function (e.g., in a model 
or at the top level in a controller), or instead you could do 
globals()['IS_IN_SET'] within a function.

Anthony

On Monday, February 18, 2013 11:09:50 PM UTC-5, Tim Richardson wrote:
>
> When in interactive mode (python web2py.py -S welcome)
> I can do this:
> f = local()['IS_IN_SET']
> and I get f as a function variable.
>
> But the same thing in a controller fails with a KeyError. 
>
> [I'm trying to make an SQLFORM.factory form based on queries defined in a 
> table, with SQL, parameters and validation for the parameters]
>
> python 2.7.2 on Windows 
>
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: How do I define a table that references itself

2013-02-18 Thread Paul Whipp
Thanks,

This did not only clear up this particular problem for me but seeing the
format in the IS_IN_DB constructor showed me why I was losing the default
table represents when adding constraints elsewhere so that is now sorted
too.

Thanks again.

We expect to exceed ten thousand dockets. What will happen regarding the
dropdown representation for columns referencing the dockets id as the
number grows? Will I need to introduce a custom solution for this?

On 19 February 2013 03:37, Massimo Di Pierro wrote:

> The only problem is that for self referendes you do not get an automatic
> represent and validator (because the field is created before the table
> referenced is created):
>
> You can do it manually:
>
> db.define_table('Docket',
> Field('Docket_No', 'integer',
> required = True),
> Field('Reference_Docket_ID', 'reference Docket',
> required = False),
> Field('Reference_Docket_No', 'integer',
> required = False),
> ...
>
> db.Docket.Reference_Docket_ID.requires=IS_IN_DB(db,'Docket.
> Reference_Docket_ID','%(Docket_No)s'))
> db.Docket.Reference_Docket_ID.represent=lambda value,row: value
>
>
> On Monday, 18 February 2013 02:19:04 UTC-6, Paul Whipp wrote:
>>
>> Here is an example of what I need to do:
>>
>> db.define_table('Docket',
>> Field('Docket_No', 'integer',
>> required = True),
>> Field('Reference_Docket_ID', 'reference Docket',
>> required = False),
>> Field('Reference_Docket_No', 'integer',
>> required = False),
>> ...
>>
>> The docket optionally refers to a preceding docket in the model. It
>> appears that web2py's DAL ignores the required = False specification for
>> this field because when I use the SQLFORM it tells me that 'Reference
>> Docket_ID' is a required field so its impossible to enter any docket
>> records.
>>
>> The client database is postgresSQL
>>
>> I tried adding the field constraints (e.g. db.Docket.Docket_No.requires = 
>> IS_NULL_OR(IS_IN_DB(...)))
>> but then it fails to display the dropdown when the form is presented.
>>
>> With hundreds of tables, I don't want to have to craft the form by hand.
>>
>> I'm also wondering what happens when there are many thousands of dockets
>> - will the dropdown for the Reference_Docket_ID on the form cope
>> effectively?
>>
>> Cheers,
>> Paul
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] why does this not work f=locals()['IS_IN_SET'] ?

2013-02-18 Thread Tim Richardson
When in interactive mode (python web2py.py -S welcome)
I can do this:
f = local()['IS_IN_SET']
and I get f as a function variable.

But the same thing in a controller fails with a KeyError. 

[I'm trying to make an SQLFORM.factory form based on queries defined in a 
table, with SQL, parameters and validation for the parameters]

python 2.7.2 on Windows 



-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] unable to remove jqmobile

2013-02-18 Thread greaneym
Hello,

I am trying out the jqmobile plugin and finding a strange result.
It's stuck on the mobile view no matter what changes I make.

I took these steps to get the mobile view to work.

1. copied the plugin_jqmobile from the admin app to my app.
2. copied the views/default/index to index.mobile.html and added the extend 
plugin_jqmobile/layouts line

3.  added the line to the controller/defaults.py
from gluon.contrib.user_agent_parser import mobilize
@mobilize
def index():

etc.

and it was really nice, I could see a layout as if I was viewing it on a 
mobile device.

But it wasn't exactly what I wanted and then I tried to remove it and 
wasn't able to.

I changed my routes.py so it doesn't show that view anymore.

But I'd like to figure out how to completely remove the view showing the 
mobile view.

It looks like an automatic file in views got created named index.html that 
contains the 
extend plugin_jqmobile layouts line.
I removed that and also removed the views/plugin_jqmobile directory  and 
reloaded the page, but
the mobile view is still there.

What else should I look at to modify or remove files to disable the mobile 
view?
Thanks,
Margaret

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Setting up memcache on GAE - a basic question

2013-02-18 Thread howesc
cacheable=True is a newish option to selects right?  i've not yet used 
itand had forgotten about it.

cfh

On Monday, February 18, 2013 7:17:02 AM UTC-8, Niphlod wrote:
>
> cacheable=True does not help ?
>
> On Monday, February 18, 2013 4:11:13 PM UTC+1, howesc wrote:
>>
>> ah yes
>>
>> the Rows() object returned from a select is not pickable.
>>
>> i do this a lot:
>>
>> students = cache.ram('students',
>> lambda:db(db.student.id>0).select(db.student.id, 
>> db.student.family_name,
>> ...
>> db.student.student_age).to_dict(),
>> 3600)
>>
>>
>> On Sunday, February 17, 2013 10:09:18 PM UTC-8, Andy W wrote:
>>>
>>> Thanks for the feedback Christian.
>>>
>>> It seems to be this that causes the problem on GAE but works on sqlite:
>>>
>>> students = cache.ram('students',
>>> lambda:db(db.student.id>0).select(db.student.id
>>> , 
>>> db.student.family_name,
>>> ...
>>> db.student.student_age),
>>> 3600)
>>>
>>> Any ideas?
>>>
>>> Thanks,
>>> Andy
>>>

>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] separate database and web server web2py installation

2013-02-18 Thread Michele Comitini
Rule of thumb

Local) simple queries, single web frontend
Remote) very complex queries/very large dataset, >1 web frontend

Separation is also very useful for maintenance, since upgrading paths
for python and or web2py may diverge from those of the db.
Upgrading the db can be very complex and usually in not security
critical, the reverse is true for the web frontend.

mic

2013/2/18 Derek :
> ssh does encryption, and encryption is a type of minor compression, so you
> may be transmitting less data on the line.
>
>
> On Monday, February 18, 2013 3:15:07 PM UTC-7, Richard wrote:
>>
>> Final result :
>>
>> no_ssh : 32.810 seconds (worst)
>> remote with ssh : 32.010 seconds
>> local : 31.494 seconds
>>
>> These are pretty basic tests, with profiler my dev machine may not be in
>> exact same state (more memory or less for the differents test particularly
>> the last test with no ssh).
>>
>> But it pretty strange that no ssh take even longer then with ssh...
>>
>> Richard
>>
>>
>>
>> Le lundi 18 février 2013 16:49:30 UTC-5, Niphlod a écrit :
>>>
>>> well, it depends.
>>> distinct boxes: more latency for every connection
>>> one-box: less latency but possibly ram,cpu,disk contention
>>> If your app uses a lot of CPU (that doesn't mean "your app do expensive
>>> db queries, that cpu is used by the db process") or a lot of memory or does
>>> a lot of writing/reading from disks, then having it separate can be better
>>> then having all in one box. response.toolbar() holds all the timings of the
>>> last queries, so you can use it to time the difference between a query on
>>> the local db instance and on the remote one.
>>>
>>> PS: ssh encryption on all traffic from/to the database adds another
>>> layer.
>>>
>>> On Monday, February 18, 2013 10:43:24 PM UTC+1, Richard wrote:

 Hello,

 I would like to know if someone has any experience to report here about
 separating web and database server into distinct server (2 linux box for
 example).

 I making some test actually and found no great improvement to do so... I
 access the remote database server through ssh port fowarding, so it may be
 the reason why I have no speed improvement.

 But I read that if web app is making a lot of db request (1000+) it may
 be a bad idea to split web server and database server
 (http://www.mysqlperformanceblog.com/2006/10/16/should-mysql-and-web-server-share-the-same-box/).
 In web2py "represent=lambda..." trigger a lot of db request, so I wonder if
 web2py represent could be responsible of the no speed improvement.

 I use profiler and the difference between local and remote database is
 pretty small (.5 sec longer with remote db).

 I will try to profile remote database with no ssh to see if I get speed
 improvement and get back here.

 Thanks

 Richard

 PS.: I try to use "performance" as a tag, but I can't add new tag, but I
 think that having a "performance" tag or "speed" tag could be great...




> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] separate database and web server web2py installation

2013-02-18 Thread Derek
ssh does encryption, and encryption is a type of minor compression, so you 
may be transmitting less data on the line.

On Monday, February 18, 2013 3:15:07 PM UTC-7, Richard wrote:
>
> Final result :
>
> no_ssh : 32.810 seconds (worst)
> remote with ssh : 32.010 seconds
> local : 31.494 seconds
>
> These are pretty basic tests, with profiler my dev machine may not be in 
> exact same state (more memory or less for the differents test particularly 
> the last test with no ssh).
>
> But it pretty strange that no ssh take even longer then with ssh...
>
> Richard
>
>
>
> Le lundi 18 février 2013 16:49:30 UTC-5, Niphlod a écrit :
>>
>> well, it depends.
>> distinct boxes: more latency for every connection
>> one-box: less latency but possibly ram,cpu,disk contention
>> If your app uses a lot of CPU (that doesn't mean "your app do expensive 
>> db queries, that cpu is used by the db process") or a lot of memory or does 
>> a lot of writing/reading from disks, then having it separate can be better 
>> then having all in one box. response.toolbar() holds all the timings of the 
>> last queries, so you can use it to time the difference between a query on 
>> the local db instance and on the remote one.
>>
>> PS: ssh encryption on all traffic from/to the database adds another layer.
>>
>> On Monday, February 18, 2013 10:43:24 PM UTC+1, Richard wrote:
>>>
>>> Hello,
>>>
>>> I would like to know if someone has any experience to report here about 
>>> separating web and database server into distinct server (2 linux box for 
>>> example).
>>>
>>> I making some test actually and found no great improvement to do so... I 
>>> access the remote database server through ssh port fowarding, so it may be 
>>> the reason why I have no speed improvement.
>>>
>>> But I read that if web app is making a lot of db request (1000+) it may 
>>> be a bad idea to split web server and database server (
>>> http://www.mysqlperformanceblog.com/2006/10/16/should-mysql-and-web-server-share-the-same-box/).
>>>  
>>> In web2py "represent=lambda..." trigger a lot of db request, so I wonder if 
>>> web2py represent could be responsible of the no speed improvement.
>>>
>>> I use profiler and the difference between local and remote database is 
>>> pretty small (.5 sec longer with remote db).
>>>
>>> I will try to profile remote database with no ssh to see if I get speed 
>>> improvement and get back here.
>>>
>>> Thanks
>>>
>>> Richard
>>>
>>> PS.: I try to use "performance" as a tag, but I can't add new tag, but I 
>>> think that having a "performance" tag or "speed" tag could be great...
>>>
>>>
>>>
>>>
>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] CPU 210%

2013-02-18 Thread Michele Comitini
Niphold explanation is better than anything I could come out with.

One could ask why pool_size=1 and not pool_size=0 then?
A pool of one seems logical nonsense, but it works.
1 means that we keep recycling that same connection that is bound to
the non-threading process.
Think "recycle_connection=True" and write it as "pool_size=1"

mic


2013/2/18 Richard Vézina :
> Thanks Niphold for clarification, really appreciate.
>
> Richard
>
>
> On Mon, Feb 18, 2013 at 4:17 PM, Niphlod  wrote:
>>
>> it "easy". if you run web2py using threads, then pooling is ok, since it's
>> managed in a single process, recycling connections in a pool for each new
>> thread that processes a request, and speeds up things a lot.
>>
>> A lot of webserver though use a single process to handle every request,
>> using fork() (gunicorn, uwsgi, and so on) to provide concurrency. It
>> means that there are n processes able to serve up to n requests
>> concurrently.
>> In that case, there are no threads involved, so there's no need to use a
>> pool, because every request is handled in a "freshly created" new single
>> process.
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] separate database and web server web2py installation

2013-02-18 Thread Richard
Final result :

no_ssh : 32.810 seconds (worst)
remote with ssh : 32.010 seconds
local : 31.494 seconds

These are pretty basic tests, with profiler my dev machine may not be in 
exact same state (more memory or less for the differents test particularly 
the last test with no ssh).

But it pretty strange that no ssh take even longer then with ssh...

Richard



Le lundi 18 février 2013 16:49:30 UTC-5, Niphlod a écrit :
>
> well, it depends.
> distinct boxes: more latency for every connection
> one-box: less latency but possibly ram,cpu,disk contention
> If your app uses a lot of CPU (that doesn't mean "your app do expensive db 
> queries, that cpu is used by the db process") or a lot of memory or does a 
> lot of writing/reading from disks, then having it separate can be better 
> then having all in one box. response.toolbar() holds all the timings of the 
> last queries, so you can use it to time the difference between a query on 
> the local db instance and on the remote one.
>
> PS: ssh encryption on all traffic from/to the database adds another layer.
>
> On Monday, February 18, 2013 10:43:24 PM UTC+1, Richard wrote:
>>
>> Hello,
>>
>> I would like to know if someone has any experience to report here about 
>> separating web and database server into distinct server (2 linux box for 
>> example).
>>
>> I making some test actually and found no great improvement to do so... I 
>> access the remote database server through ssh port fowarding, so it may be 
>> the reason why I have no speed improvement.
>>
>> But I read that if web app is making a lot of db request (1000+) it may 
>> be a bad idea to split web server and database server (
>> http://www.mysqlperformanceblog.com/2006/10/16/should-mysql-and-web-server-share-the-same-box/).
>>  
>> In web2py "represent=lambda..." trigger a lot of db request, so I wonder if 
>> web2py represent could be responsible of the no speed improvement.
>>
>> I use profiler and the difference between local and remote database is 
>> pretty small (.5 sec longer with remote db).
>>
>> I will try to profile remote database with no ssh to see if I get speed 
>> improvement and get back here.
>>
>> Thanks
>>
>> Richard
>>
>> PS.: I try to use "performance" as a tag, but I can't add new tag, but I 
>> think that having a "performance" tag or "speed" tag could be great...
>>
>>
>>
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Default SQLFORM.grid / auth restrictions?

2013-02-18 Thread Jim S
>From what I see you shouldn't have to have any groups setup.  You will need 
a user which you can use the register function (from the generated login 
box on your main page) to create.

Also, it appears as though you have your table setup incorrectly.  If you 
want portfolio_id to be the keyfield of you table, you should do it like 
this:

db.define_table('portfolio_data',
  Field('portfolio_id', 'id'),
Field('close_date', 'date'),
Field('index_value'),
Field('portfolio_value'),
Field('cash_change'))

I don't think that would have any effect on the Not Authorized error, but 
might get you down the road.  Just to confirm, you are logged in and all 
when you test this, right?  Sorry to ask such a trivial question, but just 
want to make sure all the bases are covered.

-Jim


On Saturday, February 16, 2013 4:56:49 PM UTC-6, Matt House wrote:
>
> Hello-
> I am new to Web2Py and I think I have a simple question, but I've banged 
> my head on the desk for two hours and searched this forum to no avail. 
>
> I have setup a basic database and want to give the user the ability to 
> edit a series of fields using SQLFORM.grid. I also want users to be logged 
> in before they can edit the fields (I'd actually prefer they can only edit 
> fields they inserted, but I will come back to that later...). 
>
> Here is my model:
>
> db.define_table('portfolio_data',
> Field('portfolio_id'),
> Field('close_date', 'date'),
> Field('index_value'),
> Field('portfolio_value'),
> Field('cash_change'))
>
> portfolio_id is simply a sequential number (1, 2, 3) generated when the 
> user creates the new portfolio. 
>
> I created a controller called edit, which takes an argument equal to the 
> portfolio_id (so edit/1 edits rows for portfolio 1, edit/2 rows for 
> portfolio 2, etc.)
>
> @auth.requires_login()
> def edit():
> # get portfolio ID from URL string
> passed_id = request.args(0)
>
> query = (db.portfolio_data.portfolio_id == passed_id)
> form = SQLFORM.grid(query=query)
> 
> return dict(form=form)
>
> When I try to access /default/edit/1, I get a "Not Authorized" error. If 
> I set user_signature=False in the SQLFORM.grid call, then I'm able to 
> view and edit the table rows without a problem. 
>
> My diagnosis is that I have something set incorrectly in the 
> authentication tables. I added a group users and gave them permission to 
> read, update and select from the table db.portfolio_data, but still no 
> luck. I'm also confused why I would need to do that at all, since all I'm 
> asking for in the controller is a login and nothing more (i.e., I'm not 
> restricting table access anywhere). (And lest anyone ask, I am definitely 
> logged in.) 
>
> Are there default table edit restrictions somewhere that I missed in the 
> documentation? Or is there something else I need to do to get SQLFORM and 
> auth to play together nicely? I'm working from the default web2py scaffold, 
> so I'm surprised no one else has run into this issue. The only similar 
> issue I found was 
> this- 
> I can't even reproduce the issue Kevin highlights in his question. 
>
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: SmartGrid and New button 1 to many

2013-02-18 Thread Jim S
Dan 

the problem is that you are using SQLFORM.grid instead of 
SQLFORM.smartgrid.  Try changing that and you should be good.  Sorry for 
the delay, had a busy weekend

-Jim

On Saturday, February 16, 2013 12:20:22 PM UTC-6, Dan Kozlowski wrote:
>
> Jim,
>
> I still can't get it working. I have  dailycounts which is one record per 
> day and has many history records per day. Looking for a button to show all 
> the history records when a day is selected form dailycounts. Below is the 
> controller and DAL
>
> Thanks
>
>
> def dailycounts():
> grid=SQLFORM.grid(db.daily_counts, 
> user_signature=False,create=False,editable=False,deletable=False,orderby=~db.daily_counts.add_date,
>  
> fields=[db.daily_counts.add_date,db.daily_counts.encrypt_count,db.daily_counts.decrypt_count,db.daily_counts.error_count,db.daily_counts.cycle_count,db.daily_counts.directory_create_count,db.daily_counts.client_add_count])
> return locals()
>
>
> db.define_table('daily_counts',
>Field('encrypt_count','integer'),
>Field('decrypt_count','integer'),
>Field('error_count','integer'),
>Field('cycle_count','integer'),
>Field('directory_create_count','integer'),
>Field('client_add_count','integer'),
>Field('client_update_count','integer'),
>Field('client_delete_count','integer'),
>Field('encryption_key_count','integer'),
>Field('add_date','date', unique=True),
>Field('add_time','time'),
>Field('add_db_user','string'),
>Field('add_app_user','string'),
>Field('update_date','date'),
>Field('update_time','time'),
>Field('update_db_user','string'),
>Field('update_app_user','string'))
>
> db.define_table('history',
>Field('client_id','string',length=10),
>Field('command','string',length=255),
>Field('encrypt_key','string',length=50),
>Field('from_dir','string',length=100),
>Field('to_dir','string',length=100),
>Field('archive_dir','string',length=100),
>Field('error_dir','string',length=100),
>Field('in_filename','string',length=100),
>Field('out_filename','string',length=100),
>Field('encryption_type','string'),
>Field('add_date',db.daily_counts),
>Field('add_time','time'),
>Field('add_db_user','string'),
>Field('add_app_user','string'))
>
>
>
>
>
>
>
>
>
>
> On Friday, February 15, 2013 10:29:46 PM UTC-6, Dan Kozlowski wrote:
>>
>> Does anyone know if I  smartgrid to can create another button next to 
>>  View, Edit, Delete that will allow it to open a new search screen ? I have 
>> a customer ( 1 to many notes) and would like a  Notes button  that takes 
>> you to another search screen to allow you to view 1 to many Notes a 
>> customer can have ?
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] separate database and web server web2py installation

2013-02-18 Thread Niphlod
well, it depends.
distinct boxes: more latency for every connection
one-box: less latency but possibly ram,cpu,disk contention
If your app uses a lot of CPU (that doesn't mean "your app do expensive db 
queries, that cpu is used by the db process") or a lot of memory or does a 
lot of writing/reading from disks, then having it separate can be better 
then having all in one box. response.toolbar() holds all the timings of the 
last queries, so you can use it to time the difference between a query on 
the local db instance and on the remote one.

PS: ssh encryption on all traffic from/to the database adds another layer.

On Monday, February 18, 2013 10:43:24 PM UTC+1, Richard wrote:
>
> Hello,
>
> I would like to know if someone has any experience to report here about 
> separating web and database server into distinct server (2 linux box for 
> example).
>
> I making some test actually and found no great improvement to do so... I 
> access the remote database server through ssh port fowarding, so it may be 
> the reason why I have no speed improvement.
>
> But I read that if web app is making a lot of db request (1000+) it may be 
> a bad idea to split web server and database server (
> http://www.mysqlperformanceblog.com/2006/10/16/should-mysql-and-web-server-share-the-same-box/).
>  
> In web2py "represent=lambda..." trigger a lot of db request, so I wonder if 
> web2py represent could be responsible of the no speed improvement.
>
> I use profiler and the difference between local and remote database is 
> pretty small (.5 sec longer with remote db).
>
> I will try to profile remote database with no ssh to see if I get speed 
> improvement and get back here.
>
> Thanks
>
> Richard
>
> PS.: I try to use "performance" as a tag, but I can't add new tag, but I 
> think that having a "performance" tag or "speed" tag could be great...
>
>
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] separate database and web server web2py installation

2013-02-18 Thread Richard
Hello,

I would like to know if someone has any experience to report here about 
separating web and database server into distinct server (2 linux box for 
example).

I making some test actually and found no great improvement to do so... I 
access the remote database server through ssh port fowarding, so it may be 
the reason why I have no speed improvement.

But I read that if web app is making a lot of db request (1000+) it may be 
a bad idea to split web server and database server (
http://www.mysqlperformanceblog.com/2006/10/16/should-mysql-and-web-server-share-the-same-box/).
 
In web2py "represent=lambda..." trigger a lot of db request, so I wonder if 
web2py represent could be responsible of the no speed improvement.

I use profiler and the difference between local and remote database is 
pretty small (.5 sec longer with remote db).

I will try to profile remote database with no ssh to see if I get speed 
improvement and get back here.

Thanks

Richard

PS.: I try to use "performance" as a tag, but I can't add new tag, but I 
think that having a "performance" tag or "speed" tag could be great...




-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] CPU 210%

2013-02-18 Thread Richard Vézina
Thanks Niphold for clarification, really appreciate.

Richard


On Mon, Feb 18, 2013 at 4:17 PM, Niphlod  wrote:

> it "easy". if you run web2py using threads, then pooling is ok, since it's
> managed in a single process, recycling connections in a pool for each new
> thread that processes a request, and speeds up things a lot.
>
> A lot of webserver though use a single process to handle every request,
> using fork() (gunicorn, uwsgi, and so on) to provide concurrency. It
> means that there are n processes able to serve up to n requests
> concurrently.
> In that case, there are no threads involved, so there's no need to use a
> pool, because every request is handled in a "freshly created" new single
> process.
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] CPU 210%

2013-02-18 Thread Niphlod
it "easy". if you run web2py using threads, then pooling is ok, since it's 
managed in a single process, recycling connections in a pool for each new 
thread that processes a request, and speeds up things a lot.

A lot of webserver though use a single process to handle every request, 
using fork() (gunicorn, uwsgi, and so on) to provide concurrency. It 
means that there are n processes able to serve up to n requests 
concurrently.
In that case, there are no threads involved, so there's no need to use a 
pool, because every request is handled in a "freshly created" new single 
process.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Removing HTML TAGS

2013-02-18 Thread Kenneth
Thank both Bruno and Michele. 

I just tried you second suggestion Michele but still got an ticket. But by 
changing places of str and TAG and adding flatten() I got what I wanted. 

XML(TAG(str(elements[9])).flatten())


Kenneth


use beatifulsoup a one stop shop for html mangling 
> http://www.crummy.com/software/BeautifulSoup/ 
>
> or try this: 
>
> XML(str(TAG(elements[9])) 
>
> mic 
>
> 2013/2/18 Bruno Rocha >: 
> > 
> > 
> > 
> http://stackoverflow.com/questions/9662346/python-code-to-remove-html-tags-from-a-string
>  
> > 
> > -- 
> > 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "web2py-users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to web2py+un...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Removing HTML TAGS

2013-02-18 Thread Michele Comitini
use beatifulsoup a one stop shop for html mangling
http://www.crummy.com/software/BeautifulSoup/

or try this:

XML(str(TAG(elements[9]))

mic

2013/2/18 Bruno Rocha :
>
>
> http://stackoverflow.com/questions/9662346/python-code-to-remove-html-tags-from-a-string
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] CPU 210%

2013-02-18 Thread Richard Vézina
Hello,

I am trying to optimize speed a bit these days, and read this thread and
Michele "10 rules to speed" and I am mystify about rule 10 : 10. use the
dal pooling machinery, i.e. db=DAL(..., pool_size=1)

About the pool_size parameter is very important to reduce response
time and use an adequate value.
The above pool_size=1 using processes seems weird, but is not: each
request is handled by a process that needs only a single connection no
more,
using threads pool_size needs a value >= to the maximum number of
threads in a web2py instance.
The total number of persistent connections to the db is conn_n =
proc_num x pool_size (with proc_num = number of processes). So if you
have 20 processes (proc_num=20) with pool_size=1:

conn_n = 20 x 1 = 20

If you have 20 threads (proc_num = 1) with pool_size=20:

conn_n = 1 x 20 = 20


I read many time on this Massimo wrote more high is the pool_size the
better will be the performance... But what Michele seems to explain here is
the inverse... Or that only pool_size=1 is enough?!

Is it possible to get clarification here?

Thanks

Richard


On Tue, Apr 17, 2012 at 4:40 PM, Michele Comitini <
michele.comit...@gmail.com> wrote:

> Richard you are right.  We should make a web2py slice out of this.  I
> keep repeating same things over from time to time, I suppose it's the
> age... ;-)
>
> Anyway a put a star on the thread so one day I will write.
>
> Here are 10 system configuration rules I follow for high scalability
> with web2py on multicore machines:
> 1. use processes not threads or use pypy
> 2. use an event based http frontend
> 3. use UWSGI or SCGI or FCGI
> 4. use HTTP keepalive
> 5. treat static content as static i.e. keep it out of the views
> 6. reduce number and size of static files, i.e. sprites and pack js
> and css and aggregate them in a file
> 7. support gzip encoding for files > 1KB
> 8. put the database(s) on a different machine(s) or double the cores
> i.e. for each request have 2 cores at hand
> 9. cache dynamic content leveraging on web2py cache
> 10. use the dal pooling machinery, i.e. db=DAL(..., pool_size=1)
>
> About the pool_size parameter is very important to reduce response
> time and use an adequate value.
> The above pool_size=1 using processes seems weird, but is not: each
> request is handled by a process that needs only a single connection no
> more,
> using threads pool_size needs a value >= to the maximum number of
> threads in a web2py instance.
> The total number of persistent connections to the db is conn_n =
> proc_num x pool_size (with proc_num = number of processes). So if you
> have 20 processes (proc_num=20) with pool_size=1:
>
> conn_n = 20 x 1 = 20
>
> If you have 20 threads (proc_num = 1) with pool_size=20:
>
> conn_n = 1 x 20 = 20
>
> .
>
> mic
>
> Il 17 aprile 2012 21:00, Richard Vézina 
> ha scritto:
> > Michele,
> >
> > I read this thread, not sure if it is not already existing... But it
> start
> > to look like a recipe for speed tuning that could be translate into a
> web2py
> > slice or blog post :)
> >
> > Richard
> >
> >
> > On Tue, Apr 17, 2012 at 2:32 PM, Michele Comitini
> >  wrote:
> >>
> >> What I suggest is use nginx + uwsgi or nginx + scgi or nginx + fcgi.
> >> You will notice big reduction in resource consuption compared to
> >> Apache.
> >> Apache can be taken away.  By the way you can use any of the above
> >> protocols to do balancing over a pool of machines running web2py and
> >> in front you can put nginx as balancer.
> >>
> >> About caching, what is important is using as much as possible the
> >> *static* dir and have the files underneath served by nginx directly.
> >> You must check that expiration times on static objects are correctly
> >> set.  Also use sprites as much as you can.  You will enjoy a big
> >> improvement because after downloading the objects the first time a
> >> client browser will make only requests for the dynamically generated
> >> contents.  Other objects will be taken by the ondisk cache of the
> >> browser. If  the object is expired  in browser cache, but the content
> >> not changed on the server, the request will result only in a 304
> >> answer so little data is exchanged and little computation is required.
> >>
> >> mic
> >>
> >>
> >> Il 17 aprile 2012 19:10, Bruce Wade  ha scritto:
> >> > Currently I just had 1 server running apache mod_wsgi using the same
> >> > configuration as pyramid. However I just got approved for a few grand
> a
> >> > month to spend on server resources, so I am looking at load balancers.
> >> > And I
> >> > will put nginx in front of apache, and also start using a lot more
> >> > caching.
> >> >
> >> >
> >> > On Tue, Apr 17, 2012 at 5:15 AM, Michele Comitini
> >> >  wrote:
> >> >>
> >> >> One more thing make css and js packed + server side gzipped (nginx
> and
> >> >> cherokee can do also gzip caching)
> >> >>
> >> >> mic
> >> >>
> >> >> Il 17 aprile 2012 14:12, Michele Comitini <
> michele.comit...@gmail.com>
> >> >> ha scritto:
> >> >> > If you

[web2py] Re: 'appadmin' on trying ot load data admin

2013-02-18 Thread Niphlod
mysql or mssql ? Windows + MSSQL is one of mine "de facto" setups.

I find hard to believe that the same app, same models and same db uri (so, 
same exact code) have a "preference" for working fine in an app and raising 
exceptions in another. Something MUST be different.

On Monday, February 18, 2013 6:18:57 PM UTC+1, Andrew Buchan wrote:
>
> I should have added a bit more info...
>
> I'm running on MsSQL, and have 2 applications pointing at the same 
> database, one live and one mirror copy for minor changes. From one 
> application the data admin interface opens fine, from the other it gives me 
> the appadmin exceptions. The files in /model and /databases are identical 
> for both, and both apps running from the same instance of web2py.
>
> Also, I have to restart web2py altogether pretty much every time a migrate 
> operation fails. I can't be completely sure if this is something new, but 
> don't remember it being like that before I upgraded to 2.3.2.
>
> I've also raised issues 
> 1343
>  and 1344 
> with 
> the latter being a rather serious one that has had me chasing my tail 
> finding new places where this could crop up and covering up for it until it 
> there's a fix (my bad for not having a selenium test suite!).
>
> Although I'm sure most of my woes are down to things I'm doing wrong these 
> issues give me the feeling that changes to web2py over the last year or so 
> have not been thoroughly tested on MsSQL deployments. I know most of you 
> deploy on LAMP-ish setups, but I haven't got that option and feel I'm 
> incurring a lot of extra work for using a less favoured microsoft stack. 
> I'm stuck with windows on this one, but am wondering if anyone has any 
> experience implementing web2py on mysql in a windows environment?
>
>
> Oh, and here's another exception.
>
> Traceback (most recent call last):
>   File "C:\Program Files\Hub Pages\web2py\gluon\restricted.py", line 212, in 
> restricted
> exec ccode in environment
>   File "C:/Program Files/Hub 
> Pages/web2py/applications/HubFormsTidy/views/appadmin.html" 
> , line 
> 88, in 
> {{if hasattr(table,'_primarykey'):}}
> KeyError: 'appadmin'
>
>
> On Friday, February 15, 2013 3:27:58 PM UTC, Andrew Buchan wrote:
>>
>> Here's the exception I get:
>>
>>
>> Traceback (most recent call last):
>>   File "C:\Program Files\Hub Pages\web2py\gluon\restricted.py", line 212, in 
>> restricted
>> exec ccode in environment
>>   File "C:/Program Files/Hub 
>> Pages/web2py/applications/HubFormsTidy/views/appadmin.html" 
>> , line 
>> 86, in 
>> {{elif request.function=='update':}}
>> KeyError: 'appadmin'
>>
>>
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Block oversized uploads serverside

2013-02-18 Thread Niphlod
usually in production you can put a limit on post size directly in the 
webserver.

On Monday, February 18, 2013 6:55:46 PM UTC+1, Andriy wrote:
>
> I just checked on server (and not localhost as I did before) and I must 
> correct myself. File transfer goes though, but file never appears in 
> uploads folder (which is a plus, but transfer itself is not safe). I`ll 
> still open a ticket, may be you can do something to prevent file transfer.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Connecting to MySQL via SSL

2013-02-18 Thread Richard Vézina
You are welcome!

Richard


On Sat, Feb 16, 2013 at 5:40 PM, Osman Masood  wrote:

> Thanks, Richard. It worked.
>
> The command I used was:
> ssh linux_user@ip_address -L 3307:database_ip:3306
>
> (Our database is hosted on Amazon RDS, so for us ip_address was different
> from database_ip. )
>
> Our connection string was:
>
> 'mysql://user:password@localhost:3307/database_name'
>
>
> Thanks again!
>
>
> On Fri, Feb 15, 2013 at 9:27 AM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Better use SSH with port fowarding...
>>
>> Something like that in terminal :
>>
>> ssh -L3307:localhost:3306 linux_user@ip_address
>>
>> Then you should be able to use this connection string :
>>
>> db=DAL('mysql://user:pwd@127.0.0.1:3307/database', ...)
>>
>> Not tested...
>>
>> Richard
>>
>>
>> On Thu, Feb 14, 2013 at 6:08 PM, Osman Masood  wrote:
>>
>>> Hi,
>>> I'm trying to connect get web2py to connect to MySQL via SSL (or SSH).
>>> Based on the code, seems like I need to do something like:
>>>
>>> db = DAL('..',
>>> driver_args=dict(ssl=dict(ca='/path/to/mysql-ssl-ca-cert.pem')))
>>>
>>> (I only need the CA cert file, the key and certificate files are not
>>> needed for the connection.)
>>>
>>> It works through my SQL client (Sequel Pro), but not through web2py.
>>> Anyone have any ideas? It gives me the following error message:
>>>
>>>  Failure to connect, tried 5 times:
>>> Traceback (most recent call last): File
>>> "/Users/oamasood/src/web2py/gluon/dal.py", line 6853, in __init__
>>> self._adapter = ADAPTERS[self._dbname](**kwargs) File
>>> "/Users/oamasood/src/web2py/gluon/dal.py", line 2402, in __init__ if
>>> do_connect: self.reconnect() File
>>> "/Users/oamasood/src/web2py/gluon/dal.py", line 576, in reconnect
>>> self.connection = f() File "/Users/oamasood/src/web2py/gluon/dal.py", line
>>> 2400, in connector return self.driver.connect(**driver_args) File
>>> "/Users/oamasood/src/web2py/gluon/contrib/pymysql/__init__.py", line 93, in
>>> Connect return Connection(*args, **kwargs) File
>>> "/Users/oamasood/src/web2py/gluon/contrib/pymysql/connections.py", line
>>> 575, in __init__ self._connect() File
>>> "/Users/oamasood/src/web2py/gluon/contrib/pymysql/connections.py", line
>>> 741, in _connect self._request_authentication() File
>>> "/Users/oamasood/src/web2py/gluon/contrib/pymysql/connections.py", line
>>> 796, in _request_authentication self._send_authentication() File
>>> "/Users/oamasood/src/web2py/gluon/contrib/pymysql/connections.py", line
>>> 822, in _send_authentication self.socket =
>>> ssl.wrap_self.socketet(self.socket, keyfile=self.key, AttributeError:
>>> 'module' object has no attribute 'wrap_self'
>>>
>>>
>>> Thanks,
>>> Osman
>>>
>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Querying values from two databases using Dal

2013-02-18 Thread Christian Espinoza
Yeah, it worked!!!:

query = """SELECT *FROM db_alerts.alerts, db_app.trucks
WHERE db_app.trucks.customer_id = 1
AND db_alerts.alerts.truck_lic = db_app.trucks.lic
ORDER BY db_alerts.alerts.id DESC LIMIT 1"""


db_app.executesql(query)

Thanks Niphlod !!
Christian.

El lunes, 18 de febrero de 2013 13:34:01 UTC-3, Niphlod escribió:
>
> DAL can't do cross database queries, unless you use executesql.
>
> On Monday, February 18, 2013 5:27:38 PM UTC+1, Christian Espinoza wrote:
>>
>> Hi all, I'm need get the last alert(a table record) from db_alerts 
>> database for every customer's truck,
>> but I'm can't get it, I'm using MYSQL.
>>
>> Table trucks at db_base:
>> db_app.define_table('trucks',
>> Field('customer_id', db_app.customers),
>> Field('lic', length=10),
>> Field('cap', 'integer'),
>> Field('vendor' db_app.vendor),
>> format='%(lic)s'
>> )
>>
>> Table alerts at db_alerts:
>> db_alerts.define_table('alerts',
>> Field('truck_lic', length=10),
>> Field('name', length=20),
>> Field('location', length=30),
>> Field('description', length=100),
>> Field('date', datetime)
>> )
>>
>>
>>  WORKING MYSQL QUERY:
>>
>> SELECT *
>> FROM db_alerts.alerts, db_app.trucks
>> WHERE db_app.trucks.customer_id = 1
>> AND db_alerts.alerts.truck_lic = db_app.trucks.lic
>> ORDER BY db_alerts.alerts.id DESC LIMIT 1
>>
>> Using Dal
>>
>> query = (db_app.trucks.customer_id ==1) & (db _app
>> .trucks.lic == db_alerts.alerts.truck_lic)
>>
>>
>>
>> The second query is the problem, how can I run it??
>>
>> Thanks guys for your time and support.
>> Greetings.
>> Christian.
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Block oversized uploads serverside

2013-02-18 Thread Andriy
I just checked on server (and not localhost as I did before) and I must 
correct myself. File transfer goes though, but file never appears in 
uploads folder (which is a plus, but transfer itself is not safe). I`ll 
still open a ticket, may be you can do something to prevent file transfer.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Block oversized uploads serverside

2013-02-18 Thread Massimo Di Pierro
Please open a ticket. Something like this could go in.

On Monday, 18 February 2013 11:26:00 UTC-6, Andriy wrote:
>
> I`m writing a forum with possibility of attachments and looking for a way 
> to refuse over-sized uploads. Validator IS_LENGTH() checks for upload file 
> size, but only after the whole file transfered to server. This may be a 
> security issue, since several attackers can start to upload Gb files to 
> server simultaneously and overload it.
>
> I searched but did not found how web2py can refuse an upload before it 
> started. But I found that if I add this line to *copystream_progress*function 
> in 
> *gluon\main.py:*
> if size>100: raise HTTP(403, "file size > 1mb, refused") - this works 
> and does not allow over-sized file to go through.
>
> Is this a possible way to deal with this problem? Or did I break something 
> if I add such line to *copystream_progress*? May be there is a way 
> already implemented in web2py? 
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How do I define a table that references itself

2013-02-18 Thread Massimo Di Pierro
The only problem is that for self referendes you do not get an automatic 
represent and validator (because the field is created before the table 
referenced is created):

You can do it manually:

db.define_table('Docket',
Field('Docket_No', 'integer',
required = True),
Field('Reference_Docket_ID', 'reference Docket',
required = False),
Field('Reference_Docket_No', 'integer',
required = False),
...

db.Docket.Reference_Docket_ID.requires=IS_IN_DB(db,'Docket.
Reference_Docket_ID','%(Docket_No)s'))
db.Docket.Reference_Docket_ID.represent=lambda value,row: value


On Monday, 18 February 2013 02:19:04 UTC-6, Paul Whipp wrote:
>
> Here is an example of what I need to do:
>
> db.define_table('Docket',
> Field('Docket_No', 'integer',
> required = True),
> Field('Reference_Docket_ID', 'reference Docket',
> required = False),
> Field('Reference_Docket_No', 'integer',
> required = False),
> ...
>
> The docket optionally refers to a preceding docket in the model. It 
> appears that web2py's DAL ignores the required = False specification for 
> this field because when I use the SQLFORM it tells me that 'Reference 
> Docket_ID' is a required field so its impossible to enter any docket 
> records.
>
> The client database is postgresSQL
>
> I tried adding the field constraints (e.g. db.Docket.Docket_No.requires = 
> IS_NULL_OR(IS_IN_DB(...))) 
> but then it fails to display the dropdown when the form is presented.
>
> With hundreds of tables, I don't want to have to craft the form by hand.
>
> I'm also wondering what happens when there are many thousands of dockets - 
> will the dropdown for the Reference_Docket_ID on the form cope effectively?
>
> Cheers,
> Paul
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: login by ajax

2013-02-18 Thread Massimo Di Pierro
self.login_bare() calls self.login_user(...) and it automatically logs 
in the user and stores user in session.auth.user


On Sunday, 17 February 2013 23:34:01 UTC-6, yashar wrote:
>
> is there any way that i log in user by code?
> for example after checking username and password with login_bare, i push 
> the user into the session as logged-in user? in this case there is no need 
> to write ajax/login directly, and the programmer has a better control.as 
> you can see in my code i check user two times one in bare_login and one in 
> auth.login, because i can not return 'login failed' value from code if i 
> use just form=auth.login().
>
> when the formkey is changing? during form creation or after each submit? 
> because i create two auth.login() forms one in the index for view and one 
> in login function, and this is working so the formkey must be same, but 
> could you help me to write a cleaner code? in that code after success login 
> page automaticly redirected as i dont understand why?
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] notnull in case of 'reference table'

2013-02-18 Thread Annet
I defined the following table in db.py:

db.define_table('timetable',
Field('nodeID','reference 
node',default='',requires=[IS_IN_DB(db,'node.id','%(id)s',zero=T('Select a 
value'))],ondelete='CASCADE',notnull=True,writable=False,readable=False),
Field('dayID','reference day',label='Dag * 
',default='',requires=IS_IN_DB(db,'day.id','%(name)s',orderby='day.id',zero='select
 
a value'),represent=lambda dayID, row: 
db(db.day.id==dayID).select().first().name if dayID else 
'',ondelete='RESTRICT',notnull=True),
Field('startDate',writable=False,readable=False,**isemptyorisdate),
Field('startTime',label='Start tijd * ',**istime),

Field('TZID',length=64,default=TZID,requires=IS_LENGTH(64,error_message=T('length
 
exceeds 64 characters')),label='Timezone ID',writable=False,readable=False),
Field('duration',length=4,requires=IS_LENGTH(4,error_message=T('length 
exceeds 4 characters')),label='Duur in minuten'),

Field('program',length=64,default='',requires=[IS_LENGTH(64,error_message=T('length
 
exceeds 64 characters')),IS_NOT_EMPTY()],notnull=True,label='Les * '),
migrate=False)

In Postgresql nodeID and dayID both have the property Not NULL set to No, 
whereas, program has this property set to Yes.
Why isn't the Not NULL property set to Yes for nodeID and dayID? This makes 
it possible to enter data using for example PHPPgAdmin
which are inconsistent with the table definition in web2py.

Kind regards,

Annet


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Block oversized uploads serverside

2013-02-18 Thread Andriy
I`m writing a forum with possibility of attachments and looking for a way 
to refuse over-sized uploads. Validator IS_LENGTH() checks for upload file 
size, but only after the whole file transfered to server. This may be a 
security issue, since several attackers can start to upload Gb files to 
server simultaneously and overload it.

I searched but did not found how web2py can refuse an upload before it 
started. But I found that if I add this line to *copystream_progress*function 
in 
*gluon\main.py:*
if size>100: raise HTTP(403, "file size > 1mb, refused") - this works 
and does not allow over-sized file to go through.

Is this a possible way to deal with this problem? Or did I brake something 
if I ad such line to *copystream_progress*? May be there is already 
implemented in web2py way? 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: 'appadmin' on trying ot load data admin

2013-02-18 Thread Andrew Buchan
I should have added a bit more info...

I'm running on MsSQL, and have 2 applications pointing at the same 
database, one live and one mirror copy for minor changes. From one 
application the data admin interface opens fine, from the other it gives me 
the appadmin exceptions. The files in /model and /databases are identical 
for both, and both apps running from the same instance of web2py.

Also, I have to restart web2py altogether pretty much every time a migrate 
operation fails. I can't be completely sure if this is something new, but 
don't remember it being like that before I upgraded to 2.3.2.

I've also raised issues 
1343
 and 1344 
with 
the latter being a rather serious one that has had me chasing my tail 
finding new places where this could crop up and covering up for it until it 
there's a fix (my bad for not having a selenium test suite!).

Although I'm sure most of my woes are down to things I'm doing wrong these 
issues give me the feeling that changes to web2py over the last year or so 
have not been thoroughly tested on MsSQL deployments. I know most of you 
deploy on LAMP-ish setups, but I haven't got that option and feel I'm 
incurring a lot of extra work for using a less favoured microsoft stack. 
I'm stuck with windows on this one, but am wondering if anyone has any 
experience implementing web2py on mysql in a windows environment?


Oh, and here's another exception.

Traceback (most recent call last):
  File "C:\Program Files\Hub Pages\web2py\gluon\restricted.py", line 212, in 
restricted
exec ccode in environment
  File "C:/Program Files/Hub 
Pages/web2py/applications/HubFormsTidy/views/appadmin.html" 
, line 
88, in 
{{if hasattr(table,'_primarykey'):}}
KeyError: 'appadmin'


On Friday, February 15, 2013 3:27:58 PM UTC, Andrew Buchan wrote:
>
> Here's the exception I get:
>
>
> Traceback (most recent call last):
>   File "C:\Program Files\Hub Pages\web2py\gluon\restricted.py", line 212, in 
> restricted
> exec ccode in environment
>   File "C:/Program Files/Hub 
> Pages/web2py/applications/HubFormsTidy/views/appadmin.html" 
> , line 
> 86, in 
> {{elif request.function=='update':}}
> KeyError: 'appadmin'
>
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: How to get request.args from an index() function?

2013-02-18 Thread Jonathan Lundell
On 18 Feb 2013, at 9:04 AM, Alec Taylor  wrote:
> Thanks, what's the routes syntax to specific functions?
> 
> This didn't work:
> 
> fruit = dict(
>default_function = 'index',
>controllers = ['salad'],
>functions = ['index','user','download','call',
> 'data','error','profile',]
>   )
> 
> Am I meant to specify the list in BASE?

No, anything app-specific goes in the app's router.

BTW, there's ordinarily no reason to list applications or controllers, unless 
you need to exclude one that's defined, because the default settings find them 
for you.

If you're making the same request (http://localhost/fruit/salad/f), I think it 
should be interpreted as http://localhost/fruit/salad/index/f; that is, args = 
['f']. What are you seeing?


> 
> On Tue, Feb 19, 2013 at 3:49 AM, Jonathan Lundell  wrote:
>> On 18 Feb 2013, at 8:38 AM, Niphlod  wrote:
>> 
>> ! Missed that.
>> 
>> On Monday, February 18, 2013 5:23:55 PM UTC+1, Jonathan Lundell wrote:
>>> 
>>> 
>>> You've listed salad as a function, but it's a controller.
>> 
>> 
>> PS: Next thing to code is a small page where you load routes, a text input
>> where you can insert an http url, and a textarea with the resulting
>> Wsplitted" url (function, controller, args, vars, language, etc) (in & out).
>> @Jonathan: if it's technically possible and you don't have time, I'll put in
>> my todo-list (and enlist you as a consultant :-P)
>> 
>> 
>> Another thing that could be helpful in debugging routes is to call URL()
>> with specified arguments and see what it generates. That would have shown a
>> problem with the fruit/salad router.
>> 
>> --
>> 
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.



-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: How to get request.args from an index() function?

2013-02-18 Thread Alec Taylor
*controllers that is

On Tue, Feb 19, 2013 at 4:04 AM, Alec Taylor  wrote:
> Thanks, what's the routes syntax to specific functions?
>
> This didn't work:
>
> fruit = dict(
> default_function = 'index',
> controllers = ['salad'],
> functions = ['index','user','download','call',
> 'data','error','profile',]
>)
>
> Am I meant to specify the list in BASE?
>
> On Tue, Feb 19, 2013 at 3:49 AM, Jonathan Lundell  wrote:
>> On 18 Feb 2013, at 8:38 AM, Niphlod  wrote:
>>
>> ! Missed that.
>>
>> On Monday, February 18, 2013 5:23:55 PM UTC+1, Jonathan Lundell wrote:
>>>
>>>
>>> You've listed salad as a function, but it's a controller.
>>
>>
>> PS: Next thing to code is a small page where you load routes, a text input
>> where you can insert an http url, and a textarea with the resulting
>> Wsplitted" url (function, controller, args, vars, language, etc) (in & out).
>> @Jonathan: if it's technically possible and you don't have time, I'll put in
>> my todo-list (and enlist you as a consultant :-P)
>>
>>
>> Another thing that could be helpful in debugging routes is to call URL()
>> with specified arguments and see what it generates. That would have shown a
>> problem with the fruit/salad router.
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: How to get request.args from an index() function?

2013-02-18 Thread Alec Taylor
Thanks, what's the routes syntax to specific functions?

This didn't work:

fruit = dict(
default_function = 'index',
controllers = ['salad'],
functions = ['index','user','download','call',
'data','error','profile',]
   )

Am I meant to specify the list in BASE?

On Tue, Feb 19, 2013 at 3:49 AM, Jonathan Lundell  wrote:
> On 18 Feb 2013, at 8:38 AM, Niphlod  wrote:
>
> ! Missed that.
>
> On Monday, February 18, 2013 5:23:55 PM UTC+1, Jonathan Lundell wrote:
>>
>>
>> You've listed salad as a function, but it's a controller.
>
>
> PS: Next thing to code is a small page where you load routes, a text input
> where you can insert an http url, and a textarea with the resulting
> Wsplitted" url (function, controller, args, vars, language, etc) (in & out).
> @Jonathan: if it's technically possible and you don't have time, I'll put in
> my todo-list (and enlist you as a consultant :-P)
>
>
> Another thing that could be helpful in debugging routes is to call URL()
> with specified arguments and see what it generates. That would have shown a
> problem with the fruit/salad router.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to remove items that a user owns when selecting rows from db?

2013-02-18 Thread bracquet
I mean if we have a list of products called:

Product 1
Product 2
Product 3
Product 4

And we have a list of registered buyers:

Buyer 1
Buyer 2
Buyer 3

And the sales contains which products a buyer has bought:

Buyer 1 Product 1
Buyer 2 Product 2 Product 3

What I'm trying to figure out is, when a buyer logs in (and therefore 
auth.user.id is set), how do I get the Rows for all products that the 
current buyer has not bought yet?

The result should be something like this for each buyer:

Buyer 1 should see Product 2, Product 3, Product 4.
Buyer 2 should see Product 1, Product 4.
Buyer 3 should see Product 1, Product 2, Product 3, Product 4.

I tried something like this:

rows = db((db.sale.product != 
db.product.id)&(db.sale.buyer==auth.user.id)).select()   # want to select 
all products that are not found in sale.product for this user.

But this returns 0 Rows.

On Friday, February 15, 2013 9:34:42 PM UTC-5, 黄祥 wrote:
>
> what do you mean by sales? is it in the session order or is it in the 
> table?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: web2py contains pyfpdf version 1.54b, but there is version 1.7 with utf-8 support

2013-02-18 Thread Mariano Reingart
Martin:

I've updated the web2py fpdf example addressing your issues (described bellow):

http://pyfpdf.googlecode.com/files/web2py.app.fpdf_20130218.w2p

(2) About unicode support, You need to pass unicode strings: u"my
unicode string" (look at the u prefix).
Also, you need embed a ttf unicode fonts (normal pdf fonts doesn't
include support beyond latin1, so there is an additional font pack in
downloads)
Please see:

https://code.google.com/p/pyfpdf/wiki/Unicode

Here is the example adapted for unicode

def get_me_a_unicode_pyfpdf():
title = "This The Doc Title"
heading = "First Paragraph"

# to use unicode, add the u"" (and ensure your source code and
text is in utf-8)
text = u"blä€ß " * 1

pdf=FPDF()

# load a true-type font that support unicode, like DejaVu:
# download and unzip
https://pyfpdf.googlecode.com/files/fpdf_unicode_font_pack.zip in the
private folder

pdf.add_font('DejaVu', '', os.path.join(request.folder, "private",
"font", 'DejaVuSans.ttf'), uni=True)
pdf.add_font('DejaVu', 'B', os.path.join(request.folder,
"private", "font", 'DejaVuSans-Bold.ttf'), uni=True)
pdf.add_page()
pdf.set_font('DejaVu','B',15)
pdf.cell(w=210,h=9,txt=title,border=0,ln=1,align='C',fill=0)
pdf.set_font('DejaVu','B',15)
pdf.cell(w=0,h=6,txt=heading,border=0,ln=1,align='L',fill=0)
pdf.set_font('DejaVu','',12)
pdf.multi_cell(w=0,h=5,txt=text)
response.headers['Content-Type']='application/pdf'
return pdf.output(dest='S')

(3) If you want the html view, please add

response.view = "generic.html"

Anyway, you need to get the pdf view:

http://localhost:8000/pyfpdf/default/report.pdf

(4) again, unicode... see (2)

(5) this will fail with newer versions of web2py as pdf
tutorial/samples are not included.
You'll need to grab a copy of logo_nb.png from the pypdf package and
change the line whereit uses the image:

logo=os.path.join(request.folder, "private","logo_pb.png")
self.image(logo,10,8,33)

(6) again, add a default view to see the html:

response.view = "generic.html"


(8) idem (5), you need to get the invoice.csv from the pypdf project site

(9) Maybe you are using a older version of web2py, I think Massimo
re-introduced .copy(), but you can take a workaround:

https://code.google.com/p/web2py/issues/detail?id=1255&can=1&q=fpdf

Just replace  element = element.copy() with  element = dict(element)
on template.py, or better, convert rows to dicts in your app:

# read elements from db
elements = 
db(db.pdf_element.pdf_template_id==1).select(orderby=db.pdf_element.priority)

# convert rows to dicts due a web2py internal change (see issue 1255)
# this prevents AttributeError('Row' object has no attribute 'copy')
elements = [element.as_dict() for element in elements]

PS: I'm not the creator of this library (it is a port of a well-known
PHP extension and similar libraries).
I'm just the continuator (maintainer), and there are some new
contributors too ;-)

Best regards,

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com


On Mon, Feb 18, 2013 at 2:51 AM, Martin Weissenboeck  wrote:
> ok, I'll do it.
>
>
> 2013/2/18 Massimo Di Pierro 
>>
>> Bring it up with Mariano, author of fpdf. ;-)
>>
>>
>> On Sunday, 17 February 2013 14:37:03 UTC-6, mweissen wrote:
>>>
>>> I have tried it now. These are my results:
>>>
>>> (1) A text like
>>>
>>> English: Hello World
>>> Greek: Γειά σου κόσμος
>>> Polish: Witaj świecie
>>> Portuguese: Olá mundo
>>> Russian: Здравствуй, Мир
>>> Vietnamese: Xin chào thế giới
>>> Arabic: مرحبا العالم
>>> Hebrew:  שלום עולם
>>>
>>> will be converted to pdf.
>>>
>>> (2) But there are problems with right-to-left scripts:
>>> שלום עולםis written as  םלוע םולש
>>> مرحبا العالم   is written as ملاعلا ابحرم
>>>
>>> (3) pdf.write_html seems to work only with latin-1
>>> pdf.write_html("äöü") is written as "äöü", but
>>> pdf.write_html("äöü".decode('utf-8').encode('latin-1') gives "äöü" - as
>>> expected.
>>>
>>> (4) pdf.write_html does not work with any "&...;" html-character
>>> pdf.write_html(">") gives "#62;"
>>>
>>>
>>> Maybe something should be improved...
>>> Regards, Martin
>>>
>>>
>>>
>>> 2013/2/17 Massimo Di Pierro 

 I just upgraded to the latest pfdf version (had to make a change for
 compatibility). Please check it.


 On Sunday, 17 February 2013 11:13:46 UTC-6, mweissen wrote:
>
> I want to use the utf-8 character set together with pyfpdf.
> On https://code.google.com/p/pyfpdf/wiki/Unicode there is pyfpdf
> version 1.7, which supports utf-8.
> But in web2py (2.3.2) in gluon\contrib\pyfpdf  fpdf.py is version 1.54b
>
> Is there any reason not to use pyfpdf 1.7 in web2py?
>
> Regards, Martin
>
>
>
 --

 ---
 You received this message because you are subscribed to the Google
 Groups "web

Re: [web2py] Re: How to get request.args from an index() function?

2013-02-18 Thread Jonathan Lundell
On 18 Feb 2013, at 8:38 AM, Niphlod  wrote:
> ! Missed that.
> 
> On Monday, February 18, 2013 5:23:55 PM UTC+1, Jonathan Lundell wrote:
> 
> You've listed salad as a function, but it's a controller. 
> 
> PS: Next thing to code is a small page where you load routes, a text input 
> where you can insert an http url, and a textarea with the resulting 
> Wsplitted" url (function, controller, args, vars, language, etc) (in & out). 
> @Jonathan: if it's technically possible and you don't have time, I'll put in 
> my todo-list (and enlist you as a consultant :-P) 

Another thing that could be helpful in debugging routes is to call URL() with 
specified arguments and see what it generates. That would have shown a problem 
with the fruit/salad router.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Fatal problem with date field, SQLite and DAL - german/czech date format

2013-02-18 Thread Niphlod
A custom translation is ok (I'm italian and use the italian date format, 
that is %d/%m/%Y), as long as respects the way web2py handles it (and as 
long as the widget you chose for date(time(s)) fields can cope with the 
"correct translation").

On Monday, February 18, 2013 5:37:20 PM UTC+1, Mirek Zvolský wrote:
>
> Yes. I think this can be my problem - custom translation of formats.
> I'm very sorry, that I was too fast with entering this user group.
> I will study more about it and I will give then message, if the problem is 
> in format definition or really inside web2py.
> Thanks, Mirek
>
>
>
> Dne pondělí, 18. února 2013 16:42:09 UTC+1 Niphlod napsal(a):
>>
>> as a general rule of thumb, in web2py date(time(s)) are stored always in 
>> "pseudo-iso" format (-MM-DD) and transformed to/from according to the 
>> date format specified into languages. Are you using custom translation 
>> files and/or a different date-time widget than the default one included in 
>> web2py ?
>>
>> On Monday, February 18, 2013 4:27:08 PM UTC+1, Mirek Zvolský wrote:
>>>
>>> Hi, 
>>> maybe this is DAL.py error? Or more as one - strange behavior for dates 
>>> in czech/german format - 'date' fields in tables cannot be used at all (!!)
>>>
>>> I have 'date' field in table 'akce' in SQLite database.
>>> I try a) after removing SQLite database I try run appadmin and browse 
>>> table 'akce' 
>>>b) after removing SQLite database I insert first record and 
>>> immediately I try select records using db().select(db.akce.ALL)
>>>c) same as b) but after replacing 'date' field in table 
>>> definition with 'datetime'
>>>
>>> 2.3.2 stable:
>>> a) http://localhost:8000/akce/appadmin/select/db?query=db.akce.id%3E0
>>> appadmin fails with error message (1)-bellow
>>> b) select fails with error message (2)-bellow
>>> c) no error, but no row as select result (instead of proper one)
>>>
>>> 2.4.1 trunk (alpha.2 + timestamp.2013.01.10.21.26.18):
>>> a) appadmin will not fail, however count of rows will not display (there 
>>> is 'rows' instead of '0 rows' - in czech language)
>>> b) select fails in same way as in 2.3.2 (message (2) )
>>> c) select works fine for 'datetime' fields
>>>
>>> I think at least in b) case, reason is german/czech date format, which 
>>> SQLite driver get from DAL.py.
>>> Because
>>>datetime.date(*map(int, val.split("-")))
>>> works well for dates like val='2013-02-19'.
>>> However sqlite3 driver will receive from DAL.py (func log_execute) the 
>>> date in local german/czech format like val='19.02.2013' and fails.
>>>
>>> So field type 'date' in tables cannot be used at all !
>>> Could this be repaired?
>>>
>>> Thanks, Mirek
>>>
>>>
>>>
>>> error (1) - I think this is fixed in trunk
>>>   File 
>>> "C:\Python27\Lib\site-packages\web2py\applications\akce\controllers/appadmin.py",
>>>  
>>> line 213, in select
>>> nrows = db(query).count()
>>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 8896, 
>>> in count
>>> return db._adapter.count(self.query,distinct)
>>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1652, 
>>> in count
>>> return self.cursor.fetchone()[0]
>>> TypeError: 'NoneType' object is not subscriptable
>>>
>>> error (2) - for 'date' fields, not fixed yet
>>>   File "C:\Python27\Lib\site-packages\web2py\gluon\restricted.py", line 
>>> 212, in restricted
>>> exec ccode in environment
>>>   File 
>>> "C:/Python27/Lib/site-packages/web2py/applications/akce/controllers/akce.py",
>>>  
>>> line 47, in 
>>>   File "C:\Python27\Lib\site-packages\web2py\gluon\globals.py", line 
>>> 193, in 
>>> self._caller = lambda f: f()
>>>   File 
>>> "C:/Python27/Lib/site-packages/web2py/applications/akce/controllers/akce.py",
>>>  
>>> line 7, in akce
>>> db.akce.ALL, orderby=db.akce.sraz_kdy)
>>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 9092, 
>>> in select
>>> return adapter.select(self.query,fields,attributes)
>>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 2178, 
>>> in select
>>> return super(SQLiteAdapter, self).select(query, fields, attributes)
>>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1637, 
>>> in select
>>> return self._select_aux(sql,fields,attributes)
>>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1602, 
>>> in _select_aux
>>> self.execute(sql)
>>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1715, 
>>> in execute
>>> return self.log_execute(*a, **b)
>>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1709, 
>>> in log_execute
>>> ret = self.cursor.execute(*a, **b)
>>>   File "C:\Python27\lib\sqlite3\dbapi2.py", line 63, in convert_date
>>> return datetime.date(*map(int, val.split("-")))
>>> ValueError: invalid literal for int() with base 10: '19.02.2013'
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To

Re: [web2py] Re: How to get request.args from an index() function?

2013-02-18 Thread Niphlod
! Missed that.

On Monday, February 18, 2013 5:23:55 PM UTC+1, Jonathan Lundell wrote:
>
>
> You've listed salad as a function, but it's a controller. 
>

PS: Next thing to code is a small page where you load routes, a text input 
where you can insert an http url, and a textarea with the resulting 
Wsplitted" url (function, controller, args, vars, language, etc) (in & 
out). 
@Jonathan: if it's technically possible and you don't have time, I'll put 
in my todo-list (and enlist you as a consultant :-P) 


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Fatal problem with date field, SQLite and DAL - german/czech date format

2013-02-18 Thread Mirek Zvolský
Yes. I think this can be my problem - custom translation of formats.
I'm very sorry, that I was too fast with entering this user group.
I will study more about it and I will give then message, if the problem is 
in format definition or really inside web2py.
Thanks, Mirek



Dne pondělí, 18. února 2013 16:42:09 UTC+1 Niphlod napsal(a):
>
> as a general rule of thumb, in web2py date(time(s)) are stored always in 
> "pseudo-iso" format (-MM-DD) and transformed to/from according to the 
> date format specified into languages. Are you using custom translation 
> files and/or a different date-time widget than the default one included in 
> web2py ?
>
> On Monday, February 18, 2013 4:27:08 PM UTC+1, Mirek Zvolský wrote:
>>
>> Hi, 
>> maybe this is DAL.py error? Or more as one - strange behavior for dates 
>> in czech/german format - 'date' fields in tables cannot be used at all (!!)
>>
>> I have 'date' field in table 'akce' in SQLite database.
>> I try a) after removing SQLite database I try run appadmin and browse 
>> table 'akce' 
>>b) after removing SQLite database I insert first record and 
>> immediately I try select records using db().select(db.akce.ALL)
>>c) same as b) but after replacing 'date' field in table definition 
>> with 'datetime'
>>
>> 2.3.2 stable:
>> a) http://localhost:8000/akce/appadmin/select/db?query=db.akce.id%3E0
>> appadmin fails with error message (1)-bellow
>> b) select fails with error message (2)-bellow
>> c) no error, but no row as select result (instead of proper one)
>>
>> 2.4.1 trunk (alpha.2 + timestamp.2013.01.10.21.26.18):
>> a) appadmin will not fail, however count of rows will not display (there 
>> is 'rows' instead of '0 rows' - in czech language)
>> b) select fails in same way as in 2.3.2 (message (2) )
>> c) select works fine for 'datetime' fields
>>
>> I think at least in b) case, reason is german/czech date format, which 
>> SQLite driver get from DAL.py.
>> Because
>>datetime.date(*map(int, val.split("-")))
>> works well for dates like val='2013-02-19'.
>> However sqlite3 driver will receive from DAL.py (func log_execute) the 
>> date in local german/czech format like val='19.02.2013' and fails.
>>
>> So field type 'date' in tables cannot be used at all !
>> Could this be repaired?
>>
>> Thanks, Mirek
>>
>>
>>
>> error (1) - I think this is fixed in trunk
>>   File 
>> "C:\Python27\Lib\site-packages\web2py\applications\akce\controllers/appadmin.py",
>>  
>> line 213, in select
>> nrows = db(query).count()
>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 8896, in 
>> count
>> return db._adapter.count(self.query,distinct)
>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1652, in 
>> count
>> return self.cursor.fetchone()[0]
>> TypeError: 'NoneType' object is not subscriptable
>>
>> error (2) - for 'date' fields, not fixed yet
>>   File "C:\Python27\Lib\site-packages\web2py\gluon\restricted.py", line 
>> 212, in restricted
>> exec ccode in environment
>>   File 
>> "C:/Python27/Lib/site-packages/web2py/applications/akce/controllers/akce.py",
>>  
>> line 47, in 
>>   File "C:\Python27\Lib\site-packages\web2py\gluon\globals.py", line 193, 
>> in 
>> self._caller = lambda f: f()
>>   File 
>> "C:/Python27/Lib/site-packages/web2py/applications/akce/controllers/akce.py",
>>  
>> line 7, in akce
>> db.akce.ALL, orderby=db.akce.sraz_kdy)
>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 9092, in 
>> select
>> return adapter.select(self.query,fields,attributes)
>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 2178, in 
>> select
>> return super(SQLiteAdapter, self).select(query, fields, attributes)
>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1637, in 
>> select
>> return self._select_aux(sql,fields,attributes)
>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1602, in 
>> _select_aux
>> self.execute(sql)
>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1715, in 
>> execute
>> return self.log_execute(*a, **b)
>>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1709, in 
>> log_execute
>> ret = self.cursor.execute(*a, **b)
>>   File "C:\Python27\lib\sqlite3\dbapi2.py", line 63, in convert_date
>> return datetime.date(*map(int, val.split("-")))
>> ValueError: invalid literal for int() with base 10: '19.02.2013'
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Querying values from two databases using Dal

2013-02-18 Thread Niphlod
DAL can't do cross database queries, unless you use executesql.

On Monday, February 18, 2013 5:27:38 PM UTC+1, Christian Espinoza wrote:
>
> Hi all, I'm need get the last alert(a table record) from db_alerts 
> database for every customer's truck,
> but I'm can't get it, I'm using MYSQL.
>
> Table trucks at db_base:
> db_app.define_table('trucks',
> Field('customer_id', db_app.customers),
> Field('lic', length=10),
> Field('cap', 'integer'),
> Field('vendor' db_app.vendor),
> format='%(lic)s'
> )
>
> Table alerts at db_alerts:
> db_alerts.define_table('alerts',
> Field('truck_lic', length=10),
> Field('name', length=20),
> Field('location', length=30),
> Field('description', length=100),
> Field('date', datetime)
> )
>
>
>  WORKING MYSQL QUERY:
>
> SELECT *
> FROM db_alerts.alerts, db_app.trucks
> WHERE db_app.trucks.customer_id = 1
> AND db_alerts.alerts.truck_lic = db_app.trucks.lic
> ORDER BY db_alerts.alerts.id DESC LIMIT 1
>
> Using Dal
>
> query = (db_app.trucks.customer_id ==1) & (db _app.
> trucks.lic == db_alerts.alerts.truck_lic)
>
>
>
> The second query is the problem, how can I run it??
>
> Thanks guys for your time and support.
> Greetings.
> Christian.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Querying values from two databases using Dal

2013-02-18 Thread Christian Espinoza
Hi all, I'm need get the last alert(a table record) from db_alerts database 
for every customer's truck,
but I'm can't get it, I'm using MYSQL.

Table trucks at db_base:
db_app.define_table('trucks',
Field('customer_id', db_app.customers),
Field('lic', length=10),
Field('cap', 'integer'),
Field('vendor' db_app.vendor),
format='%(lic)s'
)

Table alerts at db_alerts:
db_alerts.define_table('alerts',
Field('truck_lic', length=10),
Field('name', length=20),
Field('location', length=30),
Field('description', length=100),
Field('date', datetime)
)


 WORKING MYSQL QUERY:

SELECT *
FROM db_alerts.alerts, db_app.trucks
WHERE db_app.trucks.customer_id = 1
AND db_alerts.alerts.truck_lic = db_app.trucks.lic
ORDER BY db_alerts.alerts.id DESC LIMIT 1

Using Dal

query = (db_app.trucks.customer_id ==1) & (db _app.
trucks.lic == db_alerts.alerts.truck_lic)



The second query is the problem, how can I run it??

Thanks guys for your time and support.
Greetings.
Christian.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: How to get request.args from an index() function?

2013-02-18 Thread Jonathan Lundell
On 18 Feb 2013, at 8:09 AM, Alec Taylor  wrote:
> 
> I have created a tiny test-case which proves that I can't properly
> acquire request.args: https://gist.github.com/anonymous/4978457
> 
> What am I doing wrong; how am I supposed to acquire request.args?
> 
> (I want URL per uid of record)

You've listed salad as a function, but it's a controller.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: How to get request.args from an index() function?

2013-02-18 Thread Alec Taylor
I have created a tiny test-case which proves that I can't properly
acquire request.args: https://gist.github.com/anonymous/4978457

What am I doing wrong; how am I supposed to acquire request.args?

(I want URL per uid of record)

On Tue, Feb 19, 2013 at 12:48 AM, Niphlod  wrote:
> did you try turning debug on for routes ?
> Can you confirm that curl hits the function you're printing args into ?
> (i.e. it doesn't call /fruit/index/salad/foo)
>
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Fatal problem with date field, SQLite and DAL - german/czech date format

2013-02-18 Thread Niphlod
as a general rule of thumb, in web2py date(time(s)) are stored always in 
"pseudo-iso" format (-MM-DD) and transformed to/from according to the 
date format specified into languages. Are you using custom translation 
files and/or a different date-time widget than the default one included in 
web2py ?

On Monday, February 18, 2013 4:27:08 PM UTC+1, Mirek Zvolský wrote:
>
> Hi, 
> maybe this is DAL.py error? Or more as one - strange behavior for dates in 
> czech/german format - 'date' fields in tables cannot be used at all (!!)
>
> I have 'date' field in table 'akce' in SQLite database.
> I try a) after removing SQLite database I try run appadmin and browse 
> table 'akce' 
>b) after removing SQLite database I insert first record and 
> immediately I try select records using db().select(db.akce.ALL)
>c) same as b) but after replacing 'date' field in table definition 
> with 'datetime'
>
> 2.3.2 stable:
> a) http://localhost:8000/akce/appadmin/select/db?query=db.akce.id%3E0
> appadmin fails with error message (1)-bellow
> b) select fails with error message (2)-bellow
> c) no error, but no row as select result (instead of proper one)
>
> 2.4.1 trunk (alpha.2 + timestamp.2013.01.10.21.26.18):
> a) appadmin will not fail, however count of rows will not display (there 
> is 'rows' instead of '0 rows' - in czech language)
> b) select fails in same way as in 2.3.2 (message (2) )
> c) select works fine for 'datetime' fields
>
> I think at least in b) case, reason is german/czech date format, which 
> SQLite driver get from DAL.py.
> Because
>datetime.date(*map(int, val.split("-")))
> works well for dates like val='2013-02-19'.
> However sqlite3 driver will receive from DAL.py (func log_execute) the 
> date in local german/czech format like val='19.02.2013' and fails.
>
> So field type 'date' in tables cannot be used at all !
> Could this be repaired?
>
> Thanks, Mirek
>
>
>
> error (1) - I think this is fixed in trunk
>   File 
> "C:\Python27\Lib\site-packages\web2py\applications\akce\controllers/appadmin.py",
>  
> line 213, in select
> nrows = db(query).count()
>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 8896, in 
> count
> return db._adapter.count(self.query,distinct)
>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1652, in 
> count
> return self.cursor.fetchone()[0]
> TypeError: 'NoneType' object is not subscriptable
>
> error (2) - for 'date' fields, not fixed yet
>   File "C:\Python27\Lib\site-packages\web2py\gluon\restricted.py", line 
> 212, in restricted
> exec ccode in environment
>   File 
> "C:/Python27/Lib/site-packages/web2py/applications/akce/controllers/akce.py", 
> line 47, in 
>   File "C:\Python27\Lib\site-packages\web2py\gluon\globals.py", line 193, 
> in 
> self._caller = lambda f: f()
>   File 
> "C:/Python27/Lib/site-packages/web2py/applications/akce/controllers/akce.py", 
> line 7, in akce
> db.akce.ALL, orderby=db.akce.sraz_kdy)
>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 9092, in 
> select
> return adapter.select(self.query,fields,attributes)
>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 2178, in 
> select
> return super(SQLiteAdapter, self).select(query, fields, attributes)
>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1637, in 
> select
> return self._select_aux(sql,fields,attributes)
>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1602, in 
> _select_aux
> self.execute(sql)
>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1715, in 
> execute
> return self.log_execute(*a, **b)
>   File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1709, in 
> log_execute
> ret = self.cursor.execute(*a, **b)
>   File "C:\Python27\lib\sqlite3\dbapi2.py", line 63, in convert_date
> return datetime.date(*map(int, val.split("-")))
> ValueError: invalid literal for int() with base 10: '19.02.2013'
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Graph Model (proposal to contribute)

2013-02-18 Thread António Ramos
D3js pure javascript on client!

see this example of meteorjs using d3js

http://meteor.com/examples/parties

That is something...



2013/2/18 Niphlod 

> the only issue with the current implementation in trunk is that on Windows
> it's almost impossible to get it going, due to the requirements.
>
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Fatal problem with date field, SQLite and DAL - german/czech date format

2013-02-18 Thread Mirek Zvolský
Hi, 
maybe this is DAL.py error? Or more as one - strange behavior for dates in 
czech/german format - 'date' fields in tables cannot be used at all (!!)

I have 'date' field in table 'akce' in SQLite database.
I try a) after removing SQLite database I try run appadmin and browse table 
'akce' 
   b) after removing SQLite database I insert first record and 
immediately I try select records using db().select(db.akce.ALL)
   c) same as b) but after replacing 'date' field in table definition 
with 'datetime'

2.3.2 stable:
a) http://localhost:8000/akce/appadmin/select/db?query=db.akce.id%3E0
appadmin fails with error message (1)-bellow
b) select fails with error message (2)-bellow
c) no error, but no row as select result (instead of proper one)

2.4.1 trunk (alpha.2 + timestamp.2013.01.10.21.26.18):
a) appadmin will not fail, however count of rows will not display (there is 
'rows' instead of '0 rows' - in czech language)
b) select fails in same way as in 2.3.2 (message (2) )
c) select works fine for 'datetime' fields

I think at least in b) case, reason is german/czech date format, which 
SQLite driver get from DAL.py.
Because
   datetime.date(*map(int, val.split("-")))
works well for dates like val='2013-02-19'.
However sqlite3 driver will receive from DAL.py (func log_execute) the date 
in local german/czech format like val='19.02.2013' and fails.

So field type 'date' in tables cannot be used at all !
Could this be repaired?

Thanks, Mirek



error (1) - I think this is fixed in trunk
  File 
"C:\Python27\Lib\site-packages\web2py\applications\akce\controllers/appadmin.py",
 
line 213, in select
nrows = db(query).count()
  File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 8896, in 
count
return db._adapter.count(self.query,distinct)
  File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1652, in 
count
return self.cursor.fetchone()[0]
TypeError: 'NoneType' object is not subscriptable

error (2) - for 'date' fields, not fixed yet
  File "C:\Python27\Lib\site-packages\web2py\gluon\restricted.py", line 
212, in restricted
exec ccode in environment
  File 
"C:/Python27/Lib/site-packages/web2py/applications/akce/controllers/akce.py", 
line 47, in 
  File "C:\Python27\Lib\site-packages\web2py\gluon\globals.py", line 193, 
in 
self._caller = lambda f: f()
  File 
"C:/Python27/Lib/site-packages/web2py/applications/akce/controllers/akce.py", 
line 7, in akce
db.akce.ALL, orderby=db.akce.sraz_kdy)
  File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 9092, in 
select
return adapter.select(self.query,fields,attributes)
  File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 2178, in 
select
return super(SQLiteAdapter, self).select(query, fields, attributes)
  File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1637, in 
select
return self._select_aux(sql,fields,attributes)
  File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1602, in 
_select_aux
self.execute(sql)
  File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1715, in 
execute
return self.log_execute(*a, **b)
  File "C:\Python27\Lib\site-packages\web2py\gluon\dal.py", line 1709, in 
log_execute
ret = self.cursor.execute(*a, **b)
  File "C:\Python27\lib\sqlite3\dbapi2.py", line 63, in convert_date
return datetime.date(*map(int, val.split("-")))
ValueError: invalid literal for int() with base 10: '19.02.2013'

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Graph Model (proposal to contribute)

2013-02-18 Thread Niphlod
the only issue with the current implementation in trunk is that on Windows 
it's almost impossible to get it going, due to the requirements.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Setting up memcache on GAE - a basic question

2013-02-18 Thread Niphlod
cacheable=True does not help ?

On Monday, February 18, 2013 4:11:13 PM UTC+1, howesc wrote:
>
> ah yes
>
> the Rows() object returned from a select is not pickable.
>
> i do this a lot:
>
> students = cache.ram('students',
> lambda:db(db.student.id>0).select(db.student.id, 
> db.student.family_name,
> ...
> db.student.student_age).to_dict(),
> 3600)
>
>
> On Sunday, February 17, 2013 10:09:18 PM UTC-8, Andy W wrote:
>>
>> Thanks for the feedback Christian.
>>
>> It seems to be this that causes the problem on GAE but works on sqlite:
>>
>> students = cache.ram('students',
>> lambda:db(db.student.id>0).select(db.student.id, 
>> db.student.family_name,
>> ...
>> db.student.student_age),
>> 3600)
>>
>> Any ideas?
>>
>> Thanks,
>> Andy
>>
>>>


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Setting up memcache on GAE - a basic question

2013-02-18 Thread howesc
ah yes

the Rows() object returned from a select is not pickable.

i do this a lot:

students = cache.ram('students',
lambda:db(db.student.id>0).select(db.student.id, 
db.student.family_name,
...
db.student.student_age).to_dict(),
3600)


On Sunday, February 17, 2013 10:09:18 PM UTC-8, Andy W wrote:
>
> Thanks for the feedback Christian.
>
> It seems to be this that causes the problem on GAE but works on sqlite:
>
> students = cache.ram('students',
> lambda:db(db.student.id>0).select(db.student.id, 
> db.student.family_name,
> ...
> db.student.student_age),
> 3600)
>
> Any ideas?
>
> Thanks,
> Andy
>
>>
>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Removing HTML TAGS

2013-02-18 Thread Bruno Rocha
http://stackoverflow.com/questions/9662346/python-code-to-remove-html-tags-from-a-string

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Removing HTML TAGS

2013-02-18 Thread Kenneth
Hello,

def parser():

from gluon.html import web2pyHTMLParser
from gluon.sanitizer import sanitize

folder = os.path.join(request.folder,'static')
file = os.path.join(folder,'MYY.03.02.5.1.asp')
source = open(file)
html = source.read()


tree=web2pyHTMLParser(html).tree

elements=tree.elements(_class="BODYCONTENT")[1]

return XML(TAG(elements[9]))

if I try it like that I get a ticket: 

AttributeError: '__tag__' object has no attribute 'decode'

if I put only:
   return XML(elements[9])

I get the text I want but with a couple of HTML tags that I'd wasning on using 
TAG to remove them.

Tässä artikkelissa käydään läpi tulevaisuuden 
sosiologisia trendejä. Os...sista.


I'd like to the ridden of div claas and a name

Any ideas?


Kenneth

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Graph Model (proposal to contribute)

2013-02-18 Thread pablo . angulo



Thanks a ton, Jose, I did a much more modest attempt at the same thing:

print 'digraph Bloques{\n' \
  'ranksep="2"\n' \
  'splines="true"\n'
for table in db:
for field in table:
if field.type.startswith('reference'):
t = '%s -> %s'%(table, field.type[10:])
type = field.type[10:]
elif field.type.startswith('list:reference'):
t = '%s -> %s [arrowhead="veevee" ]'%(table, field.type[15:])
else: continue
if field.name!=type:
 t += '[ label = "%s" ]'%field.name
print t
print '}'


This generates a diagram with only the references between the tables, 
labeling the arrows if the field name is different from the target table.
Calling 

dot -Tpng db.dot -o db_picture.png

gives a file like in the example above.

BTW; have you considered using canviz?:

 http://code.google.com/p/canviz/
I'm not sure it does what Massimo wants, because it might need the 
coordinates of the points, that are obtained with a call to 'dot'.

Regards

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] User Management Backoffice

2013-02-18 Thread Bruno Rocha
You can customize the web2admin


https://github.com/rif/web2admin

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: How to get request.args from an index() function?

2013-02-18 Thread Niphlod
did you try turning debug on for routes ? 
Can you confirm that curl hits the function you're printing args into ? 
(i.e. it doesn't call /fruit/index/salad/foo)

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: String interpreted as html code

2013-02-18 Thread Andriy
Use XML() helper - http://web2py.com/books/default/chapter/29/05#XML

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] String interpreted as html code

2013-02-18 Thread BlueShadow
Hi,
I got a string containing some html code and I want that to be interpreted 
as html. but when i do the simple{{=string}} i get that html printed as if 
it were text. there has to be a very simple way to do that.
thanks

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: How to get request.args from an index() function?

2013-02-18 Thread Alec Taylor
routers = dict(
   BASE = dict(
   default_application = 'fruit',
   applications = ['fruit', 'admin'],
   default_controller = 'default',
   controllers = 'DEFAULT',
   default_function = 'index',
   ),
   fruit = dict(
default_function = 'index',
functions =  ['index','user','download','call', 'data',
'error','profile','salad']
   )
)

On Mon, Feb 18, 2013 at 7:17 PM, Niphlod  wrote:
> of course this can't be possible, the entire framework will implode without
> a proper request routing: have you some custom routing in place ?
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] widget: unexpected error

2013-02-18 Thread leone
Hi all!

I built a widget that scans the local server file system.
I attach the code of the widget.
The content of form.vars and request.vars when the form is submitted is 
inexplicable for me:

form = SQLFORM.factory(
Field('tree2','string', 
widget=WDG.field_treeview(startpath=startpath, selectmode='A')),
)
*if form.process(keepvalues=True).accepted:*
*   p*rint "0>>>", form.vars, request.vars

Ispecting html form code, the only input tag is this:



This is the unexpected output:

 

web2py 2.3.2
python 2.7
linux mint 14

I don't understand. Can anyone help me?
thanks in advance

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.






#---TREEVIEW

class field_treeview:
def __init__(self, startpath='', width=500, static=True, showmode='A', selectmode='A'):
self.startpath = startpath
self.width = width
self.static = static
self.showmode = showmode
self.selectmode = selectmode

def __call__(self, field, value=''):
_id = "%s_%s" % (field._tablename, field.name)
_name = field.name
#altrimenti accepts restituisce errori
if not field.default:
field.default=''
html = treeview_input(name=_name, value=value, id=_id,
startpath=self.startpath,
showmode=self.showmode,
selectmode=self.selectmode,
width=self.width,
border=False,
static=self.static)
return html


def treeview_input(name, value='', id='', startpath='', showmode='A', selectmode='A', width=400, border=False, static=False):
if not id:
id = name
_name = name
_id_tree = "%s_tree" % _name
id_divimp = id + '_divimp'
id_divtree = id + '_divtree'

_value = value or ''
winp = "" % dict(id=id, name=_name, value=_value, width=width)
wbtn = """
Explore""" % dict(name=_name)
def action(itemtype, itemname, fullpath):
cmd = ''
jscmd = "$('#%(id)s').val('%(fullpath)s'); %(name)s_show(); return false;""" % dict(id=id, fullpath=fullpath, name=_name)
if selectmode == 'A':
cmd = jscmd
if itemtype == selectmode:
cmd = jscmd
return cmd
wtree = _treeview(id=_id_tree, startpath=startpath, jsaction=action, showmode=showmode, width=width, border=True, static=static)
width += 100
out = []

js = """

function %(name)s_hide() {
$('#%(id_divimp)s').hide();
$('#%(id_divtree)s').show();
}
function %(name)s_show() {
$('#%(id_divimp)s').show();
$('#%(id_divtree)s').hide();
}

""" % dict(name=_name, id_divimp=id_divimp, id_divtree=id_divtree)
out.append("" % id_divimp)
out.append(winp)
out.append(" ")
out.append(wbtn)
out.append("")
out.append("" % ( id_divtree, str(width)) )
out.append(wtree)
out.append("")
out.append(js)
html = '\n'.join(out)
return XML(html)


def treeview(id='', startpath='', showmode='A', selectmode='A', width=400, jsaction=None, border=False, static=False):
html = _treeview(id, startpath, showmode, selectmode, width, jsaction, border, static)
return XML(html)


def _treeview(id='', startpath='', showmode='A', selectmode='A', width=400, jsaction=None, border=False, static=False):
""" action e' una funzione che ritorna una stringa javascript
da eseguire al click
def action(itemtype, itemname, fullpath)
"""
response = current.response

response.files.append(URL(c='static/WDG/jquery.treeview',f='jquery.treeview.js'))
response.files.append(URL(c='static/WDG/jquery.treeview',f='jquery.treeview.css'))
if not startpath:
startpath = os.getcwd()
fullpath = os.path.abspath(startpath)
out = []
strid = ''
if id:
strid = """ id="%s" """ % id
style = ''
if border:
style += """ border:1px solid #BFBFBF; background-color:#EFEFEF;padding:25px;margin-bottom:10px;"""
out.append( "" % dict(strid=strid, style=style))
out.append("" % dict(id=id))
item = 0
deep = 0
lstul, deep, item = _walk(fullpath, fullpath, showmode, deep, item, jsaction, static)
out = out + lstul
out.append( "")
out.append( "")
out.append( """$(document).ready(function(){$("#%(id)s").treeview({collapsed: true,});})""" % dict(id=id))
html = '\n'.join(out)
return html


def _walk(startpath, value, showmode, deep, item, jsaction, static):
out = []
  

[web2py] User Management Backoffice

2013-02-18 Thread Leonel Câmara
I finally need a backoffice where I allow the site owner to moderate the 
users. Before I start doing it I'd like to know if you guys have any tips, 
best practices or lists of things that I cannot forget as I'm certain this 
road has been traveled before.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: web2py auth question

2013-02-18 Thread Leonel Câmara
You can use LOAD to put the login form on the homepage. It's also possible 
to do it in a completely ajaxified way, I did it using login_bare.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: MySQL, self-reference, and null values

2013-02-18 Thread Loïc
Done
http://code.google.com/p/web2py/issues/detail?id=1342
Thanks

Le lundi 11 février 2013 00:40:59 UTC+1, Massimo Di Pierro a écrit :
>
> Can you please open a ticket so the issue is tracked?
>
> On Friday, 1 February 2013 09:20:54 UTC-6, Loïc wrote:
>>
>> Dear All,
>>
>> I have a 'page' model with a sef-reference: 
>> db.define_table('page',
>> Field('parent', 'reference page', readable=False, writable=False),
>> Field('title', unique=True, notnull=True)
>> //more fields not important here
>> )
>>
>> When I insert a new page via appadmin without specifying a 'parent', 
>> everything is OK with sqlite
>>
>> Since I moved my database to mysql, I have an error : 
>>  (1452, 'Cannot add or update a 
>> child row: a foreign key constraint fails (`dommartin25`.`page`, CONSTRAINT 
>> `page_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `page` (`id`) ON DELETE 
>> CASCADE)')
>> How can I allow null values for the 'parent' field?
>>
>> Thank you
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Unable to send email - password reset.

2013-02-18 Thread Andrew Buchan
Indeed it is subtle, perhaps it should make it clearer that it assumes TLS 
by default whereas previous versions didn't.

As for the debug statements I was just looking for a way to get this from 
my live app, on occasions when I need to monitor live use. I guess I can 
always switch off the service and run the live in the way described above 
for a period of time.

Thanks for the input guys.

---

On Friday, February 15, 2013 12:20:39 AM UTC, Tim Richardson wrote:
>
> Some time ago I ran into exactly the same problem and came to the solution 
> exactly the same way (on Windows). 
> The book now includes this setting but perhaps it is too subtle (search 
> TLS). 
>
> There are a lot of advantages to running debug/development sessions using 
> an interactive web2py server started from the command prompt (on a 
> different port), and one of them is easier access to console messages. 
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: web2py apache2 setup with htaccess authorization

2013-02-18 Thread Chr_M
Ah, thanks for the link and the example. I see some clues there.

Regards, Chris

On Monday, February 18, 2013 12:40:34 AM UTC+1, Massimo Di Pierro wrote:
>
> Perhaps this can help?
> http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives
>
> Anyway you can mimic it with web2py. In a model add:
>
> if not session.authorized:
>  if request.post_vars.password == '123456': session.authorized = True
>  else: raise 
> HTTP(200,HTML(BODY(FORM('Password:',INPUT(_name='password'),INPUT(_type='submit'.xml())
>
>
>
> On Sunday, 17 February 2013 13:22:20 UTC-6, Chr_M wrote:
>>
>> I understand it is a primitive system, but also a quick way to put a 
>> website behind a login. I do not want to integrate an authentication 
>> system, because it is only for some betatesters before the website goes 
>> live.
>>
>> On Sunday, February 17, 2013 4:25:16 PM UTC+1, Massimo Di Pierro wrote:
>>>
>>> Why do you want to use htaccess instead of web2py own authentication. 
>>> htaccess is such a primitive system. 
>>>
>>>
>>> On Sunday, 17 February 2013 06:26:09 UTC-6, Chr_M wrote:

 I come from a PHP background and when I wanted to have a website (or a 
 part) behind a login screen (for example for beta testing) I could do that 
 with a htaccess and htpasswd file (with Apache2). I have deployed a web2py 
 website with Apache2, but I can not figure out how to have this website 
 behind an Apache2 login. Is that possible with a web2py with Apache2 setup 
 with a htaccess file? Or is there an alternative way to do in with web2py?

 Thanks in advance.

 Regards, Chris

>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: How do I define a table that references itself

2013-02-18 Thread Paul Whipp
Yes it can - the table I'm trying to create is perfectly valid and sensible
(and it works fine if implemented directly in postgres or mysql). I'm just
having trouble representing it effectively with the DAL.

On 18 February 2013 18:54, pbreit  wrote:

> Can a reference be optional?
>
>
> On Monday, February 18, 2013 12:19:04 AM UTC-8, Paul Whipp wrote:
>>
>> Here is an example of what I need to do:
>>
>> db.define_table('Docket',
>> Field('Docket_No', 'integer',
>> required = True),
>> Field('Reference_Docket_ID', 'reference Docket',
>> required = False),
>> Field('Reference_Docket_No', 'integer',
>> required = False),
>> ...
>>
>> The docket optionally refers to a preceding docket in the model. It
>> appears that web2py's DAL ignores the required = False specification for
>> this field because when I use the SQLFORM it tells me that 'Reference
>> Docket_ID' is a required field so its impossible to enter any docket
>> records.
>>
>> The client database is postgresSQL
>>
>> I tried adding the field constraints (e.g. db.Docket.Docket_No.requires = 
>> IS_NULL_OR(IS_IN_DB(...)))
>> but then it fails to display the dropdown when the form is presented.
>>
>> With hundreds of tables, I don't want to have to craft the form by hand.
>>
>> I'm also wondering what happens when there are many thousands of dockets
>> - will the dropdown for the Reference_Docket_ID on the form cope
>> effectively?
>>
>> Cheers,
>> Paul
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How do I define a table that references itself

2013-02-18 Thread pbreit
Can a reference be optional?

On Monday, February 18, 2013 12:19:04 AM UTC-8, Paul Whipp wrote:
>
> Here is an example of what I need to do:
>
> db.define_table('Docket',
> Field('Docket_No', 'integer',
> required = True),
> Field('Reference_Docket_ID', 'reference Docket',
> required = False),
> Field('Reference_Docket_No', 'integer',
> required = False),
> ...
>
> The docket optionally refers to a preceding docket in the model. It 
> appears that web2py's DAL ignores the required = False specification for 
> this field because when I use the SQLFORM it tells me that 'Reference 
> Docket_ID' is a required field so its impossible to enter any docket 
> records.
>
> The client database is postgresSQL
>
> I tried adding the field constraints (e.g. db.Docket.Docket_No.requires = 
> IS_NULL_OR(IS_IN_DB(...))) 
> but then it fails to display the dropdown when the form is presented.
>
> With hundreds of tables, I don't want to have to craft the form by hand.
>
> I'm also wondering what happens when there are many thousands of dockets - 
> will the dropdown for the Reference_Docket_ID on the form cope effectively?
>
> Cheers,
> Paul
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] How do I define a table that references itself

2013-02-18 Thread Paul Whipp
Here is an example of what I need to do:

db.define_table('Docket',
Field('Docket_No', 'integer',
required = True),
Field('Reference_Docket_ID', 'reference Docket',
required = False),
Field('Reference_Docket_No', 'integer',
required = False),
...

The docket optionally refers to a preceding docket in the model. It appears 
that web2py's DAL ignores the required = False specification for this field 
because when I use the SQLFORM it tells me that 'Reference Docket_ID' is a 
required field so its impossible to enter any docket records.

The client database is postgresSQL

I tried adding the field constraints (e.g. db.Docket.Docket_No.requires = 
IS_NULL_OR(IS_IN_DB(...))) 
but then it fails to display the dropdown when the form is presented.

With hundreds of tables, I don't want to have to craft the form by hand.

I'm also wondering what happens when there are many thousands of dockets - 
will the dropdown for the Reference_Docket_ID on the form cope effectively?

Cheers,
Paul

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to get request.args from an index() function?

2013-02-18 Thread Niphlod
of course this can't be possible, the entire framework will implode without 
a proper request routing: have you some custom routing in place ? 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: login by ajax

2013-02-18 Thread Paolo valleri
+1 for auth,ajax_login()

paolo

On Monday, February 18, 2013 4:50:20 AM UTC+1, Massimo Di Pierro wrote:
>
> Should we offer something like {{=auth.ajax_login()}} helper which submits 
> to /user/login? If would not be difficult to write. 
> How should it work?
>
>
>
>
> On Sunday, 17 February 2013 21:37:59 UTC-6, Anthony wrote:
>>
>> def login():
>>
>> form=auth.login()
>>> if form.accepts(request,session=None):
>>>
>>
>> auth.login() already handles form processing, so you should not call 
>> form.accepts(), as that will not work.
>>  
>>
>>>   
>>> 
>>> 
>>> Email
>>> 
>>> Password
>>> >> placeholder="*">
>>> Submit
>>> 
>>> 
>>>
>>
>> web2py SQLFORM's (including the auth forms) include hidden _formname and 
>> _formkey fields -- if you're creating a custom form, you need to include 
>> those, or the form will not pass validation when submitted. If you want to 
>> create a custom form based on a SQLFORM, you should follow 
>> http://web2py.com/books/default/chapter/29/07#Custom-forms.
>>
>> Also, rather than manually submitting the form via Ajax, you might 
>> consider putting the login form in an Ajax component (or even a non-Ajax 
>> component with ajax_trap set to True). In that case, web2py.js will handle 
>> the Ajax submission for you. In that case, you may want to create a 
>> login_onaccept function to avoid the usual post-login redirect (which 
>> wouldn't be useful for an Ajax login).
>>
>> Anthony
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.