[web2py] Re: dataTables with serverside json

2012-02-10 Thread Vineet
Richard,
Here is my minimal code for returning json data in dataTables via
web2py's ajax function.

---View---



  
ABC Category Name
Code
  






// this I keep in js folder

function dtbl_show(hash_div, sAjaxSource, aoColumns) {

$(document).ready(function() {

$(hash_div).dataTable( {

"bJQueryUI": true,

"bDeferRender": true,

"bPaginate": true,

'sPaginationType': 'full_numbers',

"bProcessing": true,

"bServerSide": true,

"aaSorting": [[ 1, "desc" ]],

"bAutoWidth": false,

"aoColumns" : aoColumns,

"sAjaxSource": sAjaxSource

} );

 } );

jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPages = 10;


}



// call here this script & pass the table's div for rendering it

dtbl_show("#abc_table", "{{=URL('abc','get_abcdata')}}", [{ sWidth:
'350px' }, { sWidth: '200px' }] )


--- End View ---

--- Controller for populating data via ajax ---
(excuse the bugged-up indentation here)

def get_abcdata():
  if request_vars_iDisplayStart != None:

iDisplayStart = request_vars_iDisplayStart

  else:

iDisplayStart = 0



  if request_vars_iDisplayLength != None:

iDisplayLength = request_vars_iDisplayLength

  else:

iDisplayLength = 10



  if request_vars_sEcho != None:

   sEcho = int(request_vars_sEcho)

  else:

   sEcho = 1


  qry = 'your sql query string'


### Below this, I am using a 3rd party library viz. DABO for
interacting with DB.
### You may substitute that syntax with the DB layer of your choice
(DAL or whatever else) and get dataset.

try:

conn_name = connInstance.makeConn()

cur = conn_name.cursor()

qry = qry1 + ' limit ' + str(iDisplayStart) + ', ' +
str(iDisplayLength) + ';'

# fetch total data

cur.execute(qry1)

data_full = cur.getDataSet()

iTotalRecords = len(data_full)

# fetch data as requested from client

cur.execute(qry)

data_disp = cur.getDataSet()

iTotalDisplayRecords = len(data_full)

finally:

conn_name.close()


aaData = []
# Now populate the aaData with data in form of lists.
# e.g. aaDada will look like -- [[1, 'Vineet'],[2,'Richard']]
# This formatting is important

   D=dict(sEcho=sEcho, iTotalRecords=iTotalRecords,
iTotalDisplayRecords=iTotalDisplayRecords,
iDisplayLength=iDisplayLength, aaData=aaData)
   return response.json(D)

-- End of Controller code --

That's wraps it up.
If you need any further drilling down in my code, pl. ask.
I will be happy to share.

HTH,
--- Vineet

On Feb 8, 10:18 pm, Richard Vézina 
wrote:
> Yes!
>
> I think the PowerTable of Burno don't implement server side processing
> yet... We maybe can start form there to make a server side implementation
> of PowerTable... What do you think?
>
> I think, we have to split table header from data then wrote a python
> implementation fo the php script as shown in the example of DTs...
>
> For sure see a bit of your code could help me figure out the path I should
> follow and help my reflexion.
>
> About "fnInitComplete" it is just needed in case you want to initialise DTs
> with fixed columns...
>
> Richard
>
> On Wed, Feb 8, 2012 at 11:52 AM, Vineet  wrote:
> > Hi Richard !
> > Pl. excuse my late replying.
> > Glad to hear that you got it working.
>
> > If you are interested, I can share my code.
> > I am not using "fnInitComplete".
> > Mine is very simple & minimal code.
>
> > --- Vineet
>
> > On Feb 7, 10:19 pm, Richard Vézina 
> > wrote:
> > > Finally got it to work...
>
> > > There was a problem with the init of DTs particularly this option :
>
> > >http://datatables.net/release-datatables/extras/FixedColumns/server-s...
>
> > > *fnInitComplete*
> > > *
> > > *
> > > *
> > > *
> > > It's not solving my speed problem as I expect it could do... So I will
> > put
> > > it on hold, but I plan to implement a basic server interaction script as
> > > the php DTs example to make it easier deploy DTs with server side
> > > capability...
>
> > > Richard
>
> > > On Mon, Feb 6, 2012 at 6:10 PM, Bruno Rocha 
> > wrote:
> > > > Not,
>
> > > > PowerGrid is based in pure Jquery Templates
>
> > > > --
>
> > > > Bruno Rocha
> > > > [http://rochacbruno.com.br]
>
>


Re: [web2py] uwsgi configuration: why many lines in /root/var/log/uwsgi-python/web2py log : routing 0 routes 0 ?

2012-02-10 Thread Roberto De Ioris

> strange, really :D
>
> I don't mind if that turns out in the logging, but I have the same
> behaviour
>
> niphlod@platypus:~$ uwsgi-python --version
> uWSGI 0.9.6.8
>
> I use uwsgi-python in production /usr/bin/uwsgi-python . If I recall
> correctly that is a symbolic link to `/etc/alternatives/uwsgi-python', and
> that one is afile  symbolic link to `/usr/bin/uwsgi-python2.6'
> I then have a /usr/bin/uwsgi that is the result of pip-installing uwsgi
> package: actually I'm experimenting on dropping the uwsgi-python package
> (some real mess to understand clearly, at least for me, especially with
> its
> /etc/init.d scripts) . With the emperor mode it's really easier to manage
> apps Maybe some "shared libraries" between versions ?
>
>

The original uwsgi debian packages started when the emperor was still a
prototype. The author (Leonid Borisenko) did his best to simulate what the
Emperor is today simply using init script and various form of
configuration inheritance. For me, Emperor is the simplest (and versatile)
way to go, as it relies on config files only: you create one to start a
new instance, you remove it to remove an instance, you touch it to reload
an instance. No script, nor funny permission issues (you can choose the
directory in which config files are looked up).

In addition to this, 0.9.6 is near to end-of-maintainance (june 2012), so
upgrading to 1.x would be in general a better choice.


-- 
Roberto De Ioris
http://unbit.it


[web2py] Re: Significant overhead with each define_table()

2012-02-10 Thread James M.
I have a significantly more performant solution that I am trying.  I
moved my db.define_table() out of models folder and into a class
defined in modules.  The class has properties for each table.  The
properties(tables) are lazy loaded as needed.  The way I implemented
it, the dal syntax is almost identical when doing selects/inserts/
updates.
Here is a gist https://gist.github.com/1796274
now most of my pages test at 60-100 Requests/Second instead of ~25
Requests/Second.


On Jan 7, 7:44 pm, "James M."  wrote:
> I just did some simple load tests on a web app I am working on.  I was
> using apache bench (ab -n 1000 -c 100) and getting results that were
> much slower than expected.  The Requests/Second were ~ 26.  For
> comparison I did the same test against the welcome app and I was
> getting ~ 59 Requests/Second (with no optimizations).
> I started testing various scenarios to determine what was causing the
> big discrepancy.  I tried all the suggested tips for improving
> performance (migrate=False, compile app, cache, session.forget() etc),
> with very small improvements...
>
> I was curious what kind ofoverheadadding tables to the welcome app
> would have.  To get a good starting point I decided to optimize the
> page I was testing in the web app as follows:
>
> #default.py
> @cache(request.env.path_info, time_expire=60, cache_model=cache.ram)
> def index():
>     session.forget(response)
>     return response.render(dict())
>
> After this change I was getting 93 Requests/Second
>
> I added the following table:
>
> db.define_table('table1',
>         Field('col1','string'),
>         Field('col2','string'),
>         Field('col3','string'),
>         Field('col4','string'),
>         Field('col5','string'),
>         Field('col6','string'),
>         Field('col7','string'),
>         Field('col8','string'),
>         Field('col9','string'),
>         Field('col10','string')
> )
>
> and tested again resulting in 87 Requests/Second
>
> I repeated adding tables (table2, table3 etc)
> After adding 5 tables the test was down to 67 Requests/Second
> After adding 10 tables the test was down to 52 Requests/Second
> After adding 30 tables the test was down to 27 Requests/Second
>
> The full test results are logged 
> here:https://docs.google.com/spreadsheet/ccc?key=0ApWaSSISueScdG1DSDl4NVNk...
>
> I am starting to look at the DAL code to see if I notice anything that
> can be improved, haven't noticed anything yet.  I am wondering if
> anyone has any thoughts on what would be causing this.


[web2py] Re: debugging

2012-02-10 Thread Vineet
Forgot to mention that Full version of Eclipse is Not required. Only
the runtime.
You need to google for the runtime binary version download link.

-- V

On Feb 11, 9:28 am, Vineet  wrote:
> I am using eclipse + pydev for debugging.
> It rocks.
>
> Miguel Lopes has shared a excellent write-up on "how-to".
> You might be interested in this thread (see the 4th from last 
> post)http://groups.google.com/group/web2py/browse_thread/thread/b6c0cf5d61...
>
> HTH
>
> -- Vineet
>
> On Feb 11, 4:16 am, Alan Etkin  wrote:
>
>
>
>
>
>
>
> > There's very useful information about debugging web2py 
> > here:http://groups.google.com/group/web2py/browse_thread/thread/7ea4aadbd2...
>
> > On 10 feb, 03:53, shartha  wrote:
>
> > > I found some older posts on how to debug using web2py.py. Such file
> > > doesn't exist in newer versions. How can you debug an application in
> > > web2py in the current version?


[web2py] Re: debugging

2012-02-10 Thread Vineet
I am using eclipse + pydev for debugging.
It rocks.

Miguel Lopes has shared a excellent write-up on "how-to".
You might be interested in this thread (see the 4th from last post)
http://groups.google.com/group/web2py/browse_thread/thread/b6c0cf5d61d0c565/55eed4b5c8cd8234?lnk=gst&q=debug+eclipse#55eed4b5c8cd8234

HTH

-- Vineet


On Feb 11, 4:16 am, Alan Etkin  wrote:
> There's very useful information about debugging web2py 
> here:http://groups.google.com/group/web2py/browse_thread/thread/7ea4aadbd2...
>
> On 10 feb, 03:53, shartha  wrote:
>
> > I found some older posts on how to debug using web2py.py. Such file
> > doesn't exist in newer versions. How can you debug an application in
> > web2py in the current version?


Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1

2012-02-10 Thread Bruno Rocha
Thank you Anthony, I am going to talk about it with Michele.

On Fri, Feb 10, 2012 at 7:44 PM, Anthony  wrote:

> Only question I have is:
>>
>> I am using MIchelle's code to facebook and google Oauth. [
>> http://code.google.com/r/**michelecomitini-**facebookaccess/
>> ]
>>
>
> Oauth is GPLv2, which is not compatible with LGPL. Maybe you can get
> Michelle to switch to LGPL or make an exception for this one case.
>
>
>> I am using Kenji pagination plugin [ http://dev.s-cubism.com/**
>> plugin_paginator  ]
>>
>
> These plugins are all MIT, so no problem including them in a LGPL project.
>
>
>> I am using Ckeditor and Plugin Ckeditor by Ross Peoples  [
>> https://bitbucket.org/**PhreeStyle/web2py_ckeditor/**wiki/Home
>> ]
>>
>
> I don't see any license with this one. Would probably be a good idea if
> Ross adopted some license (maybe MIT or BSD). Without an explicit license,
> I'm not sure about the legal status of its usage (at least in the US, it is
> copyrighted by default, so I'm not sure you can use it unless specific
> rights are explicitly granted or it has been put in the public domain).
>
> Anthony
>
> --
> mail from:GoogleGroups "web2py-developers" mailing list
> make speech: web2py-develop...@googlegroups.com
> unsubscribe: web2py-developers+unsubscr...@googlegroups.com
> details : http://groups.google.com/group/web2py-developers
> the project: http://code.google.com/p/web2py/
> official : http://www.web2py.com/
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Re: Modules: how to access db

2012-02-10 Thread Sathvik Ponangi
Thanks for that!

I've never tested it in a multi-threaded environment.

On Sat, Feb 11, 2012 at 4:41 AM, nick name wrote:

> This solution will lead to a race condition. Do not use it!
>
> If you have multiple threads, they might update your commons at the same
> time and you'll get request from one session, and session from another, and
> db from a third.
>
> "current" is a thread-local thing, guaranteed not to be touched by any
> other part - use "current", not "common" (or whatever your own module is
> called)
>



-- 
Sathvik Ponangi


[web2py] Re: Scheduler json string for vars parm

2012-02-10 Thread blackthorne
Never mind, just did it!

args=[]
vars={"plugin_title":"http","targets":["http://www.google.pt"]}

On Feb 11, 2:08 am, blackthorne  wrote:
> Sorry, to reopen this thread, I have a question close to this one.
> I want to invoke a method called "plugin_run" from a scheduler task.
>
> def plugin_run(plugin_title, **kw): <- this is the signature
>
> plugin_run('http',targets=['https://www.google.pt']) <- valid example
>
> considering this,  how should I invoke args and vars in the
> scheduler_task?
>
> Thank you
>
> On Feb 6, 10:18 pm, Martín Mulone  wrote:
>
>
>
>
>
>
>
> > Yes I think the json format is strict to " instead of '
>
> > change with this and try again:
>
> > vars='{"fromDate":"2012-01-01","toDate":"2012-01-31","districtNumber":0}',
>
> > 2012/2/6 Jim Steil 
>
> > > Hi
>
> > > I'm having trouble getting my vars json string right on my call to add a
> > > job to my scheduler.  If I run with no vars, it works fine.  But, when I
> > > add my json string I'm getting:
>
> > > Traceback (most recent call last):
> > >  File "C:\dev\web2py\gluon\**scheduler.py", line 159, in executor
> > >    vars = loads(task.vars, object_hook=_decode_dict)
> > >  File "C:\dev\web2py\gluon\contrib\**simplejson\__init__.py", line 403,
> > > in loads
> > >    return cls(encoding=encoding, **kw).decode(s)
> > >  File "C:\dev\web2py\gluon\contrib\**simplejson\decoder.py", line 403, in
> > > decode
> > >    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
> > >  File "C:\dev\web2py\gluon\contrib\**simplejson\decoder.py", line 419, in
> > > raw_decode
> > >    obj, end = self.scan_once(s, idx)
> > >  File "C:\dev\web2py\gluon\contrib\**simplejson\scanner.py", line 72, in
> > > scan_once
> > >    return _scan_once(string, idx)
> > >  File "C:\dev\web2py\gluon\contrib\**simplejson\scanner.py", line 43, in
> > > _scan_once
> > >    _scan_once, object_hook, object_pairs_hook, memo)
> > >  File "C:\dev\web2py\gluon\contrib\**simplejson\decoder.py", line 207, in
> > > JSONObject
> > >    raise JSONDecodeError("Expecting property name", s, end)
> > > JSONDecodeError: Expecting property name: line 1 column 1 (char 1)
>
> > > My add_task looks like this:
>
> > >    db.scheduler_task.insert(
> > >         status='QUEUED',
> > >         application_name='myApp',
> > >         task_name='Task name',
> > >         function_name='functionname',
> > >         args='[]',
> > >         vars="{'fromDate':'2012-01-01'**,'toDate':'2012-01-31','**
> > > districtNumber':0}",
> > >         enabled=True,
> > >         start_time=request.now,
> > >         stop_time=request.now+**datetime.timedelta(days=1),
> > >         repeats=1,
> > >         timeout=600)
>
> > > is there something obvious I'm doing wrong?
>
> > >    -Jim
>
> > --
> >  http://www.tecnodoc.com.ar


[web2py] Re: Scheduler json string for vars parm

2012-02-10 Thread blackthorne
Sorry, to reopen this thread, I have a question close to this one.
I want to invoke a method called "plugin_run" from a scheduler task.

def plugin_run(plugin_title, **kw): <- this is the signature

plugin_run('http',targets=['https://www.google.pt']) <- valid example

considering this,  how should I invoke args and vars in the
scheduler_task?

Thank you


On Feb 6, 10:18 pm, Martín Mulone  wrote:
> Yes I think the json format is strict to " instead of '
>
> change with this and try again:
>
> vars='{"fromDate":"2012-01-01","toDate":"2012-01-31","districtNumber":0}',
>
> 2012/2/6 Jim Steil 
>
>
>
>
>
>
>
>
>
> > Hi
>
> > I'm having trouble getting my vars json string right on my call to add a
> > job to my scheduler.  If I run with no vars, it works fine.  But, when I
> > add my json string I'm getting:
>
> > Traceback (most recent call last):
> >  File "C:\dev\web2py\gluon\**scheduler.py", line 159, in executor
> >    vars = loads(task.vars, object_hook=_decode_dict)
> >  File "C:\dev\web2py\gluon\contrib\**simplejson\__init__.py", line 403,
> > in loads
> >    return cls(encoding=encoding, **kw).decode(s)
> >  File "C:\dev\web2py\gluon\contrib\**simplejson\decoder.py", line 403, in
> > decode
> >    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
> >  File "C:\dev\web2py\gluon\contrib\**simplejson\decoder.py", line 419, in
> > raw_decode
> >    obj, end = self.scan_once(s, idx)
> >  File "C:\dev\web2py\gluon\contrib\**simplejson\scanner.py", line 72, in
> > scan_once
> >    return _scan_once(string, idx)
> >  File "C:\dev\web2py\gluon\contrib\**simplejson\scanner.py", line 43, in
> > _scan_once
> >    _scan_once, object_hook, object_pairs_hook, memo)
> >  File "C:\dev\web2py\gluon\contrib\**simplejson\decoder.py", line 207, in
> > JSONObject
> >    raise JSONDecodeError("Expecting property name", s, end)
> > JSONDecodeError: Expecting property name: line 1 column 1 (char 1)
>
> > My add_task looks like this:
>
> >    db.scheduler_task.insert(
> >         status='QUEUED',
> >         application_name='myApp',
> >         task_name='Task name',
> >         function_name='functionname',
> >         args='[]',
> >         vars="{'fromDate':'2012-01-01'**,'toDate':'2012-01-31','**
> > districtNumber':0}",
> >         enabled=True,
> >         start_time=request.now,
> >         stop_time=request.now+**datetime.timedelta(days=1),
> >         repeats=1,
> >         timeout=600)
>
> > is there something obvious I'm doing wrong?
>
> >    -Jim
>
> --
>  http://www.tecnodoc.com.ar


[web2py] Re: One issues (I guess) with auth form login+janrain

2012-02-10 Thread Alan Etkin
> Does it makes sense to popup the password field if it's None from the dict?

I think it does, as doing otherwise would limit the authentication
feature. If you don't want to ask for password in an authentication
form, you could customize the form validation to set/get a password
automatically.

Anyway, I am not sure if when using janrain login it is possible to
configure passwords. It seems that it doesn't

On 7 feb, 20:07, Ricardo Pedroso  wrote:
> I'm evaluatind multiple logins using the normal auth form + janrain in
> web2py 1.99.4
> It's working almost as I was expecting, but when I do the following steps:
>
> 1) login with janrain (in my case using google)
> 2) I'm sucessfully logged in my app.
>     I go to /myap/default/user/change_password and cannot change my pass
>     because I don't have one yet to fill the "old password" field.
> 3) I got to appadmin and setup a pass for my user
> 4) I logout and login using my email/pass in auth form. It works
> 5) Now I logout and login using janrain and my previous password was blanked
>
> I try to debug it and found that in step 5 the pass is being blanked
> in gluon/tools.py:
>
>     def get_or_create_user(self, keys):
>         (...)
>         if user:
>             print table_user, keys
>             user.update_record(**table_user._filter_fields(keys))
>         (...)
>
> I added a print statement and it gives me:
>
> auth_user {'first_name': u'Ricardo',
>                 'last_name': u'Pedroso',
>                 'registration_id': u'https://www.google.com/profiles/',
>                 'password': None,
>                 'registration_key': '',
>                 'email': u'em...@example.com'}
>
> Note that the 'registration_id' and 'email' fields are not the ones I
> get, I just edit them to post here.
>
> The field that matters for this case is the 'password': None.
>
> Is where my pass is being blanked, right?
> Can this be avoid?
> Does it makes sense to popup the password field if it's None from the dict?
>
> A more general question, does it make sense to use auth form+janrain?
>
> The code I'm using that is different from the scaffold app:
>
> models/db.py:
> 
> ()
>
> auth.define_tables()
>
> from gluon.contrib.login_methods.rpx_account import RPXAccount
> from gluon.contrib.login_methods.extended_login_form import ExtendedLoginForm
>
> other_form = RPXAccount(request,
>     api_key='mykey',
>     domain='mydomain',
>     url = "http://localhost:8000/%s/default/user/login"; % request.application)
>
> auth.settings.login_form = ExtendedLoginForm(auth, other_form,
> signals=['token'])
>
> (...)
>
> ---
>
> Regards,
> Ricardo


Re: [web2py] Re: The web2py version

2012-02-10 Thread Bruce Wade
Yeah the None error is because we need to add an error message for
IS_STRONG for some reason that validator doesn't return any message,
possibly a bug??

I agree the fonts are oversized however that is what the CEO wants because
most of our members are older people who are not very good with computers.

On Fri, Feb 10, 2012 at 3:37 PM, Alan Etkin  wrote:

> It looks nice.
>
> The registration validation returns a "None" error at the first
> section. I think that the text font is oversized (seen with Firefox
> 3.6.24 and a 16" LCD)
>
> Regards
>
> On 9 feb, 22:29, Bruce Wade  wrote:
> > Hi,
> >
> > I know I have been posting a lot of questions in this group, here is why:
> http://176.34.12.39
> >
> > The port is about 90% complete now after 1.5 months of work :D
> >
> > Have removed 100s of lines of code in some parts of the application. Let
> me
> > know what you think so far. The database is just junk data right now.
> >
> > --
> > --
> > Regards,
> > Bruce Wadehttp://
> ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: Search menu

2012-02-10 Thread Alan Etkin
I belive there's no info about this case in the book, perhaps you
could use form helpers and other tags into the link placeholders after
the menu object creation, modifying the MENU output, so the effect
would be similar to what you described. However, there could be some
issues with the display of the subitems, as they are shown only if
there is a current mouse hover event.

MENU is documented in the section 5.2.3 of the web2py book.

On 8 feb, 06:27, shartha  wrote:
> Hello everyone,
>
> I'd like to have a search menu that has two submenus. Submenus will
> appear if the mouse is over the search menu. The first submenu is
> nothing but a text field and a button where the user can enter an
> expression and press the button to get the results of the search (this
> is for basic search), and the second submenu is "Advanced Search" that
> will take away the user to a new page so that they could enter the
> detailed criteria for their search.
>
> Is this (the first submenu) easy to implement in web2py?
>
> Thanks,
> Shartha


[web2py] Re: Chain/Multiple condition on select

2012-02-10 Thread gbs
Yes, thanks, you'r right.

With you'r method, it's simple ;)
And you can make AND condition :

query &= db.mytable.tag == tag

OR condition :
query |= db.mytable.tag == tag

It's exactly what i'm seeking!
You'r solution, and Bruno's one, are perfect,

I hope that can help someone else,

Have a nice day!

On 11 fév, 00:23, Anthony  wrote:
> On Friday, February 10, 2012 6:19:09 PM UTC-5, gbs wrote:
>
> > I have try the solution of anthony, but i don't have the skill in
> > python to success..
> > (some error with 'Rows' object has no attribute 'select', etc ;)
>
> Once the query has been built, this should work:
>
> rows = db(query).select()
>
> Anthony


[web2py] Re: markmin and image width

2012-02-10 Thread Alan Etkin
If you mean having markmin to give the image a given width, this migth
help:

"... This paragraph has an image aligned to the right with a width of
200px. Its is placed using the code

[[some image http://www.web2py.com/examples/static/web2py_logo.png
right 200px]]. ..."

from here:
http://web2py.com/examples/static/markmin.html

On 8 feb, 10:35, Jose  wrote:
> Hi,
>
> How I can set the width of an image (to be processed by markmin)?
>
> Best regards,
> Jose


[web2py] Re: The web2py version

2012-02-10 Thread Alan Etkin
It looks nice.

The registration validation returns a "None" error at the first
section. I think that the text font is oversized (seen with Firefox
3.6.24 and a 16" LCD)

Regards

On 9 feb, 22:29, Bruce Wade  wrote:
> Hi,
>
> I know I have been posting a lot of questions in this group, here is 
> why:http://176.34.12.39
>
> The port is about 90% complete now after 1.5 months of work :D
>
> Have removed 100s of lines of code in some parts of the application. Let me
> know what you think so far. The database is just junk data right now.
>
> --
> --
> Regards,
> Bruce 
> Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com


[web2py] Re: Chain/Multiple condition on select

2012-02-10 Thread Anthony
On Friday, February 10, 2012 6:19:09 PM UTC-5, gbs wrote:
>
> I have try the solution of anthony, but i don't have the skill in 
> python to success.. 
> (some error with 'Rows' object has no attribute 'select', etc ;) 
>

Once the query has been built, this should work:

rows = db(query).select() 

Anthony


[web2py] Re: Chain/Multiple condition on select

2012-02-10 Thread gbs
I have try the solution of anthony, but i don't have the skill in
python to success..
(some error with 'Rows' object has no attribute 'select', etc ;)

But it's my fault,

Thanks again

On 10 fév, 23:43, gbs  wrote:
> Thanks to all.
>
> I have test the first answer, from Bruno..
>
> It's work!
>
> Thanks a lot, i'm searching/reading during a long time!
>
> I will test the others solutions, why i think they are more simple/
> comprehensible for me :$
>
> Best regards
>
> ps : sorry for the language
>
> On 10 fév, 23:18, Bruno Rocha  wrote:
>
>
>
>
>
>
>
> > > *queries=[]*
> > > *if arg1 == "x": queries.append(db.table.field == x)*
> > > *if arg2 == "y": queries.append(db.table.otherfield == y)*
> > > *# many conditions here*
> > > *query = reduce(lambda a,b:(a&b),queries)*
> > > *db(query).select()*
>
> > On Fri, Feb 10, 2012 at 8:10 PM, gbs  wrote:
> > > Hi,
>
> > > i have search posts on this group, but i don't have found the solution
> > > of my question :$
>
> > > I have a table, wich display record of a database, nothing weird..
>
> > > I have made a form, so you can "filter" the result.
>
> > > You can check "Tag" of the record, "Status" of the record, so on...
>
> > > How can i create an sql "requete/statement" : ??
>
> > > sql = ""
> > > -- if tag :
> > >   sql += "tag = xxx"
> > > -- if status:
> > >   sql += " and status = xxx"
>
> > > result = db(sql).select()
>
> > > it's just an example, wich don't work, but i don't understand how to
> > > chain condition of a query :$
>
> > > Best regards
>
> > --
>
> > Bruno Rocha
> > [http://rochacbruno.com.br]


[web2py] Re: debugging

2012-02-10 Thread Alan Etkin
There's very useful information about debugging web2py here:
http://groups.google.com/group/web2py/browse_thread/thread/7ea4aadbd2676e3/c714f62f47db2968

On 10 feb, 03:53, shartha  wrote:
> I found some older posts on how to debug using web2py.py. Such file
> doesn't exist in newer versions. How can you debug an application in
> web2py in the current version?


[web2py] Re: security check in web2py

2012-02-10 Thread nick name
I usually run it with -i 0.0.0.0 , which means it listens simultaneously on 
127.x.y.z and on any other address the computer might have. The admin pages 
are accessible only when coming through localhost (127.0.0.1) or ssl, no 
need for different processes/ports.


[web2py] Re: Modules: how to access db

2012-02-10 Thread nick name
This solution will lead to a race condition. Do not use it!

If you have multiple threads, they might update your commons at the same 
time and you'll get request from one session, and session from another, and 
db from a third.

"current" is a thread-local thing, guaranteed not to be touched by any 
other part - use "current", not "common" (or whatever your own module is 
called)


Re: [web2py] DAL speed - an idea

2012-02-10 Thread nick name
There's a tree structure among the record, upon which the aggregation is 
computed.

Some dbs (e.g. oracle) have extensions for tree-like structures (CONNECT BY 
etc), but it is not standard, and I need to support both sqlite and 
postgres in this app.



Re: [web2py] Re: keep shared objects permanently in RAM: Is it possible ?

2012-02-10 Thread Michele Comitini
I wrote:
> The problem with MAP_ANONYMOUS is that you cannot share after fork.

I should have written: you cannot share *a mmap created* after fork.

>
> http://www.kernel.org/doc/man-pages/online/pages/man2/mmap.2.html
>
> If you are on Linux here you find some quick explanation how mmap,
> tmpfs and shm fs relate to each others:
> http://stackoverflow.com/questions/904581/shmem-vs-tmpfs-vs-mmap


Re: [web2py] Re: keep shared objects permanently in RAM: Is it possible ?

2012-02-10 Thread Michele Comitini
2012/2/9 Sebastian E. Ovide :
> That is a nice trick for sharing information with different processes
> reducing to the minimum the FS IO... It still has the IO bottleneck of
> read/write from/to file compare with real data permanent in memory... but
> still a valid approach...

On a generic posix system you have to use MAP_ANONIMOUS to avoid that
on linux if you have lots of physical RAM setting the MAP_SHARED flag
should be enough.
The problem with MAP_ANONYMOUS is that you cannot share after fork.

http://www.kernel.org/doc/man-pages/online/pages/man2/mmap.2.html

If you are on Linux here you find some quick explanation how mmap,
tmpfs and shm fs relate to each others:
http://stackoverflow.com/questions/904581/shmem-vs-tmpfs-vs-mmap


Re: [web2py] Re: Chain/Multiple condition on select

2012-02-10 Thread Anthony
On Friday, February 10, 2012 5:35:50 PM UTC-5, Detectedstealth wrote:
>
> sql = db
> -- if tag :
>   sql = sql(db.mytable.tag = "xxx")
> -- if status:
>   sql = sql(db.mytable.status = "xxx")
>
> result = sql.select()


Yes, that's nice too. It works because the Set object is callable, and 
calling it adds a new condition to its query.

Anthony 


[web2py] Re: Chain/Multiple condition on select

2012-02-10 Thread gbs
Thanks to all.

I have test the first answer, from Bruno..

It's work!

Thanks a lot, i'm searching/reading during a long time!

I will test the others solutions, why i think they are more simple/
comprehensible for me :$

Best regards

ps : sorry for the language

On 10 fév, 23:18, Bruno Rocha  wrote:
> > *queries=[]*
> > *if arg1 == "x": queries.append(db.table.field == x)*
> > *if arg2 == "y": queries.append(db.table.otherfield == y)*
> > *# many conditions here*
> > *query = reduce(lambda a,b:(a&b),queries)*
> > *db(query).select()*
>
> On Fri, Feb 10, 2012 at 8:10 PM, gbs  wrote:
> > Hi,
>
> > i have search posts on this group, but i don't have found the solution
> > of my question :$
>
> > I have a table, wich display record of a database, nothing weird..
>
> > I have made a form, so you can "filter" the result.
>
> > You can check "Tag" of the record, "Status" of the record, so on...
>
> > How can i create an sql "requete/statement" : ??
>
> > sql = ""
> > -- if tag :
> >   sql += "tag = xxx"
> > -- if status:
> >   sql += " and status = xxx"
>
> > result = db(sql).select()
>
> > it's just an example, wich don't work, but i don't understand how to
> > chain condition of a query :$
>
> > Best regards
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]


Re: [web2py] Re: Chain/Multiple condition on select

2012-02-10 Thread Bruce Wade
sql = db
-- if tag :
  sql = sql(db.mytable.tag = "xxx")
-- if status:
  sql = sql(db.mytable.status = "xxx")

result = sql.select()

On Fri, Feb 10, 2012 at 2:25 PM, Anthony  wrote:

> You could do something like:
>
> query = db.mytable.id > 0
> if tag:
> query &= db.mytable.tag == tag
> if status:
> query &= db.mytable.status == status
>
> Anthony
>
>
> On Friday, February 10, 2012 5:10:01 PM UTC-5, gbs wrote:
>>
>> Hi,
>>
>> i have search posts on this group, but i don't have found the solution
>> of my question :$
>>
>> I have a table, wich display record of a database, nothing weird..
>>
>> I have made a form, so you can "filter" the result.
>>
>> You can check "Tag" of the record, "Status" of the record, so on...
>>
>> How can i create an sql "requete/statement" : ??
>>
>> sql = ""
>> -- if tag :
>>sql += "tag = xxx"
>> -- if status:
>>sql += " and status = xxx"
>>
>> result = db(sql).select()
>>
>> it's just an example, wich don't work, but i don't understand how to
>> chain condition of a query :$
>>
>> Best regards
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: keep shared objects permanently in RAM: Is it possible ?

2012-02-10 Thread Michele Comitini
>>  You can reach a very high level of
>> parallelism with lower dead-locking probability than with java
>> threads.
>
>
> any source about that ? (any paper, benchmarks etc...)
>
Search for something like  "Guido van Rossum  threading vs forking" or
read some recent Bruce Eckel books.  The summary is that threads i.e.
a "share all, but little" are a bad approach in anything more than a
simple flow, because you end up managing a lot of possible resource
contention, and still you never know any possible state of the
application.  Better to start defining what is to be shared ("share
nothing but little") and define how to share just that.
So why threads are popular?  Because in the early '90s a very popular
O.S. was not able to support forking without killing the machine and
eating up all memory.  Java was born in that period and they took the
decision to support threads (and Java does it very well) instead of
parallel processes because of that.  Now most systems support MMU
ability to do copy on write of memory so there is no need to worry
about forks anymore.

MMAP is a way to do the sharing without resorting to different
semantics than those available with files, there are many other ways
depending on your needs.  The processing module of the standard python
library does a lot of that for you in a transparent way.  If you need
parallel processing at a higher level also across the network,
parallel python is very good at that.  In any case *stay away* from
python threading if you need really concurrent tasks.  If you expect
that they perform as in Java you will be disapponted.

mic


[web2py] Re: Chain/Multiple condition on select

2012-02-10 Thread Anthony
You could do something like:

query = db.mytable.id > 0
if tag:
query &= db.mytable.tag == tag
if status:
query &= db.mytable.status == status

Anthony

On Friday, February 10, 2012 5:10:01 PM UTC-5, gbs wrote:
>
> Hi, 
>
> i have search posts on this group, but i don't have found the solution 
> of my question :$ 
>
> I have a table, wich display record of a database, nothing weird.. 
>
> I have made a form, so you can "filter" the result. 
>
> You can check "Tag" of the record, "Status" of the record, so on... 
>
> How can i create an sql "requete/statement" : ?? 
>
> sql = "" 
> -- if tag : 
>sql += "tag = xxx" 
> -- if status: 
>sql += " and status = xxx" 
>
> result = db(sql).select() 
>
> it's just an example, wich don't work, but i don't understand how to 
> chain condition of a query :$ 
>
> Best regards



[web2py] Re: Chain/Multiple condition on select

2012-02-10 Thread gbs
Oh? you think?

Ok i will test, thanks a lot!

On 10 fév, 23:18, Bruno Rocha  wrote:
> > *queries=[]*
> > *if arg1 == "x": queries.append(db.table.field == x)*
> > *if arg2 == "y": queries.append(db.table.otherfield == y)*
> > *# many conditions here*
> > *query = reduce(lambda a,b:(a&b),queries)*
> > *db(query).select()*
>
> On Fri, Feb 10, 2012 at 8:10 PM, gbs  wrote:
> > Hi,
>
> > i have search posts on this group, but i don't have found the solution
> > of my question :$
>
> > I have a table, wich display record of a database, nothing weird..
>
> > I have made a form, so you can "filter" the result.
>
> > You can check "Tag" of the record, "Status" of the record, so on...
>
> > How can i create an sql "requete/statement" : ??
>
> > sql = ""
> > -- if tag :
> >   sql += "tag = xxx"
> > -- if status:
> >   sql += " and status = xxx"
>
> > result = db(sql).select()
>
> > it's just an example, wich don't work, but i don't understand how to
> > chain condition of a query :$
>
> > Best regards
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]


[web2py] Re: Chain/Multiple condition on select

2012-02-10 Thread gbs

I know that you can do :
result = db((db.xxx.tag==tag) & (db.xxx.status==status)).select()

But i don't know how to generate the condition, one by one...





On 10 fév, 23:10, gbs  wrote:
> Hi,
>
> i have search posts on this group, but i don't have found the solution
> of my question :$
>
> I have a table, wich display record of a database, nothing weird..
>
> I have made a form, so you can "filter" the result.
>
> You can check "Tag" of the record, "Status" of the record, so on...
>
> How can i create an sql "requete/statement" : ??
>
> sql = ""
> -- if tag :
>    sql += "tag = xxx"
> -- if status:
>    sql += " and status = xxx"
>
> result = db(sql).select()
>
> it's just an example, wich don't work, but i don't understand how to
> chain condition of a query :$
>
> Best regards


Re: [web2py] Chain/Multiple condition on select

2012-02-10 Thread Bruno Rocha
>
> *queries=[]*
> *if arg1 == "x": queries.append(db.table.field == x)*
> *if arg2 == "y": queries.append(db.table.otherfield == y)*
> *# many conditions here*
> *query = reduce(lambda a,b:(a&b),queries)*
> *db(query).select()*
>

On Fri, Feb 10, 2012 at 8:10 PM, gbs  wrote:

> Hi,
>
> i have search posts on this group, but i don't have found the solution
> of my question :$
>
> I have a table, wich display record of a database, nothing weird..
>
> I have made a form, so you can "filter" the result.
>
> You can check "Tag" of the record, "Status" of the record, so on...
>
> How can i create an sql "requete/statement" : ??
>
> sql = ""
> -- if tag :
>   sql += "tag = xxx"
> -- if status:
>   sql += " and status = xxx"
>
> result = db(sql).select()
>
> it's just an example, wich don't work, but i don't understand how to
> chain condition of a query :$
>
> Best regards




-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: maybe minor bug or just documentation

2012-02-10 Thread Anthony

>
> jodb.define_table('category', 
> Field('name', 'string', length=100, unique = True, requires = 
> IS_NOT_EMPTY()),
>

Here, by explicitly specifying "requires", you are preventing web2py from 
automatically adding the IS_NOT_IN_DB validator, so you have to add that 
one explicitly as well.
 

> jodb.category.name.requires = IS_NOT_IN_DB(jodb,jodb.category.name) 
>

Here, by specifying the IS_NOT_IN_DB validator, you have overwritten the 
previously specified IS_NOT_EMPTY() validator. Instead, try:

requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(jodb, jodb.category.name)]

Or you can simply specify unique=True and notnull=True (without specifying 
any "requires"), and you will automatically get both of those validators.

Anthony


[web2py] Chain/Multiple condition on select

2012-02-10 Thread gbs
Hi,

i have search posts on this group, but i don't have found the solution
of my question :$

I have a table, wich display record of a database, nothing weird..

I have made a form, so you can "filter" the result.

You can check "Tag" of the record, "Status" of the record, so on...

How can i create an sql "requete/statement" : ??

sql = ""
-- if tag :
   sql += "tag = xxx"
-- if status:
   sql += " and status = xxx"

result = db(sql).select()

it's just an example, wich don't work, but i don't understand how to
chain condition of a query :$

Best regards


[web2py] Re: how to deploy web2py not in the apache root (help with url rewriting)

2012-02-10 Thread giovanni allegri
Thanks for your tips.
I'm out of office in these days so I cannot test it now. I was just
thinking to the solution suggested by tom. I will try it because I
will have to serve various applications. I will need to remove the w2p
prefix too to obtain (e.g.):
http://server2/cpa4 and http://server/master
instead of
http://server2/w2p/cpa4 and http://server/w2p/master.

I will let you know if I get to the point ;)
giovanni


On 9 Feb, 18:22, Wikus van de Merwe 
wrote:
> If you have just one application all you need to do is set the web2py WSGI
> script alias and serve files from the web2py folder excluding admin parts.
>
> WSGIDaemonProcess web2py display-name=%{GROUP}
> WSGIProcessGroup web2py
> WSGIScriptAlias /prefix /var/www/web2py/wsgihandler.py
>
> 
>     Options +FollowSymLinks
>     AllowOverride None
>     Order Allow,Deny
>     Deny from all
>     
>       Allow from all
>     
>   
>
>   AliasMatch ^/prefix/([^/]+)/static/(.*)
> /var/www/web2py/applications/$1/static/$2
>
>   
>     Order Allow,Deny
>     Allow from all
>   
>
>   
>     Deny from all
>   
>
>   
>     Deny from all
>   
> 
>
> Then set path prefix and the default application in your web2py/routes.py
> file:
>
> routers = dict(
>     # base router
>     BASE = dict(
>         default_application = "app",
>         path_prefix = "prefix",
>     ),
> )
>
> As a result you will get "domain/prefix" pointing to the default
> application "app".


Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1

2012-02-10 Thread Ross Peoples
CKEditor is licensed under LGPL, so you're good there. As for 
plugin_ckeditor. I wrote it, but I haven't given it a license yet (on my 
todo list). However, I will probably go with LGPL as well. It only makes 
sense as web2py and CKEditor are both LGPL. So you are all set with the 
CKEditor stuff.

Everything that I release and publish to the public, such as 
plugin_ckeditor, I do so with the intent to allow people to use it for 
their own purposes, whatever they may be, so long as they contribute 
changes make to my work back to the public. This is pretty much what the 
LGPL is for (from my understanding).


Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1

2012-02-10 Thread Anthony

>
> Only question I have is:
>
> I am using MIchelle's code to facebook and google Oauth. [
> http://code.google.com/r/michelecomitini-facebookaccess/]
>

Oauth is GPLv2, which is not compatible with LGPL. Maybe you can get 
Michelle to switch to LGPL or make an exception for this one case.
 

> I am using Kenji pagination plugin [ 
> http://dev.s-cubism.com/plugin_paginator ]
>

These plugins are all MIT, so no problem including them in a LGPL project.
 

> I am using Ckeditor and Plugin Ckeditor by Ross Peoples  [
> https://bitbucket.org/PhreeStyle/web2py_ckeditor/wiki/Home]
>

I don't see any license with this one. Would probably be a good idea if 
Ross adopted some license (maybe MIT or BSD). Without an explicit license, 
I'm not sure about the legal status of its usage (at least in the US, it is 
copyrighted by default, so I'm not sure you can use it unless specific 
rights are explicitly granted or it has been put in the public domain).

Anthony


Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1

2012-02-10 Thread Bruno Rocha
well, I did it, LGPLv3
https://github.com/rochacbruno/Movuca/blob/master/LICENSE

I needed to choose today because I will start a big project for one client
using Movuca as base, and I read too much (do not understand everything)
but I think LPGP will fits it.

Only question I have is:

I am using MIchelle's code to facebook and google Oauth. [
http://code.google.com/r/michelecomitini-facebookaccess/]
I am using Kenji pagination plugin [
http://dev.s-cubism.com/plugin_paginator ]
I am using Ckeditor and Plugin Ckeditor by Ross Peoples  [
https://bitbucket.org/PhreeStyle/web2py_ckeditor/wiki/Home]

Maybe I am going to use another libraries, how can I know if it is
compatible or not?


-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Re: Need assistance with executesql

2012-02-10 Thread Niphlod
it's actually not web2py, but the db adapter .

Also, it would be a lot easier without having to taking into account the 
first interpolation (payback_types = ('s','p')) .

In that case you can use the simple %(name)s notation with dict as 
placeholders parameter, or the positional one with simple %s and a tuple as 
placeholders parameter


Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1

2012-02-10 Thread Anthony
On Friday, February 10, 2012 3:09:56 PM UTC-5, rochacbruno wrote:
>
>
>
> On Fri, Feb 10, 2012 at 1:00 PM, Wikus van de Merwe <
> dupakrop...@googlemail.com> wrote:
>
>> GPLv3
>
>
> Whats the key differences between GPLv3 and LGPLv3 ?
>

I think basically LGPL allows "linking" of proprietary software and GPL 
does not. Under LGPL, if someone wrote application or plugin code that 
merely called the Movuca API but didn't directly modify the Movuca code 
itself, that application or plugin code could remain proprietary. Under 
GPL, that same code could not remain proprietary and would have to be 
distributed with a GPL-compatible license. web2py adopted the LGPL to allow 
users to develop proprietary web2py applications (i.e., the idea being the 
applications call or "link" to the framework but do not represent a 
modification of the framework itself) while preventing commercial forks of 
the actual framework (previously web2py had used a GPLv2 license with a 
commercial exception for applications to achieve the same goal, but many 
people found that confusing and risky from a legal perspective).

Anthony



[web2py] Markmin Output Questions

2012-02-10 Thread Ross Peoples
I am looking into writing lots of documentation and have been looking 
around at the different solutions. I know that the web2py book was written 
with Markin, and seeing as how it is able to output to multiple different 
formats and supports things like tables and image alignment, I figure it's 
probably the best way to go.

I want the documentation to be viewable (like the web2py book online) and 
be able to generate a PDF book, just like the web2py book. How do I do 
this? And here are a few more specific questions I have about this process:

   - Should each chapter (or topic) be in it's own file?
   - How do you insert page numbers, pages breaks, etc into the resulting 
   PDF file?
   - How do I generate the table of contents and the index?

This is the first time I've done anything remotely professional with 
documentation, so any other tips would be helpful. Thanks!



[web2py] Re: web2py shell not executing db.define_table() but does record it in SQL log.

2012-02-10 Thread Massimo Di Pierro
You did not db.commit() it

On Feb 10, 2:04 pm, Bill Thayer  wrote:
> In summary, creating a person table from the web2py shell creates an entry
> in the SQL log but does not create the table.
>
> I'm using the images example webapp for working the examples in Chapter 
> 26.
> I entered...
>
> >>> db.define_table('person', Field('name'), format='%(name)s %(id)s')
>
> ...into the shell. Then I entered...>>> print db.tables
>
> ...and the shell returned
> ['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 
> 'auth_event', 'auth_cas', 'image', 'comment']
>
> Notice no 'person' table. Yet the sql log shows the person table has been 
> created.
>
> timestamp: 2012-02-10T12:59:39.94
> CREATE TABLE person(
>     id INTEGER PRIMARY KEY AUTOINCREMENT,
>     name CHAR(512)
> );
> success!


Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1

2012-02-10 Thread Bruce Wade
Here is why openoffice moved from GPL to LGPL:
http://blogs.oracle.com/webmink/entry/openoffice_org_goes_to_lgplv3

On Fri, Feb 10, 2012 at 12:09 PM, Bruno Rocha  wrote:

>
>
> On Fri, Feb 10, 2012 at 1:00 PM, Wikus van de Merwe <
> dupakrop...@googlemail.com> wrote:
>
>> GPLv3
>
>
> Whats the key differences between GPLv3 and LGPLv3 ?
>
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: Need assistance with executesql

2012-02-10 Thread Bruce Wade
Yeah the DAL didn't work as planed.

Your final suggestion worked. I was using postgresql. With sqlalchemy you
can use :keyword I guess web2py requires %%(keyword)s as you said above.

Thanks for the help, this one was driving me crazy :D


On Fri, Feb 10, 2012 at 12:16 PM, Niphlod  wrote:

> PS: for postgresql, it's nasty ... placeholders are in "python" notation,
> so
>
> db.executesql('select * from %s', placeholders=('example'))
>
> or
>
> db.executesql('select * from %(tablename)s', placeholders={'tablename' :
> 'example'})
>
> works.
>
> If payback types is passed as a string, you need to add a % to retain the
> quoted template, I guess
>
>
> payback_types = ('s','p')
>   query_string = """
> select sum(happen_amount) from cash_journal
> where distributor_id = 1
> and transaction_type in %(types)s
> and extract(epoch from (%%s - happen_time)) < %%s;""" % {
> 'types': str(payback_types)
> }
>
> lockAmount = self.db.executesql(query_**string,
> placeholders=(now, seconds))
> or
>
>
> payback_types = ('s','p')
>   query_string = """
> select sum(happen_amount) from cash_journal
> where distributor_id = 1
> and transaction_type in %(types)s
> and extract(epoch from (%%(now)s - happen_time)) <
> %%(seconds)s;""" % {
> 'types': str(payback_types)
> }
>
> lockAmount = self.db.executesql(query_**string,
> placeholders=dict(now=now, seconds=seconds))
>
> should work as intended.
>
>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: Need assistance with executesql

2012-02-10 Thread Niphlod
PS: for postgresql, it's nasty ... placeholders are in "python" notation, so

db.executesql('select * from %s', placeholders=('example'))

or 

db.executesql('select * from %(tablename)s', placeholders={'tablename' : 
'example'})

works.

If payback types is passed as a string, you need to add a % to retain the 
quoted template, I guess

payback_types = ('s','p')
  query_string = """
select sum(happen_amount) from cash_journal 
where distributor_id = 1
and transaction_type in %(types)s
and extract(epoch from (%%s - happen_time)) < %%s;""" % {
'types': str(payback_types)
}

lockAmount = self.db.executesql(query_string, placeholders=(now, 
seconds))
or

payback_types = ('s','p')
  query_string = """
select sum(happen_amount) from cash_journal 
where distributor_id = 1
and transaction_type in %(types)s
and extract(epoch from (%%(now)s - happen_time)) < 
%%(seconds)s;""" % {
'types': str(payback_types)
}

lockAmount = self.db.executesql(query_string, 
placeholders=dict(now=now, seconds=seconds))

should work as intended.




Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1

2012-02-10 Thread Bruno Rocha
On Fri, Feb 10, 2012 at 1:00 PM, Wikus van de Merwe <
dupakrop...@googlemail.com> wrote:

> GPLv3


Whats the key differences between GPLv3 and LGPLv3 ?

-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] web2py shell not executing db.define_table() but does record it in SQL log.

2012-02-10 Thread Bill Thayer
In summary, creating a person table from the web2py shell creates an entry 
in the SQL log but does not create the table.

I'm using the images example webapp for working the examples in Chapter 
26. 
I entered...

>>> db.define_table('person', Field('name'), format='%(name)s %(id)s')

...into the shell. Then I entered...
>>> print db.tables
...and the shell returned
['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 'auth_event', 
'auth_cas', 'image', 'comment']

Notice no 'person' table. Yet the sql log shows the person table has been 
created.

timestamp: 2012-02-10T12:59:39.94
CREATE TABLE person(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name CHAR(512)
);
success!




[web2py] Re: Need assistance with executesql

2012-02-10 Thread Niphlod
what db is involved ?
placeholders can have different formats, I don't recall using the 
":variable" notation...

PS: I'm assming that the "seconds()" method in the other thread didn't 
worked... sorry for that 


Re: [web2py] Re: Folder inside controller dosen't work.

2012-02-10 Thread howesc
one option working with the framework as is:

 - make a controller called jsonrpc with 1 method
 - use the first arg from the request.args to select the module to call
 - create a directory in modules and put all your calls in there.
 - import and invoke the modules as needed by the controller (passing in 
request and whatever else is needed)

in that case you write 1 controller and forget about it, and then create 
the modules just as you were planning to make controllers.



Re: [web2py] Making Internationalization Easier

2012-02-10 Thread Bruno Rocha
I am interested in this, did you see how Magento inline translations works?

Let me know if I can help.

http://zerp.ly/rochacbruno
Em 10/02/2012 13:42, "Bruce Wade"  escreveu:

> Hello,
>
> I am working on a module for my current site that will make doing
> internationalization easier for non-technical people. Primary reason the
> current site will be translated into 5 different languages to start and the
> people doing the translations are not very good with technology to some
> extent.
>
> If anyone is interested in having this once I am done let me know.
>
> Features:
>  1) Languages table in the database, which stores the language code and
> language name
>  2) When a new language is created, the app searches the languages
> directory for a file with the language code as a name, if it isn't found it
> creates the file
>  3) A language parser/editor. When live translations is enabled, any text
> on the website created with T("") gets a special javascript function.
>When clicking on the text a dialogue box opens with language selections
> and the text for the selected language showing. The text showing is parsed
> from the language file.
>When the text is updated the parser also updates the language file.
> Unless it is English we would have to do something else so all other
> language files are updated, still thinking on this one.
> 4) The dialogue would use ajax to load the text for the selected language.
>
> 1, 2, and 4 will be easy step 3 is going to be a little tricky when saving.
>
> If anyone has any suggestions let me know.
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>


[web2py] Re: maybe minor bug or just documentation

2012-02-10 Thread Lewis
The model follows. Focus on the category.name field (and point out
anything else that looks wrong/inept). Looks like I have belt,
suspenders, and back-up suspenders for that field.  I need
category.name to be unique and not empty.  Is it the
requires=IS_NOT_EMPTY() that forces me to use IS_NOT_IN_DB instead of
unique=True?

Which is preferred so that postgresql enforces the constraints?

Thanks,
Lewis

jodb.define_table('joke',
Field('joketext', 'text',length=2048, requires = IS_NOT_EMPTY()),
Field('created_on', 'datetime', default=request.now),
Field('created_by', jodb.auth_user))

jodb.define_table('category',
Field('name', 'string', length=100, unique = True, requires =
IS_NOT_EMPTY()),
Field('created_by', jodb.auth_user) )

jodb.define_table('joke_category',
Field('joke', jodb.joke),
Field('category', jodb.category),
format = '%(name)s')

jodb.joke_category.category.requires = IS_IN_DB(jodb,jodb.category.id,
multiple=True)
jodb.category.name.requires = IS_NOT_IN_DB(jodb,jodb.category.name)
jodb.auth_user._format = '%(first_name)s %(last_name)s'

On Feb 9, 2:06 pm, Anthony  wrote:
> On Thursday, February 9, 2012 1:28:28 PM UTC-5, Lewis wrote:
>
> > Then why did web2py fail with a run time error?  Or why wasn't the run
> > time error trapped?  Maybe because I had requires on the same table
> > for a different constraint?
>
> I assume there must be an explicit "requires" attribute set for that field
> somewhere, so the automatic setting of "requires" isn't happening. You'll
> have to show more code.
>
> > It doesn't look good when visitors to your site see the web2py error
> > ticket page.
>
> You can generate friendly error pages -- 
> seehttp://web2py.com/books/default/chapter/29/4#Routes-on-error. The error
> page can be a static file, or a dynamically generated page. In the latter
> case, it might be safer to have the error handler in a separate error
> handling application -- that way if the error happens to be in a model file
> of your main app, it won't prevent the error handler from being reached.
>
> Anthony


[web2py] Need assistance with executesql

2012-02-10 Thread Bruce Wade
Hi,

I have posted a question about getting this to work with DAL, I am unable
to do so. Therefor wish to just use executesql but am also having some
issues.

The way we have been doing it with sqlalchemy:
sqlstr = """ select sum(happen_amount) from cash_journal
 where transaction_type in ('s','l')
   and extract(epoch from
(:now-happen_time))<:seconds
   and distributor_id = :id
"""
lockAmount = engine.execute(text(sqlstr), now=now, seconds=seconds,
id=self.id).scalar()

With executesql I have tried several things, now I am at this point:
  payback_types = ('s','p')
  query_string = """
select sum(happen_amount) from cash_journal
where distributor_id = 1
and transaction_type in %(types)s
and extract(epoch from (:now - happen_time)) < :seconds;""" % {
'types': str(payback_types)
}

lockAmount = self.db.executesql(query_string,
placeholders=dict(now=now, seconds=seconds))

Any suggestions? I have more then one piece of code that is going to
require executesql.

Traceback (most recent call last):
  File 
"/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py",
line 204, in restricted
exec ccode in environment
  File 
"/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/controllers/members.py"
,
line 806, in 
  File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/globals.py",
line 172, in 
self._caller = lambda f: f()
  File 
"/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/controllers/members.py"
,
line 6, in test_calculations
print distributor_engine.get_cash_inlock_amount(distributor)
  File "applications/welcome/modules/distributor_api.py", line 127, in
get_cash_inlock_amount
lockAmount = self.db.executesql(query_string,
placeholders=dict(now=now, seconds=seconds))
  File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/dal.py",
line 5169, in executesql
self._adapter.execute(query, placeholders)
  File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/dal.py",
line 1359, in execute
return self.log_execute(*a, **b)
  File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/dal.py",
line 1353, in log_execute
ret = self.cursor.execute(*a, **b)
OperationalError: near "from": syntax error


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: DAL Limitations with aggregate and union queries

2012-02-10 Thread BrendanC
>>
 Here "*request*" is a user requesting a page, not your application making 
a query to the database.
>>

OK - now that clears up my confusion and it all makes sense- guess I was 
having a YASM (yet another senior moment) here. (So used to thinking in 
terms of http requests it's  easy to forget the important distinction here).

Thx again for your help.

BrendanC


[web2py] Re: Making Internationalization Easier

2012-02-10 Thread Mirek Zvolský
Of course I have interess for all what can improve internalization, because 
at this time it is not very clever.

Current problems:

1) No data  from where (in sources) the current string is. It would be nice 
to have inforrmation like "web2py core", "instantpress", "plugin xxx", "my 
application yyy". So it could be possible delate selected entries, copy 
selected entries to new application and so on.

2) If original developer changes a little the original text, earlier texts 
remain in the language table, but no longer in sources. So there is 
additional work when translating something what isn't longer in the 
sources. Some script, which can run over the language tables and mark 
records (=texts) no longer in sources would be nice.

3) One word in original language can have to different translations in 
other language, So something like "Edit//1", "Edit//2" which in original 
language displays as "Edit", but in target language can have 2 different 
texts would be nice.

However, this is more for core developers...


[web2py] Re: security check in web2py

2012-02-10 Thread Ross Peoples
Another option, which I use is to generate SSL certs and run web2py with -k 
and -c so that web2py runs on SSL, enabling admin from other computers.

[web2py] Re: security check in web2py

2012-02-10 Thread Massimo Di Pierro
Ciao Massimo,

You suggest you do not disable it. Instead run:

python web2py.py -i 10.0.1.7 -p 8080 -a ''
python web2py.py -i 127.0.0.1 -p 8081 -a xx

then connect to 8081 via ssl tunnel.

exposing admin without https is a major security risk. If you really
want to do, you can comment the check in applications/admin/models/
access.py.


On Feb 10, 11:47 am, Massimo Di Stefano 
wrote:
> i'm connected trough ssh to a remote linux box .. i started web2py by command 
> line using :
>
>  python web2py.py -i 10.0.1.7 -p 8080 -a xx
>
> if i go on the web page :
>
> http://myip:8080/welcome/default/index
>
>  i can access to the web2py main page, but if i try to login to the admin 
> interface i receive this message :
>
>  amministrazione disabilitata: comunicazione non sicura
>
> how can i avoid this security check ?
>
> can you point me to the doc section where i can learn more about it ?
>
> Many many thanks!!!
>
> --Massimo.


[web2py] security check in web2py

2012-02-10 Thread Massimo Di Stefano

i'm connected trough ssh to a remote linux box .. i started web2py by command 
line using : 

 python web2py.py -i 10.0.1.7 -p 8080 -a xx


if i go on the web page :

http://myip:8080/welcome/default/index 

 i can access to the web2py main page, but if i try to login to the admin 
interface i receive this message : 

 amministrazione disabilitata: comunicazione non sicura

how can i avoid this security check ?

can you point me to the doc section where i can learn more about it ?

Many many thanks!!!

--Massimo.



Re: [web2py] Re: Making Internationalization Easier

2012-02-10 Thread Niphlod
no problem. just for the record, in the admin app the vertical length of 
the page would be a minor problem for me if the untranslated strings showed 
before/after the yet translated ones ... 1200 strings before, add a 
controller, 1250 strings after, also if they are highlighted it's heavy to 
scroll all over the place :D

Putting them on db will allow also ordering on "creation" time, so last 
added strings will be optionally shown before othersI think that for 
medium-to-big projects this "project" would be a very nice addition, both 
as a separate app (accessing other app languages files asynchronously), 
module (accessing only the app it's installed into) and maybe finally 
integrated into admin.


Re: [web2py] Re: Questions on the scheduler

2012-02-10 Thread Vinicius Assef
Yet on schedules, if my task failed or timed out, will web2py try to
run it next time?



On Fri, Feb 10, 2012 at 3:39 PM, Massimo Di Pierro
 wrote:
> Not sure I understand. You do not call scheduled_workers functions.
> You schedule tasks. Workers pick them up from queue an execute them
> using the available power.
>
> On Feb 10, 4:54 am, blackthorne  wrote:
>> - Is it possible to call scheduled_workers functions asynchronously?
>> How?
>> - How should I adapt the behavior of a scheduled_worker as changing
>> its model and adding new functionality?
>>
>> Thank you


Re: [web2py] Re: DAL Limitations with aggregate and union queries

2012-02-10 Thread Niphlod
@mcm : I was replying to BrendanC.

On cluster indexes: retried, getting slighly better resultsthis timings 
don't get into account the actual "CLUSTER" operation, only the queries 
fired after having the table reindexed.

method1 : 20.4900407235 
method2 : 4.55434324348 
method3 : 5.32198321083 

Short version of "normal vs clustered indexes" debate... they are present 
on a number of "production ready" engines ... all implementions are a 
little different, but the principles remains the same. Please don't come up 
with "but db x instead does that", I'm trying to explain only the key 
points.

When you create an index on a column (let's take the case of a single 
column, the same thing goes for multiple columns in the same index) an 
"external" resource (take that as an external "file") is created, sorted, 
with pointers to the original row in the table. 
When you insert a record, the table gets updated and the column value along 
with the row pointer is "inserted" into the "external" resource. The 
external resource should be immediately resorted, but in real world that 
operation is fired looking at db stats and various tuning parameters (e.g. 
re-sort the index only if the order of the resultset vs the phisical order 
of records is inconsistent for the 20% part)

if you create an index with all the table columns you'll end up with a 
bigger "external" file than the one actually storing the table. Obviously 
this is useless, but there are situations where you have a table with 10 
columns, and you need to access them filtering or ordering on 2-3 columns 
differently: you then create several indexes ( index1 on columns 1,2,3 , 
index2 on columns 4,5,6, etc) and you end up having external "indexes" for 
that tables that summed up take more space than the table 
itself...Generally the single index is smaller than the table, yet 
sorted and then faster to "scan". 
In advanced setups, indexes files and table files are stored in different 
disks, preferring to place the indexes on the faster device available.

Clustered indexes instead "force" the records in the table to be phisically 
rearranged in the "table file". Queries on clustered indexes are generally 
faster, because the db can access the table sequentially and doesn't have 
to check first the "external file" and then the table one.
However, they were created for two main reasons:
- save space (clustered indexes don't require additional space or very 
little)
- to speed up access when the table is read-intensive but not 
write-intensive

For the intrinsic nature of the clustered index, when a row is updated on 
the column that carries a clustered index, the entire table should be 
rearranged, and as my knowledge in all the dbs this is a blocking 
operation. DBs normally don't do that, for performance reasons: you issue a 
CLUSTER index, table gets blocked, phisically rearranged, and that's it. 
When you update or insert new records, they are normally appended to the 
table. If you want your "new" records to be phisically rearranged, you 
issue another CLUSTER operation.

Also, you can't get consistent timings on a CLUSTER operation: the length 
of the operation, given that there are no other queries currently involved 
that block the process, take a "proportional time" to the actual 
"adiacency" of the records in the table:

table1
idnamesalary
1 jim4
2 john  5
3 ed 6

table2
idnamesalary
1 jim4
2 john  6
3 ed 5

issuing a clustered index on salary on table1 will take less time than 
issuing the same cluster index on table2 it has little meaning 
measuring the creation of the index.

You can't then think to issue a CLUSTER before every query: usually you 
"plan" to rearrange indexes at specific times or when a certain % of sorted 
records are no more phisically adiacent, basing your decision on the 
"degrading" statistics of your query: the more records are changed since 
the CLUSTER operation, the more the queries will be slower. You should 
balance the time that takes to issue a CLUSTER operation vs the degrading 
timings of your queries, minding that when you issue a CLUSTER index, noone 
will access that table for the entire time of the phisical rearrangement.

Clustered indexes are a great thing for gigantic tables with millions of 
records accessed for the 90% of the time with "ORDER BY" queries, tables 
that are not write-intensive.

Consider also that, for example, you want to cluster on a "created_on" 
field (datetime), but there is a column, let's say "active" (boolean) you 
filter with, with no other indexes.

e.g. SELECT * from table where active = True ORDER BY created_on

That query is going to perform badly if "active=True" records are a small 
part of the table anyway. A full scan of the table will be required anyway, 
and the corresponding sort will benefit just a small amount with the 
cluster index in place on created_on.

Again, for any fur

[web2py] Re: Questions on the scheduler

2012-02-10 Thread Massimo Di Pierro
Not sure I understand. You do not call scheduled_workers functions.
You schedule tasks. Workers pick them up from queue an execute them
using the available power.

On Feb 10, 4:54 am, blackthorne  wrote:
> - Is it possible to call scheduled_workers functions asynchronously?
> How?
> - How should I adapt the behavior of a scheduled_worker as changing
> its model and adding new functionality?
>
> Thank you


[web2py] Re: Issue 651: strange events behaviors for grid and smartgrid

2012-02-10 Thread Massimo Di Pierro
SQLFORM.grid has ondelete, SQLFORM(...).accept(...) does not. The book
is correct.

The problem is that grid uses ondelete when doing ajax delete but not
when using SQLFORM(...).accept(...)

On Feb 10, 4:03 am, Manuele Pesenti  wrote:
> I post here this discussion because I'm not yet subscribed to the
> developers list and this regards the documentation...
>
> Il 09/02/2012 18:55, Massimo Di Pierro ha scritto:
>
> > this is a good point. The problem is how to fix it.
>
> > sqlhtml does not take a ondelete (perhaps it should, and grid should
> > pass it to it).
>
> in this case I think there's a bug or a not complete information in the
> book? Or maybe it's my misunderstanding..
>
> citing 
> fromhttp://web2py.com/books/default/chapter/29/7#SQLFORM.grid-and-SQLFORM...)
>
> The complete signature for the grid is the following:
>
> SQLFORM.grid(query,
>               ...
>               onvalidation=None,
>               oncreate=None,
>               onupdate=None,
>               ondelete=None,
>               ...
>
>
>
>
>
>
>
>
>
> > ad it is grid takes a ondelete(table,record) and not a ondelete() as
> > in the example in the issue. This is because it is used (or it is
> > supposed to be used) in the ajax delete callback and therefore there
> > is no form.
> > This means we cannot pass grid(...ondelete...) to
> > form.accept(...ondelete...) because the latter does not exist and the
> > format would be incompatible anyway.
>
> > proposal for a solution?


Re: [web2py] Re: Folder inside controller dosen't work.

2012-02-10 Thread Jonathan Lundell
On Feb 10, 2012, at 4:57 AM, Phyo Arkar wrote:

> On one application , i have 20 JSON RPC methods , separated by each 
> controller. It going to be more than 100 JSORPC methods within 1 year for 
> whole project. 
> 

Out of curiosity: why only one method per controller?

Re: [web2py] Re: Making Internationalization Easier

2012-02-10 Thread Bruce Wade
You make a good point on the ~1200 strings. The language files are just
python dictionaries, so I don't see any reason why we can't provide paging
so make the file easier to work with.

Sure if you would like to help the more people the better as I think
everyone using web2py would benefit from this. I will create a repository
for an example app we can all work from.

--
Regards,
Bruce

On Fri, Feb 10, 2012 at 8:50 AM, Niphlod  wrote:

> uhm, could be interesting. I myself have some problems updating the
> language of an application that has ~1200 strings with the normal admin
> page.
>
> Having them inside a db would be useful but I don't think I'll use the
> "translate directly on the site" feature  I placed some T()s inside
> javascript function and it could be messy with those :D Also, maybe a
> string found in the template can be "rearranged" by some javascript in the
> DOM... total mess there ;-P
>
> I was thinking about keeping record of the location where T() was found to
> facilitate keeping track of all the various translated strings (controller,
> modules, views, models, etc), then display the results to willing users.
>
> Right now it comes to mind that a "recommended translation" system would
> be useful let's say I don't know Spanish, but my users do. Once 10
> different users report the same translation for the same string, that is
> "accepted" as the right translation for that string.
>
> This module will serialize back to languages/*.py files the saved results
> (maybe a function accessible only from admin people)?
>
> If you need any help I'd be glad to partecipate
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: trying itemize1... code on shell - solved

2012-02-10 Thread Bill Thayer
I needed to put:
>>>print itemize1('www.google.com')

I forgot the print command.


Re: [web2py] Re: Folder inside controller dosen't work.

2012-02-10 Thread Phyo Arkar
>
>  but this project which i doing alone now , with a team with different
> people , which going to grow soon to 15 members thats become big problem.

* correction *  Which i was doing alone "Before" , now I am with a team of
different programming background.

On Fri, Feb 10, 2012 at 7:27 PM, Phyo Arkar wrote:

> ofcoz i put all the reusable code inside modules and such. and most are
> object oriented.
>
> But that is not a choice WHEN you want to separate Controllers thats going
> to serve ONLY JSONRPC and  controller for HTML only.Folder becomes only
> necessary choice.
>
>
> On one application , i have 20 JSON RPC methods , separated by each
> controller. It going to be more than 100 JSORPC methods within 1 year for
> whole project.
> I do not want to Trow away web2py due to such small problem , but this
> project which i doing alone now , with a team with different people , which
> going to grow soon to 15 members thats become big problem.
> Thats where code management hell kicks in.
> I cant tell them to just "Separate all JSONRPC services inside a folder"
> and "Call from there , so it make it easy to debug!" .
>
>
>
>
>
> On Thu, Feb 9, 2012 at 9:11 PM, Ross Peoples wrote:
>
>> Not sure on the subfolder thing, but is it possible for you to put most
>> of your code into modules and just use controllers as the gateway to your
>> modules?
>
>
>


[web2py] Re: Making Internationalization Easier

2012-02-10 Thread Niphlod
uhm, could be interesting. I myself have some problems updating the 
language of an application that has ~1200 strings with the normal admin 
page.

Having them inside a db would be useful but I don't think I'll use the 
"translate directly on the site" feature  I placed some T()s inside 
javascript function and it could be messy with those :D Also, maybe a 
string found in the template can be "rearranged" by some javascript in the 
DOM... total mess there ;-P

I was thinking about keeping record of the location where T() was found to 
facilitate keeping track of all the various translated strings (controller, 
modules, views, models, etc), then display the results to willing users.

Right now it comes to mind that a "recommended translation" system would be 
useful let's say I don't know Spanish, but my users do. Once 10 
different users report the same translation for the same string, that is 
"accepted" as the right translation for that string.

This module will serialize back to languages/*.py files the saved results 
(maybe a function accessible only from admin people)?

If you need any help I'd be glad to partecipate


Re: [web2py] Re: Computed Fields broken by 1.99.2

2012-02-10 Thread Richard Vézina
I just want to report here about this thread that it seems that computed
field has to be set to readable and writable = True to make the computed
field to be effectively computed on form submit. Computed field won't
appears in form but will be computed. If not readable and writable True (I
didn't test with only one of both paramaters, maybe only readable or
writable True is enough) it will prevent the lambda to execute doesn't
matter if all the fields required by the compute lambda are available to it.

Hope it could help other to better figure out how computed field works...

I think book should be clearer about that, except if it's not the proper
wait it should work...

This is at least true for me under web2py 1.99.4

Richard

On Fri, Jan 13, 2012 at 8:50 AM, Alan Etkin  wrote:

> I think I was able to define readable auto computeable fields (fields
> were able to re-compute themselves on insert or update, at least with
> Sqlite) in the past. This is no longer supported (of course, if former
> versions did)?
>
> On 17 nov 2011, 11:25, David Manns  wrote:
> > I have finally figured out the cause of my problem, though not why
> > there was inconsistency in behavior with somecomputedfields updating
> > and others not.  I was putting writable=false and readable=false on
> > thecomputedfields in my model.  I'm not sure why I thought this was
> > correct usage; it makes sense that readable=false might be needed to
> > prevent thefieldfrom being displayed in forms, but given that the
> > form won't show thefield, writable=false would be unnecessary.
> > It seems that neither writable=false nor readable=false is needed
> forcomputedfields, they appear to be automatically not displayed in
> > SQLFORM andCRUD.  Readable=false causes no harm but writable=false
> > *MAY* cause thefieldto not be recomputed on update, though it will
> > becomputedon record creation.  This behavior is still present in the
> > nightly build.
> > The book could use some clarification in this area!
> > David
> >
> > On Nov 17, 1:50 am, Massimo Di Pierro 
> > wrote:
> >
> > > I believe this is a bug and it has already been fixed in trunk and
> > > nightly build. can you confirm?
> >
> > > On Nov 16, 8:23 pm, Anthony  wrote:
> >
> > > > On Wednesday, November 16, 2011 8:39:54 PM UTC-5, David Manns wrote:
> >
> > > > > This is all very alarming in a framework which boasts of "always
> > > > > maintaining backward compatibility" - quote taken from the preface
> of
> > > > > "the book".
> >
> > > > The intention was certainly not to break backward compatibility. If
> > > > something isn't working the same, it's a bug, not a backward
> compatibility
> > > > violation (unless, of course, the original behavior was a bug and was
> > > > simply being fixed). It's always a good idea to test upgrades before
> > > > deploying to production, and if you find bugs, report them -- they
> will
> > > > usually be fixed very quickly. Even better, test out the nightly
> builds or
> > > > trunk from time to time, and report bugs before they make it into
> stable
> > > > releases.
> >
> > > > Anthony
> >
> >
>


[web2py] trying itemize1... code on shell

2012-02-10 Thread Bill Thayer
While reading the web2pybook on page 
http://web2py.com/books/default/chapter/29/5 in the def...return chapter I 
tried to enter the code into the images shell controller 
(http://127.0.0.1:8000/admin/shell/index/images) to kind of test out both 
the code and using the shell.

I copied this into the shell from the book:
>>>def itemize1(link): return LI(A(link, _href="http://"; + link))

the shell returned, "web2py Shell (1, 99, 4, datetime.datetime(2011, 12, 
14, 14, 46, 14), 'stable')In [1] : def itemize1(link): return LI(A(link, 
_href="http://"; + link))"

I did it again and got, "In [2] : def itemize1(link): return LI(A(link, 
_href="http://"; + link))"

There's an error somewhere that's not getting returned an recorded.

Trying
>>>itemize1('www.google.com')


*returns nothing.*

[web2py] Re: Implementing task queue using web2py

2012-02-10 Thread howesc
some questions/thoughts:

 - local test server or production?
 - did you check the task queue?  in production go to the admin console and 
find the task queues link.  in local test go to /_ah/admin and find the 
task queue link
 - is params a required argument to taskqueue.add()?  i don't know if i 
always use it cause i need it or cause it is required.



[web2py] Re: Implementing task queue using web2py

2012-02-10 Thread Wikus van de Merwe
Check the app engine requests log to make sure the right task URL is being 
used.


[web2py] Re: Modules: how to access db

2012-02-10 Thread Sathvik Ponangi
Instead of using gluon, I pass it while importing the module.
For example, if my module is commons, then in my controller:

import commons
commons.db = db
commons.request = request
commons.session = session


Now db , request and session should now be available in the module...


[web2py] Making Internationalization Easier

2012-02-10 Thread Bruce Wade
Hello,

I am working on a module for my current site that will make doing
internationalization easier for non-technical people. Primary reason the
current site will be translated into 5 different languages to start and the
people doing the translations are not very good with technology to some
extent.

If anyone is interested in having this once I am done let me know.

Features:
 1) Languages table in the database, which stores the language code and
language name
 2) When a new language is created, the app searches the languages
directory for a file with the language code as a name, if it isn't found it
creates the file
 3) A language parser/editor. When live translations is enabled, any text
on the website created with T("") gets a special javascript function.
   When clicking on the text a dialogue box opens with language selections
and the text for the selected language showing. The text showing is parsed
from the language file.
   When the text is updated the parser also updates the language file.
Unless it is English we would have to do something else so all other
language files are updated, still thinking on this one.
4) The dialogue would use ajax to load the text for the selected language.

1, 2, and 4 will be easy step 3 is going to be a little tricky when saving.

If anyone has any suggestions let me know.

-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Support for PyPy

2012-02-10 Thread Sathvik Ponangi
Is there some way to run Web2Py on PyPy ?

[web2py] Re: Update legacy table using primarykey failed

2012-02-10 Thread Omi Chiba
I'm not sure this happen for postgres but I think it's a bug.
I submit the issue #656.

http://code.google.com/p/web2py/issues/detail?id=656


On Feb 9, 1:58 pm, Niphlod  wrote:
> that seems a float vs decimal problem
>
> bottom line, I didn't get  what is not working right now ?
>
> PS: post table definition in "raw sql", model of the table as in the
> models.py, and controller, so I can at least try to reproduce with sqlite
> or postgres (again, sorry but I don't have DB2 or MSSQL test db available)


[web2py] Re: Web2py session has me really confused now

2012-02-10 Thread Cliff
Anthony, thank you.

I get it now.  I somehow thought these two are equivalent:

session[request.controller].something = 'foo'
session[request.controller]['something'] = 'foo'

Obviously they aren't.

On Feb 10, 8:41 am, Anthony  wrote:
> > # I think this should work:
> > if 'column_select_value' in session[request.controller].keys():
> >         column_select_value =
> > session[request.controller].column_select_value
>
> > # But I get this:
> > AttributeError: 'dict' object has no attribute 'column_select_value'
>
> In Python, you cannot access dict items that way -- it would have to be:
>
> session[request.controller]['column_select_value']
>
> Or you could do:
> from gluon.storage import Storage
> session[request.controller] = Storage()
>
> Then you can use session[request.controller].column_select_value, and you
> don't even have to test whether "column_select_value" is one of the keys --
> Storage objects simply return None when you try to access a key that
> doesn't exist.
>
> Also, side note -- with a Python dict, instead of "if 'mykey' in
> mydict.keys()" you can just do "if 'mykey' in mydict".
>
> Anthony


[web2py] Re: best way to fetch data from multiple tables?

2012-02-10 Thread Omi Chiba
Sorry, I forgot GAE doesn't support Join. I can't think of any other
way except your original one. I heard now mysql is available on GAE.
Maybe you can try if the support join ?

http://googleappengine.blogspot.com/2011/10/google-cloud-sql-your-database-in-cloud.html

On Feb 10, 6:10 am, Saurabh S  wrote:
> Omi, We tried the solution that you have mentioned using join provided
> by web2py, it works fine on local server.
>
> But when we run it in google appengine sandbox or deploy it using
> google app engine it gives the error "Too many tables in the query".
> Is there a solution to resolve this? Is there any other way of
> implementing joins on google app engine which increases the
> performance?
>
> On Feb 9, 8:25 pm, Omi Chiba  wrote:
>
>
>
>
>
>
>
> > > Also will it possible for me put filters on table 1(say Employees) and> 
> > > then perform join with othertables?
>
> > I'm not sure. I think it's more like join then filter.
> > Something like below...
>
> > query = (db.person.id==db.dog.owner) & (db.person.name.like('Omi%'))
> > rows = db(query).select()
>
> > On Feb 9, 8:53 am, Sonal_b  wrote:
>
> > > Thanks Omi.
>
> > > I will give it a try.
>
> > > Also will it possible for me put filters on table 1(say Employees) and
> > > then perform join with othertables?
>
> > > On Feb 9, 7:34 pm, Omi Chiba  wrote:
>
> > > > Sound like you're looping all the records to connect different table.
> > > > I use join for the purpose and working fine though I only have about
> > > > 1 records.
>
> > > >http://www.web2py.com/books/default/chapter/29/6?search=join#Inner-joins
>
> > > > On Feb 9, 8:19 am, Sonal_b  wrote:
>
> > > > > I have to query 3tableswhich contains large number ofdata
>
> > > > > I have to come up with report which displays
>
> > > > > Employee Firstname, Lastname, Manager's FirstName, Manager's Lastname
> > > > > and Organisation name.
>
> > > > > Table Structure/Details:
>
> > > > > 1. Employee table: which contains employee information(First name,
> > > > > lastname), Organisation id and manager's id.
> > > > > 2. Manager Table: Which contains firstname, lastname etc.
> > > > > 3. Organisation table: which contains organisation's name.
>
> > > > > The process i follow is:
> > > > > 1.Fetchall the employees
> > > > >    1.a for each employee get the manager id
> > > > >        1.b  For the manager id get the manager's firstname and
> > > > > lastname by querying the Manager table
> > > > >     1.c for each employee get the organisation id
> > > > >      1.d For each organisation id get the Organisation name by
> > > > > querying the Organisation table.
>
> > > > > When I try tofetchthe records from 3tablesfollowing the above
> > > > > approach, I get deadlineexceedederror as my request could not complete
> > > > > in 30 seconds time.
>
> > > > > Please suggest a betterwayto do this. Also what should i use which
> > > > > can improve performance and also get me the result in the 30 second
> > > > > timeframe.


Re: [web2py] Re: DAL Limitations with aggregate and union queries

2012-02-10 Thread Michele Comitini
Niphold,

Thanks for the reply.

My first question is about this:
http://www.postgresql.org/docs/8.1/static/sql-cluster.html.  Sorry if
I did not explicit about what I was referring, as it is postgresql
specific.  I was wondering if you would see different figures or not,
because order by is influenced by index clustering (i.e. a presorted
table around that index).

My interest is about the high initial step in postgresql response,
i.e. the response seems a function of  the number of records + an
initial offset.
I was wondering if it was something related to connection and remote
backend initialization.

How the dal pooling works is known to me in depth, due to the fact
that I contributed fix some little bugs there.
Roundtrip of queries are clear to me.
Before psycopg2 there was a psycopg1:  the base of code was written by
me, so I suppose I have done my homework understanding how postgresql
connections work.

mic




2012/2/10 Niphlod :
> just take a look to
> http://web2py.com/book/default/chapter/06#Connection-pooling for
> understanding how DAL handles connections.
>
> Your initial question was a concern on speed on aggregate and unions, and
> the script you provided clearly use one and only one db connection.
>
> I'm sorry if I misunderstood, but having to "aggregate" or "union" involved
> in a query to fetch/show results involves anyway one and only one db
> connections.
>
> I stated (and tested) that the difference in making 2 distinct queries and
> retrieve the results against making one query that returns similar results
> is negligible in this case.
>
> The "two queries" method involves clearly two "roundtrips" to the database,
> but on the same connection.
>
> When you use web2py, you can rely on "pool_size" parameter (as explained
> into the book) to avoid making and closing a connection for every request.
> Here "request" is a user requesting a page, not your application making a
> query to the database. You could do
>
> def index():
>     for a in range(1000):
>     result = db(db.emp.id>0).select()
>
> in one controller. What will be the behaviour ? User request the "index"
> page, DAL istantiate a new connection, DAL make 1000 queries to the db using
> the same connection.
>
> If you use no "pool_size", then every time a user request the "index" page,
> the DAL will instantiate a new connection, make 1000 queries, and close the
> connection.
> If you use the "pool_size" parameter, then the DAL fetch a connection from
> the pool, make 1000 queries, and put the connection back into the pool,
> ready to be used in subsequent requests of users going to the "index" page.
>
> I hope I cleared all your doubts, if not, please ask :D
>
>


Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1

2012-02-10 Thread Wikus van de Merwe
With web2py being licensed under LGPL it is possible to build applications 
which are proprietary software. To some degree it is even possible to build 
another web framework that uses unchanged web2py code as back-end. In 
practice, however, the latter is too complicated on a technical level. The 
most common case, direct modification to the framework, have to be covered 
by LGPL or GPL, so you cannot make a proprietary fork.

However, it is possible to create a a proprietary fork in the software as 
service model. So you can imagine web applications running on a fine tuned 
version of web2py while this tuning remains secret. Same thing may happen 
to Movuca if it is not licensed under AGPL. Somebody can take the code, 
make improvements and run it on a server without offering either binaries 
or code to her clients. Just the service. Free software movement sees that 
as unethical. You benefit from the community code, but your code is not 
shared back with community. With a rise of the cloud platforms this becomes 
more and more relevant problem and pose a risk to the free software. It is 
yet another way of circumventing the GPL and changing the free code into a 
proprietary one (there were others in the past that have been stopped by 
GPLv3 e.g. tivoization).

As Mariano already pointed out, in case of web applications, the LGPL does 
have much sense as it is equivalent in this context to the GPL. And is 
always best to minimize confusion and use one of well known licenses rather 
than creating your own. So as long as you do not see proprietary forks 
behind server deployments as a problem, the best choice for Movuca is GPLv3.


Re: [web2py] Re: Advice please: best way to count records?

2012-02-10 Thread Richard Vézina
Done : Issue 655 :Adding
cache argument to .count()

Richard

On Fri, Feb 10, 2012 at 12:02 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> open a ticket. this should be added
>
> On Feb 9, 11:42 am, Richard Vézina 
> wrote:
> > Is it just me ?
> >
> > db(query).count(cache=(cache.ram, 60))
> >
> > Won't work...
> >
> > I get :
> >
> > TypeError: count() got an unexpected keyword argument 'cache'
> >
> > Richard
> >
> >
> >
> >
> >
> >
> >
> > On Thu, Feb 9, 2012 at 9:44 AM, Anthony  wrote:
> > > I can think of two ways to do it, but I don't like either one.  First
> > >> is to formulate the query without the limitby clause and do a
> > >> db(query).count().  That would give me the total number of records in
> > >> the set.  Then add the limitby clause to the query to get the records
> > >> of interest.
> >
> > > FYI, I think this is how SQLFORM.grid does it.
> >
> > > Anthony
>


[web2py] Re: Web2py session has me really confused now

2012-02-10 Thread Anthony

>
> # I think this should work: 
> if 'column_select_value' in session[request.controller].keys(): 
> column_select_value = 
> session[request.controller].column_select_value 
>
> # But I get this: 
> AttributeError: 'dict' object has no attribute 'column_select_value'
>

In Python, you cannot access dict items that way -- it would have to be:

session[request.controller]['column_select_value']

Or you could do:
from gluon.storage import Storage
session[request.controller] = Storage()

Then you can use session[request.controller].column_select_value, and you 
don't even have to test whether "column_select_value" is one of the keys -- 
Storage objects simply return None when you try to access a key that 
doesn't exist.

Also, side note -- with a Python dict, instead of "if 'mykey' in 
mydict.keys()" you can just do "if 'mykey' in mydict".

Anthony



[web2py] Web2py session has me really confused now

2012-02-10 Thread Cliff
Help me understand.

session[request.controller] = {} # This works great

# Raises an exception unless foo is already an attribute of
session[request.controller]
bar = session[request.controller].foo
AttributeError: 'dict' object has no attribute 'foo' # Okay, makes
sense

# I think this should work:
if 'column_select_value' in session[request.controller].keys():
column_select_value =
session[request.controller].column_select_value

# But I get this:
AttributeError: 'dict' object has no attribute 'column_select_value'

Can anybody explain what is going on here?

Should I do something not beautiful like this?
Try:
  column_select_value =
session[request.controller].column_select_value
Except:
  pass


[web2py] Re: DAL Limitations with aggregate and union queries

2012-02-10 Thread Niphlod
just take a look to 
http://web2py.com/book/default/chapter/06#Connection-pooling for 
understanding how DAL handles connections.

Your initial question was a concern on speed on aggregate and unions, and 
the script you provided clearly use one and only one db connection.

I'm sorry if I misunderstood, but having to "aggregate" or "union" involved 
in a query to fetch/show results involves anyway one and only one db 
connections.

I stated (and tested) that the difference in making 2 distinct queries and 
retrieve the results against making one query that returns similar results 
is negligible in this case.

The "two queries" method involves clearly two "roundtrips" to the database, 
but on the same connection.

When you use web2py, you can rely on "pool_size" parameter (as explained 
into the book) to avoid making and closing a connection for every request. 
Here "*request*" is a user requesting a page, not your application making a 
query to the database. You could do

def index():
for a in range(1000):
result = db(db.emp.id>0).select()

in one controller. What will be the behaviour ? User request the "index" 
page, DAL istantiate a new connection, DAL make 1000 queries to the db 
using the same connection.

If you use no "pool_size", then every time a user request the "index" page, 
the DAL will instantiate a new connection, make 1000 queries, and close the 
connection.
If you use the "pool_size" parameter, then the DAL fetch a connection from 
the pool, make 1000 queries, and put the connection back into the pool, 
ready to be used in subsequent requests of users going to the "index" page.

I hope I cleared all your doubts, if not, please ask :D 




Re: [web2py] Re: Folder inside controller dosen't work.

2012-02-10 Thread Phyo Arkar
ofcoz i put all the reusable code inside modules and such. and most are
object oriented.

But that is not a choice WHEN you want to separate Controllers thats going
to serve ONLY JSONRPC and  controller for HTML only.Folder becomes only
necessary choice.


On one application , i have 20 JSON RPC methods , separated by each
controller. It going to be more than 100 JSORPC methods within 1 year for
whole project.
I do not want to Trow away web2py due to such small problem , but this
project which i doing alone now , with a team with different people , which
going to grow soon to 15 members thats become big problem.
Thats where code management hell kicks in.
I cant tell them to just "Separate all JSONRPC services inside a folder"
and "Call from there , so it make it easy to debug!" .





On Thu, Feb 9, 2012 at 9:11 PM, Ross Peoples  wrote:

> Not sure on the subfolder thing, but is it possible for you to put most of
> your code into modules and just use controllers as the gateway to your
> modules?


Re: [web2py] Re: DAL Limitations with aggregate and union queries

2012-02-10 Thread Michele Comitini
Niphlod,

Just out of curiosity.
Is the dal connection pooled?
If in postgres you CLUSTER on the salary index do figures change?

mic

2012/2/10 BrendanC :
> Niphlod,
> Thanks (belatedly) for your valuable  contribution and  your test results.
>  The only thing missing from your test is contention for database
> resources/connections and that is what prompted my initial question. In the
> past I worked on a client server application where we had performance issues
> re  getting and releasing database connections (this was against a heavily
> used clinical trials Oracle database).
>
> I'm very clear on the value of adding indexes to the database - however that
> is a bit tangential to my initial question - which was primarily focused on
> understanding the limitations/boundaries of using the DAL and connection
> management.
>
> I'm curious about your statement that the DAL will always use the same
> connection. My understanding is that the DAL closes and reopens the database
> connection for each request.  Whether it's the same connection or not may
> not matter -  once you close a db connection it goes back into the pool and
> you may/may not incur a delay in opening new connection. (In a lightly
> loaded system you may never see this issue however).
>
> I was under the impression that minimizing db connections was desirable to
> prevent thrashing. In the real world this may no longer be an issue. I do
> however recall this being an issue in the past and it's something that is
> seldom mentioned in Web development.
>
> Finally, just so there is no confusion here - I'm not criticizing web2py or
> the DAL here - my question is equally valid for Rails, Django etc - afaik
> all these frameworks close and reopen connections for each request.
>
> Again thanks for your thoughtful response to my initial question.
>
> BrendanC
>
>


Re: [web2py] Re: Grid/Smartgrid: how to use the 'selectable' option?

2012-02-10 Thread Fabiano Faver
I had this same doubt and this thread have helped as there is no 
explanation on online book.
But I want to make the rows selectable to allow user to update all them 
toguether.

I have no clue how to edit the submit button that shows at the end of the 
table when selectable is active.
Any tips?


Re: [web2py] Re: Modules: how to access db

2012-02-10 Thread Michele Comitini
other ways to do it without using current.


in the module (ex. tools.py):

 def regte_verwysing(regte, tabel, veld, db):
 lys = db(db[tabel].article == regte).select(db[tabel][veld])
 verwysings = [x[veld] for x in lys]
 return verwysings

in the model (ex. db.py):

import tools.py
def regte_verwysing(regte, tabel, veld):
  return tools.regte_verwysing(regte, tabel, veld, db)


If you like closures.

in the module (ex. tools.py):

def regte_verwysing(db):
 def f(regte, tabel, veld):
 lys = db(db[tabel].article == regte).select(db[tabel][veld])
 verwysings = [x[veld] for x in lys]
 return verwysings
  return f

in the model (ex. db.py):

import tools.py
regte_verwysing = tools.regte_verwysing(db) #<- returns a callable
with args (regte, tabel, veld)

you can then call regte_verwysing(regte, tabel, veld) in your code

mic

2012/2/10 Johann Spies :
> On 9 February 2012 18:14, Bruno Rocha  wrote:
>>
>> I dont know exactly how it works, but I had problems serializing db in to
>> current, so Massimo said to always pass it explicitly to classes ad
>> functions, I remember that SQLITE worked, but not Postgres.
>
>
> Anthony's advice to me earlier in this thread is working with PostgreSQL:
>
> In db.py:
>
>
> from gluon import current
> current.db = db
>
> and in the module:
>
> from gluon import *
> def regte_verwysing(regte, tabel, veld):
>     db = current.db
>     lys = db(db[tabel].article == regte).select(db[tabel][veld])
>     verwysings = [x[veld] for x in lys]
>     return verwysings
>
> Regards
> Johann
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>


[web2py] Implementing task queue using web2py

2012-02-10 Thread Saurabh S
I have an application on google app engine.

I have used web2py framework to develop the application

I have a module in which I need to fetch the records from 3 tables and
the final set of records contain data from all the 3 tables.

Here each of my tables contain more than 1000 records so when I
implemented it, it started throwing "request time out error".

So I thought of implementing it using task queue.

While using task queue (push queue) . I have used the below code

def func():
from google.appengine.api import taskqueue
result=[]
if request.vars.download:
logging.info('Before task')
taskqueue.add(url=URL(r=request,c='abc',f='hello')) # abc is
the controller
logging.info('After Task')
return dict(result=result)

def hello():
logging.info('task queue implementation')
return

When I checked the log 'before task' and 'after task' info are present
but there is nothing logged in the log for hello function(where 'task
queue implementation' should have been present).

Please suggest if there is anything I need to add to this code to make
it work or If there is anything missing that I am unaware of.

Thanks


Re: [web2py] Re: Modules: how to access db

2012-02-10 Thread Johann Spies
On 9 February 2012 18:14, Bruno Rocha  wrote:

> I dont know exactly how it works, but I had problems serializing db in to
> current, so Massimo said to always pass it explicitly to classes ad
> functions, I remember that SQLITE worked, but not Postgres.


Anthony's advice to me earlier in this thread is working with PostgreSQL:

In db.py:

from gluon import current
current.db = db

and in the module:

from gluon import *
def regte_verwysing(regte, tabel, veld):
db = current.db
lys = db(db[tabel].article == regte).select(db[tabel][veld])
verwysings = [x[veld] for x in lys]
return verwysings

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


[web2py] Re: best way to fetch data from multiple tables?

2012-02-10 Thread Saurabh S
Omi, We tried the solution that you have mentioned using join provided
by web2py, it works fine on local server.

But when we run it in google appengine sandbox or deploy it using
google app engine it gives the error "Too many tables in the query".
Is there a solution to resolve this? Is there any other way of
implementing joins on google app engine which increases the
performance?


On Feb 9, 8:25 pm, Omi Chiba  wrote:
> > Also will it possible for me put filters on table 1(say Employees) and> 
> > then perform join with othertables?
>
> I'm not sure. I think it's more like join then filter.
> Something like below...
>
> query = (db.person.id==db.dog.owner) & (db.person.name.like('Omi%'))
> rows = db(query).select()
>
> On Feb 9, 8:53 am, Sonal_b  wrote:
>
>
>
> > Thanks Omi.
>
> > I will give it a try.
>
> > Also will it possible for me put filters on table 1(say Employees) and
> > then perform join with othertables?
>
> > On Feb 9, 7:34 pm, Omi Chiba  wrote:
>
> > > Sound like you're looping all the records to connect different table.
> > > I use join for the purpose and working fine though I only have about
> > > 1 records.
>
> > >http://www.web2py.com/books/default/chapter/29/6?search=join#Inner-joins
>
> > > On Feb 9, 8:19 am, Sonal_b  wrote:
>
> > > > I have to query 3tableswhich contains large number ofdata
>
> > > > I have to come up with report which displays
>
> > > > Employee Firstname, Lastname, Manager's FirstName, Manager's Lastname
> > > > and Organisation name.
>
> > > > Table Structure/Details:
>
> > > > 1. Employee table: which contains employee information(First name,
> > > > lastname), Organisation id and manager's id.
> > > > 2. Manager Table: Which contains firstname, lastname etc.
> > > > 3. Organisation table: which contains organisation's name.
>
> > > > The process i follow is:
> > > > 1.Fetchall the employees
> > > >    1.a for each employee get the manager id
> > > >        1.b  For the manager id get the manager's firstname and
> > > > lastname by querying the Manager table
> > > >     1.c for each employee get the organisation id
> > > >      1.d For each organisation id get the Organisation name by
> > > > querying the Organisation table.
>
> > > > When I try tofetchthe records from 3tablesfollowing the above
> > > > approach, I get deadlineexceedederror as my request could not complete
> > > > in 30 seconds time.
>
> > > > Please suggest a betterwayto do this. Also what should i use which
> > > > can improve performance and also get me the result in the 30 second
> > > > timeframe.


[web2py] Questions on the scheduler

2012-02-10 Thread blackthorne
- Is it possible to call scheduled_workers functions asynchronously?
How?
- How should I adapt the behavior of a scheduled_worker as changing
its model and adding new functionality?

Thank you


[web2py] Re: Issue 651: strange events behaviors for grid and smartgrid

2012-02-10 Thread Manuele Pesenti
I post here this discussion because I'm not yet subscribed to the 
developers list and this regards the documentation...


Il 09/02/2012 18:55, Massimo Di Pierro ha scritto:

this is a good point. The problem is how to fix it.

sqlhtml does not take a ondelete (perhaps it should, and grid should
pass it to it).


in this case I think there's a bug or a not complete information in the 
book? Or maybe it's my misunderstanding..


citing from
http://web2py.com/books/default/chapter/29/7#SQLFORM.grid-and-SQLFORM.smartgrid-(experimental)

The complete signature for the grid is the following:

SQLFORM.grid(query,
 ...
 onvalidation=None,
 oncreate=None,
 onupdate=None,
 ondelete=None,
 ...



ad it is grid takes a ondelete(table,record) and not a ondelete() as
in the example in the issue. This is because it is used (or it is
supposed to be used) in the ajax delete callback and therefore there
is no form.
This means we cannot pass grid(...ondelete...) to
form.accept(...ondelete...) because the latter does not exist and the
format would be incompatible anyway.

proposal for a solution?






[web2py] Re: DAL speed - an idea

2012-02-10 Thread Simon Lukell
+1
Having this option would make it really simple to change between the
full-blown DAL result set and a faster stripped down one (which could
then be adapted with the processor to keep the rest of the code
working.)

> I've been thinking about something like this as well. Instead of a separate
> select_raw() method, maybe we can just add a raw=True|False argument to the
> existing select() method.