[web2py] How to join data from several tables into one jqgrid?

2010-11-09 Thread Johann Spies
How do I provide a complex query  which selects data from varius
tables to jqgrid?

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge
of God and of Jesus our Lord!  His divine power has given us
everything we need for life and godliness through the full knowledge
of the one who called us by his own glory and excellence.
                                                    2 Pet. 1:2b,3a


Re: [web2py] Re: MARKMIN HELPER

2010-11-09 Thread Bruno Rocha
I am finishing a new project today, which every content is wrote in markmin
http://natalanimal.com.br/

This is a site of an animal protection association, which aims to raise
donations and sponsors to animals at Christmas.

I made it based on e-store, I am almost finishing some details.

Thank you Massimo!



2010/11/10 mdipierro 

> done
>
> On Nov 9, 11:21 pm, Bruno Rocha  wrote:
> > Minor suggestion for MARKMIN()
> >
> > If I am fetching the Markmin content from database, and database field is
> > empty (None), MARKMIN raises an error.
> >
> > I am solving this problem with :
> >
> > MARKMIN(myfield or ' ')
> >
> > But, I think MARKMIN can itself resolve what to do if the received arg is
> > NoneType)
> >
> >   File "/home/rochacbruno/webapps/natalanimal2/web2py/gluon/html.py",
> > line 1892, in xml
> > class MARKMIN(XmlComponent):
> >   File
> "/home/rochacbruno/webapps/natalanimal2/web2py/gluon/contrib/markmin/markmin2html.py",
> > line 317, in render
> > text = regex_dd.sub('``\g``:latex ',text)
> > TypeError: expected string or buffer
>



-- 

http://rochacbruno.com.br


[web2py] Re: MARKMIN HELPER

2010-11-09 Thread mdipierro
done

On Nov 9, 11:21 pm, Bruno Rocha  wrote:
> Minor suggestion for MARKMIN()
>
> If I am fetching the Markmin content from database, and database field is
> empty (None), MARKMIN raises an error.
>
> I am solving this problem with :
>
> MARKMIN(myfield or ' ')
>
> But, I think MARKMIN can itself resolve what to do if the received arg is
> NoneType)
>
>   File "/home/rochacbruno/webapps/natalanimal2/web2py/gluon/html.py",
> line 1892, in xml
>     class MARKMIN(XmlComponent):
>   File 
> "/home/rochacbruno/webapps/natalanimal2/web2py/gluon/contrib/markmin/markmin2html.py",
> line 317, in render
>     text = regex_dd.sub('``\g``:latex ',text)
> TypeError: expected string or buffer


[web2py] ssl and http web2py command line issues

2010-11-09 Thread Dave Johnson
If you start up web2py with key/cert for SSL, web2py runs in SSL mode.

In the startup message it says you can connect via http, but if you attempt
to connect via plain http, you will get a

"Bad Request"

in your browser.

[d...@thinkbox web2py]$ python web2py.py -c mycert.pem -k mycert.pem -i
192.168.1.119 -a hi
web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2010
Version 1.88.2 (2010-10-29 23:04:43)
Database drivers available: SQLite3
Starting hardcron...
please visit:
http://192.168.1.119:8000
use "kill -SIGTERM 30522" to shutdown the web2py server
=

Here are some thoughts:

* If not running SSL and you specified a non-loopback interface for web2py
to run on, the command line "should" warn about possible disablement of
admin site?

* Check that if you specify a cert on command line, you need to specify a
key (and vice-versa?)
  -- The command line silently "fails" (although there is checking in
main.py:)
if not ssl_certificate or not ssl_private_key:
  logger.info('SSL is off')

* Do a check that private key and cert match.

And now for the more interesting item, for some reason SSL connection still
works with the following cert private key (note:I zeroed out a line in my
private key!)
Am I missing something here...?


[d...@thinkbox web2py]$ cat mycert.pem
-BEGIN CERTIFICATE-
MIIDVzCCAj+gAwIBAgIJAKXRQfLWAi/BMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNV
BAYTAlhYMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1bHQg
Q29tcGFueSBMdGQwHhcNMTAxMDE2MjEyNTA1WhcNMTExMDE2MjEyNTA1WjBCMQsw
CQYDVQQGEwJYWDEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5MRwwGgYDVQQKDBNEZWZh
dWx0IENvbXBhbnkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
5TBJypoZfgg630Sx7olCd0PDNhx6dghffVecgW+1BkD7uAGbCaSXg7AgiwTNZJmw
VO6oiivRgaZi39XG7gy//2uxXcu7d116GkYTRxUSx845O8cCeQm0Kj/ucQ6IfheR
RTtVAUThBTKNEAtM6Mx6wGk3uHVktvh/MqTKhIvbuJmwj8BLB7w+d99tD4981Fhc
mvAYIGnf/0jOwG79LiG6DNIuQyPXnVUtf5S6pU2XaJwmUMy2kkhgowvIM33pNKLi
T0D7LjbvxlrcvfgwoH6GfCT38UX1oGyWJT45cFRiTSXBgxAHajlyM6r5YhTnFCmZ
hVjjGpXtQcQk9obCX6wI0wIDAQABo1AwTjAdBgNVHQ4EFgQULPMBvZYIXHsebZ+W
PpSjvxH2gjswHwYDVR0jBBgwFoAULPMBvZYIXHsebZ+WPpSjvxH2gjswDAYDVR0T
BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEARDXQp8o7aeoiYIsYbqHxpjRyDwDc
D0klMH86ToLY13ZSRJzk3WzXIqKnPAeae1IyZ66SH9PQU/u8vQLvvReapF1kiOnD
n6+knUad22olxLVXZ9thyB6NZco9Mh8q3jz27GtSXEQNaVwVQJ2IwsC5XUz1yKgz
ZJbeW8AdqP9PlacgowYPFMiWvOD1VzRKW5NY5TUKV3cE4JJCiWH0rx7t5GV8vuXM
xffdZpfUODI0YOxIGVJNwKf8SpMiahyvb4otFnzT3lBqPuyT2EEcqAt2MRsGI2R3
l/lUlt4IDxsN31BEKAySfUeDPqOKo0MyA2yZ0z85Lgsm5nVJm4NBt2B7tw==
-END CERTIFICATE-

[d...@thinkbox web2py]$ cat mybad.pem
-BEGIN RSA PRIVATE KEY-
MIIEowIBAAKCAQEA5TBJypoZfgg630Sx7olCd0PDNhx6dghffVecgW+1BkD7uAGb
CaSXg7AgiwTNZJmwVO6oiivRgaZi39XG7gy//2uxXcu7d116GkYTRxUSx845O8cC
eQm0Kj/ucQ6IfheRRTtVAUThBTKNEAtM6Mx6wGk3uHVktvh/MqTKhIvbuJmwj8BL
B7w+d99tD4981FhcmvAYIGnf/0jOwG79LiG6DNIuQyPXnVUtf5S6pU2XaJwmUMy2
kkhgowvIM33pNKLiT0D7LjbvxlrcvfgwoH6GfCT38UX1oGyWJT45cFRiTSXBgxAH
ajlyM6r5YhTnFCmZhVjjGpXtQcQk9obCX6wI0wIDAQABAoIBAASpX8bcLYqPtkrW
Rdw5NH3ihfTyzVbbQr306z0Cvabb6YLLnZCrpV1LVs4dEeRq79g6Znkw/PjrHnW5
DmvHHJygXyIuQ6jg4Nvp8vhuKEyiGC3sFVPK67w0QrBQAFy4M/85frgg44bMiWv7
HtxZVGHXggehc6P5F/U6vtfFVHnDtKX93g+NPOYpXQTcO30QftSvYqjgx/2wMhOk
ItIPOOrKWEwr6Ogjum+g/2u06JgD/vPBpR5Nurs0LUL6H1K50DDOPjlKAQ1LtIJe
qRw6PB4qMJWP9qTgkiDq98jKJ0zzDDvWjGhz5DqepK8+dyZqF6/1PPJxdE5l6K3I
AqeVQdkCgYEA9LboYrJpdBScz26I5Q5nL5+iwSvYNIlRLDocjfzrkeXicfTiCzim
TCHWgVzRL0E78TASELIvioeJ7unpk7a7KiacO2Cat/CwhfUE/aKkiSJbvw/BrmRU
PY8N65fVRc2UQK51FlulCjNG4TgbMJIQxmVS3zXPhdmr7GAWbyUWNhUCgYEA78IV
KSo/TqHRRdHzIQfRUNwmGH049/9wGBbkr67NfsNnv6nS+L81NBH+Ko1eMpZELLmt
OofIvuHpFMryMBJVAr8gOv7sPJQIGIwJxMcNMz1NyJSXoq4hXwXAA2Crpi1ODyj0
xdiOg47qRwuaYaVjILPqL73ne/vuJdOR2YxqJUcCgYEAxTjMXQ7Q8l7SalL5PTG4
c6dCclC1tNGee/hxnvVhnXoaYCEuNED5tY3n5OY7KMx4VM+bH52btxe5ULVwLD4u
5a+sZiZbSzdN7Qgld4ym8magboFyZOwzAFHUtDTwC4u9mcuATf6aKnhc/ZJMR37Q
yjRK793cXFGrv5tJOVY4amkCgYB61FyQ7VLnjuEuuuOrDV0/5rkhnK2d5+BehwP7
uTsP8T3qpC8wPo0cMweadzhGBFPC8hD8Rmoi2IvXmi0/UXT55j612rneQxxurvem
**
NZN/qwKBgAYFIvQswsUflJdpwgpDIcKtwhRJdXqU01v+NuJPDvv1n8/nWkpPNsq3
x7rWUsW+hflwxAh9W+l1fnPvo2m66Ega83H4CpJ/a8l306fpBqh/jB07cLfcl2T1
TfeiVQycQCVPlevvocnm5j2XCgT3Y0GHe6J5WiqyYCjrq6a/f55g
-END RSA PRIVATE KEY-


[web2py] Re: Selecting from dropdown using Ajax

2010-11-09 Thread Alex
You are definitely correct.  I mis-read what you had, but what I put
up, you can still use as well if you need to pass args via the URL.

In any case, if I am understanding this correctly, it seems to be more
of a problem of getting the selected value of the option, correct?

There are probably several ways to do this (I actually think jQuery
may provide an easy way to get at the selected option).  Off the top
of my head, this is probably what I would do:

  -  Create a hidden input variable in the form to hold the selected
value
  -  before the ajax call, populate the hidden input field with what
selected option's value

Something like this would need to be added to your code:

In the View:

  -  Add this onto your form:  
  -  Add this to the onChange event:  _onChange="$
('#hdnSel').val(this.value); ajax('test_chg',['hdnSel'],'target');",

What this does is on the onChange event, it will populate the hidden
input we added with the selected option's value.  This is then passed
through the AJAX call.  Hopefully this helps.  Let me know :)


On Nov 9, 8:28 pm, oneroler  wrote:
> Alex,
>
> Thanks.  I thought based on the book that the 2nd argument of ajax was
> passing the values to request.vars.variable.  I pasted some of the
> code from the book below for reference (http://web2py.com/book/default/
> chapter/10?search=ajax#The-ajax-Function).  Based on this I originally
> had the code below in test_chg.  Am I mistaken about what the 2nd
> argument is?  Also, regarding your suggestion, could you tell me how
> to identify the selected item so that I can pass as an args/vars in
> the URL as you recommended?
>
> def one():
>     return dict()
>
> def echo():
>     return request.vars.name
>
> {{extend 'layout.html'}}
> 
>    
> 
> 
>
> def test_chg
> firm=request.vars.firmdrop
> strats = db(db.firmstrat.firm_id==firm).select()
> options=[]
> for strat in strats:
>     options.append(strat.strat_id.name)
> return DIV(*options).xml()
>
> On Nov 8, 9:37 pm, Alex  wrote:
>
>
>
> > How are you passing the value in the request.vars?
>
> > I'm going to guess that on your AJAX call in the _onChange handler,
> > you want to specify the parameters.  You can do something like:
>
> >   - ajax( '{{=URL(c='controllerName',f='test_chg',
> > args=request.args(0))}}', ['firmdrop'],'target' )
>
> > You can pass whatever you want in args.  If you have values in
> > request.vars, you should be able to access then like:
>
> >  -  request.vars.variableName
>
> > On Nov 7, 9:11 pm, oneroler  wrote:
>
> > > I'm trying to learn to use the ajax functionality and am having
> > > trouble getting it to work correctly.  I am trying to use a dropdown
> > > of firms to show the related strategies.  Currently this doesn't
> > > return anything to the div, but I do know that the onchange is
> > > working.  It seems like the request.vars.values()[0] is not returning
> > > anything.  Any help would be appreciated and also any pointers if
> > > there is a way to do this better differently.  Below is my code.
>
> > > I have based this on this 
> > > messagehttp://groups.google.com/group/web2py/browse_thread/thread/4a6149ddcb
>
> > > <>
> > > def test():
> > >     firms = db(db.firm).select()
> > >     return dict(firms=firms)
>
> > > def test_chg():
> > >     firm=request.vars.values()[0]
> > >     strats = db(db.firmstrat.firm_id==firm).select()
> > >     options=[]
> > >     for strat in strats:
> > >         options.append(strat.strat_id.name)
> > >     return DIV(*options).xml()
>
> > > <>
> > > {{extend 'layout.html'}}
> > > {{=SELECT(_id='firmdrop',
> > >     _onChange="ajax('test_chg',['firmdrop'],'target');",
> > >     *[OPTION(firms[i].name,_value=str(firms[i].id)) for i in
> > > range(len(firms))]
> > >     )}}
> > > 
>
> > > Thanks,
> > > Sam- Hide quoted text -
>
> - Show quoted text -


[web2py] MARKMIN HELPER

2010-11-09 Thread Bruno Rocha
Minor suggestion for MARKMIN()

If I am fetching the Markmin content from database, and database field is
empty (None), MARKMIN raises an error.

I am solving this problem with :

MARKMIN(myfield or ' ')

But, I think MARKMIN can itself resolve what to do if the received arg is
NoneType)

  File "/home/rochacbruno/webapps/natalanimal2/web2py/gluon/html.py",
line 1892, in xml
class MARKMIN(XmlComponent):
  File 
"/home/rochacbruno/webapps/natalanimal2/web2py/gluon/contrib/markmin/markmin2html.py",
line 317, in render
text = regex_dd.sub('``\g``:latex ',text)
TypeError: expected string or buffer


Re: [web2py] Re: Error routing

2010-11-09 Thread Jonathan Lundell
On Nov 9, 2010, at 9:06 PM, Ruiwen Chua wrote:
> 
> Is there no way around it? Or..?
> 
> I'd just prefer my URLs to be clean. The users dont' really need to
> see all the additional information.

You might try setting error_handler instead of routes_onerror.

> 
> //Ruiwen
> 
> On Nov 10, 11:36 am, mdipierro  wrote:
>> No. Why?
>> 
>> On Nov 9, 5:16 am, Ruiwen Chua  wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> Hi all,
>> 
>>> I'm trying to route errors like 400, 403 and 404 to nice, clear URLs
>>> like '/error/', '/forbidden/' and '/whoops/'.
>> 
>>> Unfortunately, the Web2Py Book's section on error routing 
>>> (http://www.web2py.com/book/default/chapter/04?search=error#Routes-on-...)
>>> is pretty sparse, and I haven't been able to get this to work.
>> 
>>> I have this section both within my application/app/routes.py (snipped
>>> for brevity):
>> 
>>> routes_in = (
>>> ('/error/', '/app/default/error/'),
>>> )
>> 
>>> routes_onerror = [
>>>(r'app/400', r'/error/')
>>> ]
>> 
>>> However, I keep getting redirected to URLs like "error/?
>>> code=400&ticket=None&requested_uri=None&request_url=/deh/index"
>> 
>>> Is there a way I can hide the query string after the "error/"?
>> 
>>> Cheers
>>> Ruiwen




[web2py] Re: Error routing

2010-11-09 Thread Ruiwen Chua
Is there no way around it? Or..?

I'd just prefer my URLs to be clean. The users dont' really need to
see all the additional information.

//Ruiwen

On Nov 10, 11:36 am, mdipierro  wrote:
> No. Why?
>
> On Nov 9, 5:16 am, Ruiwen Chua  wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > I'm trying to route errors like 400, 403 and 404 to nice, clear URLs
> > like '/error/', '/forbidden/' and '/whoops/'.
>
> > Unfortunately, the Web2Py Book's section on error routing 
> > (http://www.web2py.com/book/default/chapter/04?search=error#Routes-on-...)
> > is pretty sparse, and I haven't been able to get this to work.
>
> > I have this section both within my application/app/routes.py (snipped
> > for brevity):
>
> > routes_in = (
> >         ('/error/', '/app/default/error/'),
> > )
>
> > routes_onerror = [
> >    (r'app/400', r'/error/')
> > ]
>
> > However, I keep getting redirected to URLs like "error/?
> > code=400&ticket=None&requested_uri=None&request_url=/deh/index"
>
> > Is there a way I can hide the query string after the "error/"?
>
> > Cheers
> > Ruiwen


[web2py] Re: Not getting a result from query

2010-11-09 Thread Alex
Are you sure there are records coming back?  Try doing a "print
records" and make sure data is coming back.  Sounds like it just may
be an empty result set from the query.

On Nov 9, 6:50 pm, Lorin Rivers  wrote:
> I think I'm close:
> given this controller
>
> my_macaddr = db4().select(db4.data_table.MacAddr, distinct=True)
>
> def display_form():
>   form = FORM(TR("Select a MAC Address :",
>   SELECT(_name='MacAddrSelect',
>   *[OPTION(my_macaddr[i].MacAddr, _value=str(my_macaddr[i].MacAddr)) for i in 
> range(len(my_macaddr))])),
>   TR(INPUT(_type='submit')))
>
>   records = db4((db4.data_table.MacAddr==form.vars.MacAddrSelect) & 
> (db4.data_table.ReqTime>='2010-11-08T21:00')
>             & 
> (db4.data_table.ReqTime<='2010-11-08T22:00')).select(db4.data_table.MacAddr­,db4.data_table.ReqTime,db4.data_table.Po)
>
>   return 
> dict(form=form,records=SQLTABLE(records),vars=form.vars,vars2=request.vars)
>
> and this in my view:
> {{extend 'layout.html'}}
> Input form
> {{=form}}
> Results
> {{=records}}
> Submitted variables
> {{=BEAUTIFY(request.vars)}}
> Accepted variables
> {{=BEAUTIFY(form.vars)}}
> Errors in form
> {{=BEAUTIFY(form.errors)}}
>
> My form is displaying the request.vars and the three elements in the 
> select(), but no results.
>
> What am I missing/doing wrong?
> --
> Lorin Rivers
> Mosasaur: Killer Technical Marketing 
> 
> 512/203.3198 (m)


[web2py] Re: Using the results of a select/option in a query

2010-11-09 Thread Alex
You should be able to access the variables passed by your form
through: request.vars

ex.  Given a form with this control:  

You can access this in the controller through:  request.vars.chatText

On Nov 9, 6:04 pm, Lorin Rivers  wrote:
> OK, I answered my own question from before.
>
> I now have in my controller:
> my_macaddr = db4().select(db4.data_table.MacAddr, distinct=True)
>
> def display_form():
>   form = FORM(TR("Select a MAC Address :",
>   SELECT(_name='MacAddrSelect',
>   *[OPTION(my_macaddr[i].MacAddr, _value=str(my_macaddr[i].MacAddr)) for i in 
> range(len(my_macaddr))])),
>   TR(INPUT(_type='submit')))
>   return dict(form=form)
>
> Which gives me the form I want. How do I turn the result of the submit into a 
> query?
>
> I want to generate something along the lines of this:
>
> db4((db4.data_table.MacAddr=='00AF') & 
> (db4.data_table.ReqTime>='2010-11-08T21:00') & 
> (db4.data_table.ReqTime>='2010-11-08T22:00'))
>
> Thanks!
> --
> Lorin Rivers
> Mosasaur: Killer Technical Marketing 
> 
> 512/203.3198 (m)


[web2py] Re: Confirmation message in SQLFORM

2010-11-09 Thread CesarBustios
Oh! I think i have to read the whole book before asking questions xD

Thanks man!

On Nov 9, 9:47 pm, DenesL  wrote:
> Hi Cesar,
>
> that is the default 
> behaviourhttp://web2py.com/book/default/chapter/10#Confirmation-on-Delete
>
> On Nov 9, 8:41 pm, CesarBustios  wrote:
>
>
>
>
>
>
>
> > Hi, after clicking the submit button (when deleting), is there a way
> > to send a confirmation message like saying "Are you sure man, really
> > really sure???" or something like that?
>
> > Thanks!


[web2py] Re: Error routing

2010-11-09 Thread mdipierro
No. Why?

On Nov 9, 5:16 am, Ruiwen Chua  wrote:
> Hi all,
>
> I'm trying to route errors like 400, 403 and 404 to nice, clear URLs
> like '/error/', '/forbidden/' and '/whoops/'.
>
> Unfortunately, the Web2Py Book's section on error routing 
> (http://www.web2py.com/book/default/chapter/04?search=error#Routes-on-Error)
> is pretty sparse, and I haven't been able to get this to work.
>
> I have this section both within my application/app/routes.py (snipped
> for brevity):
>
> routes_in = (
>         ('/error/', '/app/default/error/'),
> )
>
> routes_onerror = [
>    (r'app/400', r'/error/')
> ]
>
> However, I keep getting redirected to URLs like "error/?
> code=400&ticket=None&requested_uri=None&request_url=/deh/index"
>
> Is there a way I can hide the query string after the "error/"?
>
> Cheers
> Ruiwen


[web2py] Re: Pyodbc error with web2py under Apache and mod_wsgi

2010-11-09 Thread mdipierro
you may have different python versions installed. Check the one used
by modwsgi

On Nov 9, 3:02 pm, azarkowsky  wrote:
> Hi,
>
> I'm relatively new to web2py and am attempting to set up my production
> environment for the first time.  I'm running Apache2.2 with mod_wsgi,
> python 2.7, & web2py 1.88.2 on Win XP SP3.  If I run web2py without
> Apache by running:  'python web2py.py -a "" -i 127.0.0.1 -p
> 8000' I can access both my application and the admin interface without
> any problems.  Once I try to access my site running behind Apache
> though, I receive a ticket containing the following trackback:
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 188, in restricted
>     exec ccode in environment
>   File "C:/web2py/applications/lunch/models/db.py", line 11, in
> 
>     db = DAL('mssql://lunch:lu...@b1ts003/lunch1')
>   File "C:\web2py\gluon\sql.py", line 4048, in DAL
>     raise RuntimeError, "%s (tried 5 times)" % exception
> RuntimeError: global name 'pyodbc' is not defined (tried 5 times)
>
> If I run web2py in terminal mode and import pyodbc I don't receive any
> errors:
>
> C:\web2py>python web2py.py -S welcome -P
> No handlers could be found for logger "web2py"
> web2py Enterprise Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2010
> Version 1.88.2 (2010-10-29 23:04:43)
> Database drivers available: SQLite3, MSSQL/DB2
> Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit
> (Intel)] on win
> 32
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
>
> >>> import pyodbc
>
> I'm sure I'm probably just missing something in my confiration, but
> after scouring the web2py book and searching Google I haven't been
> able to find a solution.  I'd greatly appreciate any suggestions, or
> if you need additional info, please let me know!
>
> Thanks,
> Adam


[web2py] Re: running web2py on Android?

2010-11-09 Thread mdipierro
http://code.google.com/p/android-scripting/issues/detail?id=276

On Nov 9, 6:18 pm, pallav  wrote:
> I checked and the line was already commented out.
>
> I don't know how to run web2py with the switch -N because I have to
> run it from inside the interactive python shell by typing import
> web2py.web2py and hitting enter.
>
> What does the switch -N do? I can try to simulate the same effect by
> modifying th web2py code.
>
> The shell output is pasted below.
>
> $ export TEMP="/sdcard/ase/extras/python/tmp/"
> export PYTHONHOME="/data/data/com.google.ase/python"
> $ $ export AP_PORT="45310"
> export PYTHONPATH="/sdcard/ase/extras/python/:/sdcard/ase/scripts/"
> /data/data/com.google.ase/python/bin/python
> $ $ Python 2.6.2 (r262:71600, Sep 19 2009, 11:03:28)
> [GCC 4.2.1] on linux2
> Type "help", "copyright", "credits" or "license" for more 
> information.>>>import web2py.web2py
>
> uname: permission denied
> web2py Enterprise Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2010
> Version 1.88.2 (2010-10-29 23:04:43)
> Database drivers available: SQLite3
> Starting hardcron...
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/sdcard/ase/scripts/web2py/web2py.py", line 23, in 
>     gluon.widget.start(cron=True)
>   File "/sdcard/ase/scripts/web2py/gluon/widget.py", line 815, in
> start
>     logger.warn('GUI not available because Tk library is not
> installed')
>   File "/home/damonkohler/ase_src/python/src/android/python/lib/
> python2.6/logging/__init__.py", line 1042, in warning
>
>   File "/home/damonkohler/ase_src/python/src/android/python/lib/
> python2.6/logging/__init__.py", line 1142, in _log
>
>   File "/home/damonkohler/ase_src/python/src/android/python/lib/
> python2.6/logging/__init__.py", line 1117, in makeRecord
>
>   File "/home/damonkohler/ase_src/python/src/android/python/lib/
> python2.6/logging/__init__.py", line 272, in __init__
>
> ImportError: No module named multiprocessing
>
>
>
> On Nov 8, 11:46 pm, mdipierro  wrote:
>
> > make sure this line in web2py.py
>
> > # import gluon.import_all
>
> > is commented. web2py should not need to use multiprocessing. Also run
> > it with -N.
>
> > On Nov 8, 10:42 pm, pallav  wrote:
>
> > > I just tried running web2py onandroidand an error regarding the
> > > module multiprocessing being missing. It gets called from
> > > gluon.widget.start()
>
> > > I will look into the source code tomorrow to see if there is a
> > > workatound. I might try porting the multiprocessing module over.
>
> > > Any ideas anyone? I think mobile apps area great way for web2py to
> > > take a lead in the python framework world.
>
> > > On Oct 15, 5:15 am, "dustin.b"  wrote:
>
> > > > i tried to run w2p onandroidwith ASE (androidscripting env). It's
> > > > been a while since I tried this but i can remember that there was a
> > > > problem with threads or something like this. w2p seems to use python
> > > > packages that are not avaible onandroid, didnt remember exactly which
> > > > one.
>
>


[web2py] Re: Error routing

2010-11-09 Thread Ruiwen Chua


On Nov 9, 7:16 pm, Ruiwen Chua  wrote:
> Hi all,
>
> I'm trying to route errors like 400, 403 and 404 to nice, clear URLs
> like '/error/', '/forbidden/' and '/whoops/'.
>
> Unfortunately, the Web2Py Book's section on error routing 
> (http://www.web2py.com/book/default/chapter/04?search=error#Routes-on-Error)
> is pretty sparse, and I haven't been able to get this to work.
>
> I have this section both within my application/app/routes.py (snipped
> for brevity):
>
> routes_in = (
>         ('/error/', '/app/default/error/'),
> )
>
> routes_onerror = [
>    (r'app/400', r'/error/')
> ]
>
> However, I keep getting redirected to URLs like "error/?
> code=400&ticket=None&requested_uri=None&request_url=/deh/index"
>
> Is there a way I can hide the query string after the "error/"?
>
>

Sorry for pinging the list again, but does anyone have a solution for
the above problem?

Or a vague clue about how I might be able to get around it?

Thanks in advance!

Cheers
Ruiwen


[web2py] Re: Confirmation message in SQLFORM

2010-11-09 Thread DenesL
Hi Cesar,

that is the default behaviour
http://web2py.com/book/default/chapter/10#Confirmation-on-Delete


On Nov 9, 8:41 pm, CesarBustios  wrote:
> Hi, after clicking the submit button (when deleting), is there a way
> to send a confirmation message like saying "Are you sure man, really
> really sure???" or something like that?
>
> Thanks!


[web2py] Upload a file to db and store all metadata to separated db fields

2010-11-09 Thread Alexandre Augusto
Hi Massimo and Cesar. First of all another one zillion thxz to the
Extremely Amazing  Framework ever created !

I have a sittuation that is not the same as Cesar:
http://groups.google.com/group/web2py/browse_thread/thread/c83cd69dee02c9b1/065c44106598d69b?lnk=gst&q=upload+#065c44106598d69b
but somehow it is related..
and I did spent like 6 days trying many things and I could not make it
right... hope you could help me out..
and maybe this solves many others problems...

*In a nut shell, I'm trying to upload the file, store it on the
database (using the two fields upload and  blob ),
and save all meta-data and common information to different fields on
the same record *

*By meta-data I refer to file Mime types*
 1. MIME-Version
 2. Content-ID
 3. Content-Type
   [ 4.  File header signature, extracted from the file first data
block -- not sure one of the 3 fields above provide this incase not ]

*and common infomation*
I mean all user information that could be associated to the file:

5. Full file name ( 'C:\My Documents\pics\agape.jpg' )
6. File Extension (  '.jpg' )
7. File Size ( ' 230 kb ' )
 n. ...or any other metadata information available for the file

I could make the upload/ and blob/ work but I'm not having success to
gather and extract this information from the file at the same time I'm
uploading and storing it on the DB..

This is for my Computer Science Bachelor Graduation Work at Unip, São
Paulo University, once i get it more mature  I'm going to release it
to the community, as I'm aiming to create an Open Source Project
similar what happened to Instant Press but on a different scope
application some sort of ECM tool.. Even being aware that may not be
wise to store all these and some could be derivative from other
fields, I need to make this work for the proof of concept to develop
other concepts in the project.



So my model is like this

# Model
db.define_table("image",
Field('pic','upload',default=''),
Field('file','upload', default="", autodelete=True,
uploadfield='file_binary_data') ,
Field('file_binary_data', 'blob'),
Field('physical_file_name'), # the full file name.. is it possible
grab the folder from where it was uploaded ?
Field('file_extension'),
Field('file_size'),
Field('MIME_Version'),
Field('Content_ID'),
Field('Content_Type'),
Field('file_header'),  #File header footprint extracted from X top
chars from file
)


#Controller
def Upload():
form=SQLFORM(db.image)

if form.accepts(request.vars, session):

file_name = request.vars.pic

try: ext = re.compile('\.\w+
$').findall(file_name.filename.strip())[0]
except IndexError: ext = '.txt'

#pic_filename = 'image.'+'pic.'+str(random.random())[2:] + ext
#pic_filename = 'image.'+'pic.' +
str(uuid.uuid4()).replace('-','') + ext

#pic_filename = pic.filename
file_path  = os.path.join(request.folder, 'uploads/',
file_name)
file_handler = open(file_path,'wb')
file_handler.close()

raw_file_size = file_handler.?file_size()
MIME_Version  = ?get_MIME()
Content_ID= file_handler.?file_handler()
Content_Type  = file_handler.?file_type()
file_header   = ?get_Phys_File_Header(file_handler)

image_id = db.image.insert(
pic  = file_name.uuid64 ,
file_binary_data = file_name ,
physical_file_name = file_path ,
file_extension = ext ,
file_size =  raw_file_size ,
MIME_Version =  MIME_Version ,
Content_ID =  Content_ID ,
Content_Type =  Content_Type ,
file_header = file_header ,
)


response.flash = 'File Uploaded'

return dict(form=form)



###

I tried to update the response.post_var trying to avoid the manual
record insert directly but the change didn't went to db


on the manual insert I added fictitious  properties and method trying
to access the properties array directly of
FieldStorage object..  they are marked with  questions marks (?)   to
indicate where I'm looking for help


Is it possible to do store everything on the same moment file is
uploaded ?
Any help on how to store these columns are welcome ! thanks much





___
Alexandre A. Almeida
Ax3

"Any intelligent fool can make things bigger and more complex... It
takes a touch of genius - and a lot of courage to move in the opposite
direction." -- Albert Einstein


[web2py] Pyodbc error with web2py under Apache and mod_wsgi

2010-11-09 Thread azarkowsky
Hi,

I'm relatively new to web2py and am attempting to set up my production
environment for the first time.  I'm running Apache2.2 with mod_wsgi,
python 2.7, & web2py 1.88.2 on Win XP SP3.  If I run web2py without
Apache by running:  'python web2py.py -a "" -i 127.0.0.1 -p
8000' I can access both my application and the admin interface without
any problems.  Once I try to access my site running behind Apache
though, I receive a ticket containing the following trackback:

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 188, in restricted
exec ccode in environment
  File "C:/web2py/applications/lunch/models/db.py", line 11, in

db = DAL('mssql://lunch:lu...@b1ts003/lunch1')
  File "C:\web2py\gluon\sql.py", line 4048, in DAL
raise RuntimeError, "%s (tried 5 times)" % exception
RuntimeError: global name 'pyodbc' is not defined (tried 5 times)

If I run web2py in terminal mode and import pyodbc I don't receive any
errors:

C:\web2py>python web2py.py -S welcome -P
No handlers could be found for logger "web2py"
web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2010
Version 1.88.2 (2010-10-29 23:04:43)
Database drivers available: SQLite3, MSSQL/DB2
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit
(Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import pyodbc
>>>

I'm sure I'm probably just missing something in my confiration, but
after scouring the web2py book and searching Google I haven't been
able to find a solution.  I'd greatly appreciate any suggestions, or
if you need additional info, please let me know!

Thanks,
Adam


[web2py] Re: Selecting from dropdown using Ajax

2010-11-09 Thread oneroler
Alex,

Thanks.  I thought based on the book that the 2nd argument of ajax was
passing the values to request.vars.variable.  I pasted some of the
code from the book below for reference (http://web2py.com/book/default/
chapter/10?search=ajax#The-ajax-Function).  Based on this I originally
had the code below in test_chg.  Am I mistaken about what the 2nd
argument is?  Also, regarding your suggestion, could you tell me how
to identify the selected item so that I can pass as an args/vars in
the URL as you recommended?

def one():
return dict()

def echo():
return request.vars.name

{{extend 'layout.html'}}

   



def test_chg
firm=request.vars.firmdrop
strats = db(db.firmstrat.firm_id==firm).select()
options=[]
for strat in strats:
options.append(strat.strat_id.name)
return DIV(*options).xml()

On Nov 8, 9:37 pm, Alex  wrote:
> How are you passing the value in the request.vars?
>
> I'm going to guess that on your AJAX call in the _onChange handler,
> you want to specify the parameters.  You can do something like:
>
>   - ajax( '{{=URL(c='controllerName',f='test_chg',
> args=request.args(0))}}', ['firmdrop'],'target' )
>
> You can pass whatever you want in args.  If you have values in
> request.vars, you should be able to access then like:
>
>  -  request.vars.variableName
>
> On Nov 7, 9:11 pm, oneroler  wrote:
>
>
>
>
>
>
>
> > I'm trying to learn to use the ajax functionality and am having
> > trouble getting it to work correctly.  I am trying to use a dropdown
> > of firms to show the related strategies.  Currently this doesn't
> > return anything to the div, but I do know that the onchange is
> > working.  It seems like the request.vars.values()[0] is not returning
> > anything.  Any help would be appreciated and also any pointers if
> > there is a way to do this better differently.  Below is my code.
>
> > I have based this on this 
> > messagehttp://groups.google.com/group/web2py/browse_thread/thread/4a6149ddcb
>
> > <>
> > def test():
> >     firms = db(db.firm).select()
> >     return dict(firms=firms)
>
> > def test_chg():
> >     firm=request.vars.values()[0]
> >     strats = db(db.firmstrat.firm_id==firm).select()
> >     options=[]
> >     for strat in strats:
> >         options.append(strat.strat_id.name)
> >     return DIV(*options).xml()
>
> > <>
> > {{extend 'layout.html'}}
> > {{=SELECT(_id='firmdrop',
> >     _onChange="ajax('test_chg',['firmdrop'],'target');",
> >     *[OPTION(firms[i].name,_value=str(firms[i].id)) for i in
> > range(len(firms))]
> >     )}}
> > 
>
> > Thanks,
> > Sam


[web2py] Confirmation message in SQLFORM

2010-11-09 Thread CesarBustios
Hi, after clicking the submit button (when deleting), is there a way
to send a confirmation message like saying "Are you sure man, really
really sure???" or something like that?

Thanks!


[web2py] Re: twilio context ($100 prize)

2010-11-09 Thread Richard
nice service, and a cost-effective way to get publicity.


On Nov 10, 12:50 am, mdipierro  wrote:
> http://blog.twilio.com/2010/11/attention-pythonistas-twilio-has-a-con...


[web2py] Not getting a result from query

2010-11-09 Thread Lorin Rivers
I think I'm close:
given this controller

my_macaddr = db4().select(db4.data_table.MacAddr, distinct=True)

def display_form():
  form = FORM(TR("Select a MAC Address :", 
  SELECT(_name='MacAddrSelect', 
  *[OPTION(my_macaddr[i].MacAddr, _value=str(my_macaddr[i].MacAddr)) for i in 
range(len(my_macaddr))])), 
  TR(INPUT(_type='submit')))

  records = db4((db4.data_table.MacAddr==form.vars.MacAddrSelect) & 
(db4.data_table.ReqTime>='2010-11-08T21:00')
& 
(db4.data_table.ReqTime<='2010-11-08T22:00')).select(db4.data_table.MacAddr,db4.data_table.ReqTime,db4.data_table.Po)
  
  return 
dict(form=form,records=SQLTABLE(records),vars=form.vars,vars2=request.vars)


and this in my view:
{{extend 'layout.html'}}
Input form
{{=form}}
Results
{{=records}}
Submitted variables
{{=BEAUTIFY(request.vars)}}
Accepted variables
{{=BEAUTIFY(form.vars)}}
Errors in form
{{=BEAUTIFY(form.errors)}}


My form is displaying the request.vars and the three elements in the select(), 
but no results.

What am I missing/doing wrong?
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing 

512/203.3198 (m)




[web2py] Re: running web2py on Android?

2010-11-09 Thread pallav
I checked and the line was already commented out.

I don't know how to run web2py with the switch -N because I have to
run it from inside the interactive python shell by typing import
web2py.web2py and hitting enter.

What does the switch -N do? I can try to simulate the same effect by
modifying th web2py code.

The shell output is pasted below.

$ export TEMP="/sdcard/ase/extras/python/tmp/"
export PYTHONHOME="/data/data/com.google.ase/python"
$ $ export AP_PORT="45310"
export PYTHONPATH="/sdcard/ase/extras/python/:/sdcard/ase/scripts/"
/data/data/com.google.ase/python/bin/python
$ $ Python 2.6.2 (r262:71600, Sep 19 2009, 11:03:28)
[GCC 4.2.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>import web2py.web2py
uname: permission denied
web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2010
Version 1.88.2 (2010-10-29 23:04:43)
Database drivers available: SQLite3
Starting hardcron...
Traceback (most recent call last):
  File "", line 1, in 
  File "/sdcard/ase/scripts/web2py/web2py.py", line 23, in 
gluon.widget.start(cron=True)
  File "/sdcard/ase/scripts/web2py/gluon/widget.py", line 815, in
start
logger.warn('GUI not available because Tk library is not
installed')
  File "/home/damonkohler/ase_src/python/src/android/python/lib/
python2.6/logging/__init__.py", line 1042, in warning

  File "/home/damonkohler/ase_src/python/src/android/python/lib/
python2.6/logging/__init__.py", line 1142, in _log

  File "/home/damonkohler/ase_src/python/src/android/python/lib/
python2.6/logging/__init__.py", line 1117, in makeRecord

  File "/home/damonkohler/ase_src/python/src/android/python/lib/
python2.6/logging/__init__.py", line 272, in __init__

ImportError: No module named multiprocessing
>>>



On Nov 8, 11:46 pm, mdipierro  wrote:
> make sure this line in web2py.py
>
> # import gluon.import_all
>
> is commented. web2py should not need to use multiprocessing. Also run
> it with -N.
>
> On Nov 8, 10:42 pm, pallav  wrote:
>
>
>
> > I just tried running web2py onandroidand an error regarding the
> > module multiprocessing being missing. It gets called from
> > gluon.widget.start()
>
> > I will look into the source code tomorrow to see if there is a
> > workatound. I might try porting the multiprocessing module over.
>
> > Any ideas anyone? I think mobile apps area great way for web2py to
> > take a lead in the python framework world.
>
> > On Oct 15, 5:15 am, "dustin.b"  wrote:
>
> > > i tried to run w2p onandroidwith ASE (androidscripting env). It's
> > > been a while since I tried this but i can remember that there was a
> > > problem with threads or something like this. w2p seems to use python
> > > packages that are not avaible onandroid, didnt remember exactly which
> > > one.


[web2py] Using the results of a select/option in a query

2010-11-09 Thread Lorin Rivers
OK, I answered my own question from before.

I now have in my controller:
my_macaddr = db4().select(db4.data_table.MacAddr, distinct=True)

def display_form():
  form = FORM(TR("Select a MAC Address :", 
  SELECT(_name='MacAddrSelect', 
  *[OPTION(my_macaddr[i].MacAddr, _value=str(my_macaddr[i].MacAddr)) for i in 
range(len(my_macaddr))])), 
  TR(INPUT(_type='submit')))
  return dict(form=form)

Which gives me the form I want. How do I turn the result of the submit into a 
query?

I want to generate something along the lines of this:

db4((db4.data_table.MacAddr=='00AF') & 
(db4.data_table.ReqTime>='2010-11-08T21:00') & 
(db4.data_table.ReqTime>='2010-11-08T22:00'))

Thanks!
-- 
Lorin Rivers
Mosasaur: Killer Technical Marketing 

512/203.3198 (m)




Re: [web2py] Re: is there a "insert or replace" for the DAL

2010-11-09 Thread Stef Mientki
thanks Massimo, works great !

cheers,
Stef
On 09-11-2010 20:12, mdipierro wrote:
> No but you can do
>
> db(condition).update(**d) or db.table.insert(**d)
> On Nov 9, 1:00 pm, Stef Mientki  wrote:
>> hello,
>>
>> I wonder if there is a "insert or replace" or another mechanism, when insert 
>> fails ?
>>
>> thanks,
>> Stef Mientki



Re: [web2py] unicode problem in DAL

2010-11-09 Thread Stef Mientki
On 05-11-2010 23:26, Tomeu Roig wrote:
>
> Hi, before to make the insert, you need change the string ascii to utf8,
>
> Newvalue=value.encode(utf-8)
>
first of all a small type, quotes around utf-8 needed.
  
Newvalue=value.encode( ' utf-8'  )

But then it still doesn't work in my situation.
I think the problem is a bit more complex, sorry for the long story.
Normally I always use unicode strings in all my code, so there should never be 
a problem ;-)
Using the DAL introduces a basic problem,
suppose I've a dictionair My_Dict  that I want to insert in a DAL table
  
   DB.Table.insert ( **My_Dict )

This is impossible, because the unpacking ** doesn't allow unicode keys.
In gluon.sql this way of unpacking is done frequently.

the next problem is that (because I generate my fieldnames by code), the 
filednames and tablenames
becomes unicode:

  Fields.append ( eval ( str ( FLine ) ) )
  print 'LLVV',  FLine, Fields[-1].name, type (Fields[-1].name)

resulting in UNICODE !!
LLVV Field ( 'Verzekering_ID','integer') Verzekering_ID 

the third problem is that in the Table._insert method

sql_f = ', '.join(fs)
sql_v = ', '.join(vs)
sql_t = self._tablename
print '==jdhsadjs==',type(sql_t), type(sql_f), type(sql_v)
return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v)

resulting in invalid combinations of unicode and strings
==jdhsadjs==   


What really solves the problem is to convert sql_t and sql_f in Table._insert 
into strings
sql_f = ', '.join(fs)
sql_v = ', '.join(vs)
sql_t = self._tablename
sql_t = sql_t.encode('utf-8')
sql_f = sql_f.encode('utf-8')
return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v)

I've the feeling that this is not a good solution in the first place.
Secondly, there probably are more of this code parts in gluon.sql.

Any suggestions ?

thanks,
Stef


>> El 05/11/2010 12:18, "Stef Mientki" > >
>> escribió:
>>
>>
>> I'm trying to insert a record with a filed value
>>  u"ëLocatie"
>>
>> and I get an error in sql.Table._insert at the last line:
>>return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v)
>>
>> here the traceback
>>  File "D:\Data_Python_25\support\Web2Py_DAL_support.py", line 250, in 
>> DAL_Table
>>Description = Value[3][:-1])
>>  File "P:\Web2PY\web2py_src\web2py\gluon\sql.py", line 2035, in insert
>>query = self._insert(**fields)
>>  File "P:\Web2PY\web2py_src\web2py\gluon\sql.py", line 2028, in _insert
>>return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v)
>> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 35: 
>> ordinal not in range(128)
>>
>> I don't understand the problem and know what I'm doing wrong
>>
>> Wwith print statements I tried to narrow the problem, and in :
>> def sql_represent(obj, fieldtype, dbname, db_codec='UTF-8'):
>>
>> there's is this part
>>if isinstance(obj, unicode):
>>print '', type(obj),obj
>>if len(obj)>0 : print ord(obj[0])
>>obj = obj.encode(db_codec)
>>print '', type(obj)
>>if len(obj)>0 : print ord(obj[0])
>>
>> which seems to convert the unicode to a string with byte values larger than 
>> 128.
>>
>> Am I doing something wrong, or is this a bug ?
>> And of course far more interesting, how do I solve this problem ?
>>
>> thanks,
>> Stef Mientki
>>
>>



[web2py] Re: minimal URL rewrite

2010-11-09 Thread Wikus van de Merwe
You can define all the functions of the default controller that you
want to match:

FUNCTIONS = ["A", "B", "C"]

routes_in = (
('/', '/myapplic/default/index'),
('/(%s)' % "|".join(FUNCTIONS), r'/myapplic/default/\1'))

routes_out = (
('/myapplic/default/index', '/'),
('/myapplic/default/(%s)' % "|".join(FUNCTIONS), r'/\1'))

Also, when you list your rules be careful in what order they are
matched. In your example base.css (and robots.txt too) would be
rewritten as /myapplic/default/base.css because the rule with /
$anything would be triggered earlier.


[web2py] Re: making layout plugin

2010-11-09 Thread cjrh
On Nov 9, 3:52 pm, mdipierro  wrote:
> This could be another typos in the book.
>
> layout.html should be
>
> {{extend 'plugin_layout_name/layout.html'}}
> {{include}}

Fixed in the book.


[web2py] Re: many-to-many, use list:reference or separate table?

2010-11-09 Thread mdipierro
Speedwise, you should use many2many if you plan to search the referee
by the refereed. If you only need the refereed after you already have
the referee you can use list:reference. If you are on GAE
list:reference is better because native and GAe has no joins.

On Nov 9, 2:43 pm, Carlos  wrote:
> Hi all,
>
> I am wondering, with respect to many-to-many relationships, is it
> better to use "list:reference" or a separate table (with foreign
> keys)?.
>
> I refer to 'simple' many-to-many where no extra attributes need to be
> stored (otherwise the separate table is the only choice).
>
> Thanks,
>
>    Carlos


[web2py] Re: dynamic representation for crud.select / SQLTABLE

2010-11-09 Thread mdipierro
Right. I would not use crud.select(table,query) but simply
rows=db(query).select()

On Nov 9, 2:38 pm, Carlos  wrote:
> Hi Massimo,
>
> Thanks, but do you mean to loop through the rows after calling
> crud.select (which returns a list a of dictionaries)?.
>
> Or what do you mean by 'build your row' in each loop?.
>
> Is it possible to create a dummy/transient table field in order to
> assign the required dynamic value during this loop?, or should I just
> add the dictionary key/value directly to each dictionary in the list
> returned by crud.select?.
>
> Btw crud.select internally uses SQLTABLE, or not?.
>
> Thanks,
>
>    Carlos
>
> On Nov 9, 12:43 pm, mdipierro  wrote:
>
> > Sorry there is not. You may better off looping
>
> > {{for row in rows:}}
> > ... build your row ...
> > {{pass}}
>
> > On Nov 9, 12:37 pm, Carlos  wrote:
>
> > > Hi all,
>
> > > I'm using crud.select / SQLTABLE, and I need to show one column with
> > > links/actions generated dynamically based on conditions found for each
> > > row data.
>
> > > I believe I can not use 'represent' because that's linked to a single
> > > field only (lambda field: ...).
>
> > > Is there something like "lambda row: ..." where I can access all
> > > necessary fields for each row and show dynamic options based on each
> > > row data?.
>
> > > Can virtual fields provide the dynamic behavior I need for
> > > crud.select / SQLTABLE?.
>
> > > Any ideas?.
>
> > > Thanks!,
>
> > >    Carlos
>
>


[web2py] many-to-many, use list:reference or separate table?

2010-11-09 Thread Carlos
Hi all,

I am wondering, with respect to many-to-many relationships, is it
better to use "list:reference" or a separate table (with foreign
keys)?.

I refer to 'simple' many-to-many where no extra attributes need to be
stored (otherwise the separate table is the only choice).

Thanks,

   Carlos


[web2py] Re: dynamic representation for crud.select / SQLTABLE

2010-11-09 Thread Carlos
Hi Massimo,

Thanks, but do you mean to loop through the rows after calling
crud.select (which returns a list a of dictionaries)?.

Or what do you mean by 'build your row' in each loop?.

Is it possible to create a dummy/transient table field in order to
assign the required dynamic value during this loop?, or should I just
add the dictionary key/value directly to each dictionary in the list
returned by crud.select?.

Btw crud.select internally uses SQLTABLE, or not?.

Thanks,

   Carlos


On Nov 9, 12:43 pm, mdipierro  wrote:
> Sorry there is not. You may better off looping
>
> {{for row in rows:}}
> ... build your row ...
> {{pass}}
>
> On Nov 9, 12:37 pm, Carlos  wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > I'm using crud.select / SQLTABLE, and I need to show one column with
> > links/actions generated dynamically based on conditions found for each
> > row data.
>
> > I believe I can not use 'represent' because that's linked to a single
> > field only (lambda field: ...).
>
> > Is there something like "lambda row: ..." where I can access all
> > necessary fields for each row and show dynamic options based on each
> > row data?.
>
> > Can virtual fields provide the dynamic behavior I need for
> > crud.select / SQLTABLE?.
>
> > Any ideas?.
>
> > Thanks!,
>
> >    Carlos


[web2py] Re: ProgrammingError: (2014, "Commands out of sync; you can't run this command now")

2010-11-09 Thread mdipierro
Has anybody else here had a similar problem?

massimo

On Nov 9, 11:29 am, David Zejda  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Hi :)
>
> E.g. now the exception was raised by the web2py internal db
> initialization routine:
>
> 28: db = SQLDB('mysql://myus:myp...@localhost:330h6/mydb', pool_size=10)
>
> Traceback (most recent call last):
>   File "/opt/web2py/gluon/restricted.py", line 188, in restricted
>     exec ccode in environment
>   File "/opt/web2py/applications/myapp/compiled/models_db.py", line 28,
> in 
>   File "/opt/web2py/gluon/sql.py", line 978, in __init__
>     self._execute('SET FOREIGN_KEY_CHECKS=1;')
>   File "/opt/web2py/gluon/sql.py", line 977, in 
>     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
>   File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line 166,
> in execute
>     self.errorhandler(self, exc, value)
>   File "/var/lib/python-support/python2.5/MySQLdb/connections.py", line
> 35, in defaulterrorhandler
>     raise errorclass, errorvalue
> ProgrammingError: (2014, "Commands out of sync; you can't run this
> command now")
>
> I'm thinking about possibility to raise the size of my poll. But in the
> past with higher poll I think I was receiving more OperationalError:
> (2006, 'MySQL server has gone away'). Because I am referring to a live
> server, I would prefer to avoid experiments which could make frequency
> of db errors even worse :)
>
> thanks & wishing you a nice day..
> David
>
>
>
> mdipierro wrote:
> > I cannot say without looking at the code. MySQL has lots of
> > undocumented quirks about what you can do and what you cannot do
> > within one transaction.
>
> > Try add a db.commit() after each insert/unpdate/form.accepts/
> > crud.update/crud.select IF you do a select after that.
>
> > Do you have any try:...except in your controllers and db queries
> > inside?
>
> > On Nov 8, 2:57 am, David Zejda  wrote:
> > The MySQL error occurs quite often, several times every day. The app has
> > about 2 page views daily and heavily communicates with db (tens of
> > queries per request, in db I have about 100 tables). Currently I have
> > pool with size for 10 connections.
>
> > Meaning of the error message is described here:
>
> >http://dev.mysql.com/doc/refman/4.1/en/commands-out-of-sync.html
>
> > It seems that with MySQL statements on the same db connection have to be
> > exhausted one-by-one, never in parallel. Two statements returning data
> > to the process must be using separate DBConnections (possibly to the
> > same host/db). Multiple statements on the same connection are supported,
> > but only 1 may be in a state to 'fetch' data.
>
> > Traces for the errors look like this:
>
> >   File "/opt/web2py/gluon/sql.py", line 3378, in count
> >     return self.select('count(*)')[0]._extra['count(*)']
> >   File "/opt/web2py/gluon/sql.py", line 3237, in select
> >     rows = response(query)
> >   File "/opt/web2py/gluon/sql.py", line 3232, in response
> >     db._execute(query)
> >   File "/opt/web2py/gluon/sql.py", line 977, in 
> >     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
> >   File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line 166,
> > in execute
> >     self.errorhandler(self, exc, value)
> >   File "/var/lib/python-support/python2.5/MySQLdb/connections.py", line
> > 35, in defaulterrorhandler
> >     raise errorclass, errorvalue
> > ProgrammingError: (2014, "Commands out of sync; you can't run this
> > command now")
>
> > Or e.g.:
>
> > Traceback (most recent call last):
> >   File "/opt/web2py/gluon/main.py", line 475, in wsgibase
> >     BaseAdapter.close_all_instances(BaseAdapter.rollback)
> >   File "/opt/web2py/gluon/sql.py", line 810, in close_all_instances
> >     action(instance)
> >   File "/opt/web2py/gluon/sql.py", line 1393, in rollback
> >     self._connection.rollback()
> > ProgrammingError: (2014, "Commands out of sync; you can't run this
> > command now")
>
> > Do you have any tips how to aviod these errors?
>
> > Thanks!
>
> - --
> David Zejda, Open-IT cz
> web development & serviceshttp://www.o-it.info
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org
>
> iEYEARECAAYFAkzZhPcACgkQ3oCkkciamVGyjwCfc0HsoJyvD8DuRWDjT02UJwae
> U0cAmgKsRs7vhz2j5MTljR6TQDulBvt9
> =HFwI
> -END PGP SIGNATURE-


[web2py] Re: "UnicodeDecodeError: 'ascii' codec can't decode byte ...

2010-11-09 Thread mdipierro
As a debug check. I'd like to see what you gate if you "print data"
before the update.
Just in case what you put it in it is not what you get.

On Nov 9, 1:25 pm, Omri  wrote:
> in the qooxdoo application, I define data as
> data = {name: "Prüfung", textfield : "Etwas mit umlaut- üäüöö"}
> and then send it through an asynchronous call (using
> qx.io.remote.Rpc.callAsync)
>
> On Tue, Nov 9, 2010 at 19:42, mdipierro  wrote:
> > can you print data? What is in data?
>
> > On Nov 9, 12:20 pm, Omri  wrote:
> > > I did some tryouts and it seems that the only problem is with the
> > > update method, and then only when called through service.jsonrpc. I
> > > created the following model:
>
> > > db.define_table("debug_stuff",
> > >         Field("name", length=100),
> > >         Field("textfield", "text"),
> > >         format="%(name)s")
>
> > > and defined the following function in the controller (default):
>
> > > @service.jsonrpc
> > > def debug_umlauts(data):
> > >         # db["debug_stuff"].insert(**data)  #  <--- Worked, no problem
> > >         # db(db["debug_stuff"]["id"] == 2).update(**data)   # <--- Didn't
> > > work
> > >         db(db["debug_stuff"]["id"] == 2).update(name = data['name'],
> > > textfield=data['textfield'])  # <--- Worked
> > >         return "OK update"
>
> > > The only line that didn't work was the second one, where I tried to
> > > use the **data for the update method. The problem is that I want the
> > > method to be general, and therefore cannot use the method of the third
> > > line to specify for .update what fields I'm updating.
>
> > > Thanks,
> > > Omri
>
> > > On Nov 8, 5:19 pm, mdipierro  wrote:
>
> > > > Can you try put a u in front of the string u"..."
>
> > > > On Nov 8, 5:30 am, Omri  wrote:
>
> > > > > Hello,
>
> > > > > I'm having a unicode problem with the DAL.
>
> > > > > I'm developing a (mainly) RPC database application with qooxdoo as JS
> > > > > framework and web2py as the webserver.
>
> > > > > I have created a fairly generic update_record function which simply
> > > > > gets two input variables - a table name and a data dictionary with
> > > > > name/value pairs which correspond to the fields of the table.
> > > > > My function looks like this:
>
> > > > > def update_record(table_name, data):
> > > > >         db(db[table_name]['id'] == data['id']).update(**data)
> > > > >         return db(db[table_name]['id'] == data['id']).select()
>
> > > > > My application should work both in English and in German, and my
> > > > > problem is that when I try to update a string value with an Umlaut
> > > > > (example - "Überwlad") I get an error:
> > > > > "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in
> > > > > position..."
>
> > > > > I am able to insert records to the database with Umlauts, but I use a
> > > > > different method for the insert. I use the syntax of .insert(name =
> > > > > value, name2 = value2,...).
>
> > > > > I tried to encode all the data keys which are unicode objects without
> > > > > success, it keeps raising the same error.
>
> > > > > Am I missing something here, or is this a bug? And more
> > interestingly,
> > > > > how can it be solved?
>
> > > > > Thanks,
> > > > > Omri
>
>


Re: [web2py] Re: "UnicodeDecodeError: 'ascii' codec can't decode byte ...

2010-11-09 Thread Omri
in the qooxdoo application, I define data as
data = {name: "Prüfung", textfield : "Etwas mit umlaut- üäüöö"}
and then send it through an asynchronous call (using
qx.io.remote.Rpc.callAsync)



On Tue, Nov 9, 2010 at 19:42, mdipierro  wrote:

> can you print data? What is in data?
>
> On Nov 9, 12:20 pm, Omri  wrote:
> > I did some tryouts and it seems that the only problem is with the
> > update method, and then only when called through service.jsonrpc. I
> > created the following model:
> >
> > db.define_table("debug_stuff",
> > Field("name", length=100),
> > Field("textfield", "text"),
> > format="%(name)s")
> >
> > and defined the following function in the controller (default):
> >
> > @service.jsonrpc
> > def debug_umlauts(data):
> > # db["debug_stuff"].insert(**data)  #  <--- Worked, no problem
> > # db(db["debug_stuff"]["id"] == 2).update(**data)   # <--- Didn't
> > work
> > db(db["debug_stuff"]["id"] == 2).update(name = data['name'],
> > textfield=data['textfield'])  # <--- Worked
> > return "OK update"
> >
> > The only line that didn't work was the second one, where I tried to
> > use the **data for the update method. The problem is that I want the
> > method to be general, and therefore cannot use the method of the third
> > line to specify for .update what fields I'm updating.
> >
> > Thanks,
> > Omri
> >
> > On Nov 8, 5:19 pm, mdipierro  wrote:
> >
> > > Can you try put a u in front of the string u"..."
> >
> > > On Nov 8, 5:30 am, Omri  wrote:
> >
> > > > Hello,
> >
> > > > I'm having a unicode problem with the DAL.
> >
> > > > I'm developing a (mainly) RPC database application with qooxdoo as JS
> > > > framework and web2py as the webserver.
> >
> > > > I have created a fairly generic update_record function which simply
> > > > gets two input variables - a table name and a data dictionary with
> > > > name/value pairs which correspond to the fields of the table.
> > > > My function looks like this:
> >
> > > > def update_record(table_name, data):
> > > > db(db[table_name]['id'] == data['id']).update(**data)
> > > > return db(db[table_name]['id'] == data['id']).select()
> >
> > > > My application should work both in English and in German, and my
> > > > problem is that when I try to update a string value with an Umlaut
> > > > (example - "Überwlad") I get an error:
> > > > "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in
> > > > position..."
> >
> > > > I am able to insert records to the database with Umlauts, but I use a
> > > > different method for the insert. I use the syntax of .insert(name =
> > > > value, name2 = value2,...).
> >
> > > > I tried to encode all the data keys which are unicode objects without
> > > > success, it keeps raising the same error.
> >
> > > > Am I missing something here, or is this a bug? And more
> interestingly,
> > > > how can it be solved?
> >
> > > > Thanks,
> > > > Omri
> >
> >
>


[web2py] Re: IMG helper and _width

2010-11-09 Thread mdipierro
{{=IMG(_src=URL(r=request,a='base',c='static',f='base/card/logos/' +
logo[0].link) _width="228px")}}

should be

{{=IMG(_src=URL('static','base/card/logos/%s' % slogo[0].link),
_width="228px")}}

, was missing
On Nov 9, 1:07 pm, annet  wrote:
> I get an error on the following code:
>
> {{=IMG(_src=URL(r=request,a='base',c='static',f='base/card/logos/' +
> logo[0].link) _width="228px")}}
>
> Traceback (most recent call last):
>   File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/
> restricted.py", line 186, in restricted
>     ccode = compile2(code,layer)
>   File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/
> restricted.py", line 173, in compile2
>     return compile(code.rstrip().replace('\r\n','\n')+'\n', layer,
> 'exec')
>   File "/Library/Python/2.5/site-packages/web2py_1.87.3/applications/
> init/views/locator/businesscard.html", line 45
>     response.write(IMG(_src=URL(r=request,a='base',c='static',f='base/
> card/logos/' + logo[0].link) _width="228px"))
>
> SyntaxError: invalid syntax
>
> The ^ sign is under the h of _width="228px"
>
> Does one of you know the correct syntax?
>
> Kind regards,
>
> Annet.


[web2py] Re: is there a "insert or replace" for the DAL

2010-11-09 Thread mdipierro
No but you can do

db(condition).update(**d) or db.table.insert(**d)

On Nov 9, 1:00 pm, Stef Mientki  wrote:
> hello,
>
> I wonder if there is a "insert or replace" or another mechanism, when insert 
> fails ?
>
> thanks,
> Stef Mientki


[web2py] IMG helper and _width

2010-11-09 Thread annet
I get an error on the following code:

{{=IMG(_src=URL(r=request,a='base',c='static',f='base/card/logos/' +
logo[0].link) _width="228px")}}


Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/
restricted.py", line 186, in restricted
ccode = compile2(code,layer)
  File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/
restricted.py", line 173, in compile2
return compile(code.rstrip().replace('\r\n','\n')+'\n', layer,
'exec')
  File "/Library/Python/2.5/site-packages/web2py_1.87.3/applications/
init/views/locator/businesscard.html", line 45
response.write(IMG(_src=URL(r=request,a='base',c='static',f='base/
card/logos/' + logo[0].link) _width="228px"))

SyntaxError: invalid syntax


The ^ sign is under the h of _width="228px"

Does one of you know the correct syntax?


Kind regards,

Annet.



[web2py] is there a "insert or replace" for the DAL

2010-11-09 Thread Stef Mientki
hello,

I wonder if there is a "insert or replace" or another mechanism, when insert 
fails ?

thanks,
Stef Mientki


[web2py] Re: dynamic representation for crud.select / SQLTABLE

2010-11-09 Thread mdipierro
Sorry there is not. You may better off looping

{{for row in rows:}}
... build your row ...
{{pass}}

On Nov 9, 12:37 pm, Carlos  wrote:
> Hi all,
>
> I'm using crud.select / SQLTABLE, and I need to show one column with
> links/actions generated dynamically based on conditions found for each
> row data.
>
> I believe I can not use 'represent' because that's linked to a single
> field only (lambda field: ...).
>
> Is there something like "lambda row: ..." where I can access all
> necessary fields for each row and show dynamic options based on each
> row data?.
>
> Can virtual fields provide the dynamic behavior I need for
> crud.select / SQLTABLE?.
>
> Any ideas?.
>
> Thanks!,
>
>    Carlos


[web2py] Re: "UnicodeDecodeError: 'ascii' codec can't decode byte ...

2010-11-09 Thread mdipierro
can you print data? What is in data?

On Nov 9, 12:20 pm, Omri  wrote:
> I did some tryouts and it seems that the only problem is with the
> update method, and then only when called through service.jsonrpc. I
> created the following model:
>
> db.define_table("debug_stuff",
>         Field("name", length=100),
>         Field("textfield", "text"),
>         format="%(name)s")
>
> and defined the following function in the controller (default):
>
> @service.jsonrpc
> def debug_umlauts(data):
>         # db["debug_stuff"].insert(**data)  #  <--- Worked, no problem
>         # db(db["debug_stuff"]["id"] == 2).update(**data)   # <--- Didn't
> work
>         db(db["debug_stuff"]["id"] == 2).update(name = data['name'],
> textfield=data['textfield'])  # <--- Worked
>         return "OK update"
>
> The only line that didn't work was the second one, where I tried to
> use the **data for the update method. The problem is that I want the
> method to be general, and therefore cannot use the method of the third
> line to specify for .update what fields I'm updating.
>
> Thanks,
> Omri
>
> On Nov 8, 5:19 pm, mdipierro  wrote:
>
> > Can you try put a u in front of the string u"..."
>
> > On Nov 8, 5:30 am, Omri  wrote:
>
> > > Hello,
>
> > > I'm having a unicode problem with the DAL.
>
> > > I'm developing a (mainly) RPC database application with qooxdoo as JS
> > > framework and web2py as the webserver.
>
> > > I have created a fairly generic update_record function which simply
> > > gets two input variables - a table name and a data dictionary with
> > > name/value pairs which correspond to the fields of the table.
> > > My function looks like this:
>
> > > def update_record(table_name, data):
> > >         db(db[table_name]['id'] == data['id']).update(**data)
> > >         return db(db[table_name]['id'] == data['id']).select()
>
> > > My application should work both in English and in German, and my
> > > problem is that when I try to update a string value with an Umlaut
> > > (example - "Überwlad") I get an error:
> > > "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in
> > > position..."
>
> > > I am able to insert records to the database with Umlauts, but I use a
> > > different method for the insert. I use the syntax of .insert(name =
> > > value, name2 = value2,...).
>
> > > I tried to encode all the data keys which are unicode objects without
> > > success, it keeps raising the same error.
>
> > > Am I missing something here, or is this a bug? And more interestingly,
> > > how can it be solved?
>
> > > Thanks,
> > > Omri
>
>


[web2py] Re: Windows binary distribution

2010-11-09 Thread mdipierro
true

On Nov 9, 12:19 pm, Branko Vukelic  wrote:
> On Tue, Nov 9, 2010 at 4:12 PM, Bruno Rocha  wrote:
> > I Just included PySerial and another modules to access peripherals on host
> > machine.
> > I just take web2py, include my app folder and the modules/binaries I needed,
> > I dont think it broke any license. or I am wrong?
>
> You can't break GPL if you do not redistribute the code.
> Redistribution includes such acts as selling, p2p sharing, posting on
> Internet...
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog:http://www.brankovukelic.com/
> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca:http://identi.ca/foxbunny
>
> Gimp Brushmakers Guildhttp://bit.ly/gbg-group


[web2py] Re: Command-line support

2010-11-09 Thread mdipierro
Many things you can already do:

On Nov 9, 11:40 am, blackthorne  wrote:
> I think it would be important to have it all, but at least...
> generate model
> sync model
> create application (skeleton)

mkdir applications/myapp
cp -r applications/welcome/* application/myapp

> install packet application

mkdir applications/myapp
cp applications/myapp
tar zxvf web2py.app.myapp.w2p

> compile application

web2py.py -S admin
>>> from gluon.admin import app_compile: app_compile('myapp',request)

> pack application

web2py.py -S admin
>>> from gluon.admin import app_pack: print app_pack('myapp',request)


> uninstall application

rm -r applications/myapp

> update language files

web2py.py -S admin
>>> from gluon.languages import update_all_languages; 
>>> update_all_languages('applications/myapp')

> change admin password

python -c "from gluon.main import save_password;
save_password(raw_input('admin password: '),80)"

> upload (from url) & install packed application


mkdir applications/myapp
cp applications/myapp
wget http:///web2py.app.myapp.w2p
tar zxvf web2py.app.myapp.w2p


> Secondary stuff
> --
> search applications from Online Application Repository
> deploy on gae

cd ..
appcfg.py web2py

> wizard in command-line
>
> --
> search applications from Online Application Repository
> install apps
> deploy on gae
> wizard in command-line
>
> On Nov 9, 1:35 pm, mdipierro  wrote:
>
> > What operations specifically do you want to do in shell mode?
>
> > On Nov 9, 7:20 am, blackthorne  wrote:
>
> > > Well, shell mode is not quite what I was looking for but thank you.
> > > Many of us, prefer to use a common IDE such as Netbeans or Emacs or
> > > Wing, or even an OS like Emacs. The command-line is a first class tool
> > > for developers and it is great to integrate with my IDE or bash
> > > script.
> > > It would be nice to be able to issue commands that I could use with my
> > > IDE, or bash script.
>
> > > This is relevant. Many people using other frameworks vibrate just to
> > > think about web frameworks without this interface.
>
> > > Thank you
> > > Best regards
>
> > > On Nov 9, 12:24 pm, Bruno Rocha  wrote:
>
> > > > You can use from the command line
>
> > > > -S Run in shell mode
> > > > appname connect with an app
> > > > -M execute the app models
>
> > > > $python web2py.py -S appname -M
>
> > > > to generate SQL code you have to use _ before DAL methods such as:
>
> > > > db(...)_select()
>
> > > > 2010/11/9 blackthorne 
>
> > > > > Is there a way so that I can use all web2py operations, such as
> > > > > generating the SQL code from the model definition from the command-
> > > > > line or is the web interface our only option?
>
> > > > > Thank you
> > > > > Best regards
>
> > > > --
>
> > > >http://rochacbruno.com.br
>
>


[web2py] dynamic representation for crud.select / SQLTABLE

2010-11-09 Thread Carlos
Hi all,

I'm using crud.select / SQLTABLE, and I need to show one column with
links/actions generated dynamically based on conditions found for each
row data.

I believe I can not use 'represent' because that's linked to a single
field only (lambda field: ...).

Is there something like "lambda row: ..." where I can access all
necessary fields for each row and show dynamic options based on each
row data?.

Can virtual fields provide the dynamic behavior I need for
crud.select / SQLTABLE?.

Any ideas?.

Thanks!,

   Carlos


[web2py] Re: Manipulate Rows Object and/or SQLTABLE

2010-11-09 Thread mdipierro
I see two options:

1) use

db.table.field.represent = lambda value: DIV(value)

and give any representation you want to the field value.

2) If this does not work make your own SQLTABLE helper:

def mytable(rows, cols):
return  TABLE(*[TR(*[TD(row[c]) for c in cols]) for row in rows)



On Nov 9, 11:36 am, villas  wrote:
> I want to customize the result of SQLTABLE so that it can make me a
> nice table without lines and lines of code in my view file.  To
> achieve that,  I need for example to:
>
> 1) Add columns to hold icons and links and extra stuff.
> 2) Customize the rows, e.g.  links which depend on content,  different
> icons etc
>
> After giving it some thought,  I think I should leave SQLTABLE alone
> and concentrate on 'improving' the rows object so that it contains
> everything I want before passing it to SQLTABLE.
>
> To do 1) I can simply add a column to the rows object. How can I best
> do that?
> To do 2) I could iterate the rows object and make changes.
>
> Or  maybe there is another way.
> I appreciate that if I want to style the HTML table,  I'll have to
> write my code in the form (which I am trying to avoid).
>
> Thanks,
> -D


[web2py] Re: "UnicodeDecodeError: 'ascii' codec can't decode byte ...

2010-11-09 Thread Omri
I did some tryouts and it seems that the only problem is with the
update method, and then only when called through service.jsonrpc. I
created the following model:

db.define_table("debug_stuff",
Field("name", length=100),
Field("textfield", "text"),
format="%(name)s")

and defined the following function in the controller (default):

@service.jsonrpc
def debug_umlauts(data):
# db["debug_stuff"].insert(**data)  #  <--- Worked, no problem
# db(db["debug_stuff"]["id"] == 2).update(**data)   # <--- Didn't
work
db(db["debug_stuff"]["id"] == 2).update(name = data['name'],
textfield=data['textfield'])  # <--- Worked
return "OK update"

The only line that didn't work was the second one, where I tried to
use the **data for the update method. The problem is that I want the
method to be general, and therefore cannot use the method of the third
line to specify for .update what fields I'm updating.

Thanks,
Omri

On Nov 8, 5:19 pm, mdipierro  wrote:
> Can you try put a u in front of the string u"..."
>
> On Nov 8, 5:30 am, Omri  wrote:
>
> > Hello,
>
> > I'm having a unicode problem with the DAL.
>
> > I'm developing a (mainly) RPC database application with qooxdoo as JS
> > framework and web2py as the webserver.
>
> > I have created a fairly generic update_record function which simply
> > gets two input variables - a table name and a data dictionary with
> > name/value pairs which correspond to the fields of the table.
> > My function looks like this:
>
> > def update_record(table_name, data):
> >         db(db[table_name]['id'] == data['id']).update(**data)
> >         return db(db[table_name]['id'] == data['id']).select()
>
> > My application should work both in English and in German, and my
> > problem is that when I try to update a string value with an Umlaut
> > (example - "Überwlad") I get an error:
> > "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in
> > position..."
>
> > I am able to insert records to the database with Umlauts, but I use a
> > different method for the insert. I use the syntax of .insert(name =
> > value, name2 = value2,...).
>
> > I tried to encode all the data keys which are unicode objects without
> > success, it keeps raising the same error.
>
> > Am I missing something here, or is this a bug? And more interestingly,
> > how can it be solved?
>
> > Thanks,
> > Omri
>
>


Re: [web2py] Re: Windows binary distribution

2010-11-09 Thread Branko Vukelic
On Tue, Nov 9, 2010 at 4:12 PM, Bruno Rocha  wrote:
> I Just included PySerial and another modules to access peripherals on host
> machine.
> I just take web2py, include my app folder and the modules/binaries I needed,
> I dont think it broke any license. or I am wrong?

You can't break GPL if you do not redistribute the code.
Redistribution includes such acts as selling, p2p sharing, posting on
Internet...

-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


[web2py] Re: Command-line support

2010-11-09 Thread blackthorne
I think it would be important to have it all, but at least...
generate model
sync model
create application (skeleton)
install packet application
compile application
pack application
uninstall application
update language files
change admin password
upload (from url) & install packed application

Secondary stuff
--
search applications from Online Application Repository
deploy on gae
wizard in command-line


--
search applications from Online Application Repository
install apps
deploy on gae
wizard in command-line

On Nov 9, 1:35 pm, mdipierro  wrote:
> What operations specifically do you want to do in shell mode?
>
> On Nov 9, 7:20 am, blackthorne  wrote:
>
>
>
> > Well, shell mode is not quite what I was looking for but thank you.
> > Many of us, prefer to use a common IDE such as Netbeans or Emacs or
> > Wing, or even an OS like Emacs. The command-line is a first class tool
> > for developers and it is great to integrate with my IDE or bash
> > script.
> > It would be nice to be able to issue commands that I could use with my
> > IDE, or bash script.
>
> > This is relevant. Many people using other frameworks vibrate just to
> > think about web frameworks without this interface.
>
> > Thank you
> > Best regards
>
> > On Nov 9, 12:24 pm, Bruno Rocha  wrote:
>
> > > You can use from the command line
>
> > > -S Run in shell mode
> > > appname connect with an app
> > > -M execute the app models
>
> > > $python web2py.py -S appname -M
>
> > > to generate SQL code you have to use _ before DAL methods such as:
>
> > > db(...)_select()
>
> > > 2010/11/9 blackthorne 
>
> > > > Is there a way so that I can use all web2py operations, such as
> > > > generating the SQL code from the model definition from the command-
> > > > line or is the web interface our only option?
>
> > > > Thank you
> > > > Best regards
>
> > > --
>
> > >http://rochacbruno.com.br


[web2py] Manipulate Rows Object and/or SQLTABLE

2010-11-09 Thread villas
I want to customize the result of SQLTABLE so that it can make me a
nice table without lines and lines of code in my view file.  To
achieve that,  I need for example to:

1) Add columns to hold icons and links and extra stuff.
2) Customize the rows, e.g.  links which depend on content,  different
icons etc

After giving it some thought,  I think I should leave SQLTABLE alone
and concentrate on 'improving' the rows object so that it contains
everything I want before passing it to SQLTABLE.

To do 1) I can simply add a column to the rows object. How can I best
do that?
To do 2) I could iterate the rows object and make changes.

Or  maybe there is another way.
I appreciate that if I want to style the HTML table,  I'll have to
write my code in the form (which I am trying to avoid).

Thanks,
-D


Re: [web2py] Re: ProgrammingError: (2014, "Commands out of sync; you can't run this command now")

2010-11-09 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi :)

E.g. now the exception was raised by the web2py internal db
initialization routine:

28: db = SQLDB('mysql://myus:myp...@localhost:330h6/mydb', pool_size=10)

Traceback (most recent call last):
  File "/opt/web2py/gluon/restricted.py", line 188, in restricted
exec ccode in environment
  File "/opt/web2py/applications/myapp/compiled/models_db.py", line 28,
in 
  File "/opt/web2py/gluon/sql.py", line 978, in __init__
self._execute('SET FOREIGN_KEY_CHECKS=1;')
  File "/opt/web2py/gluon/sql.py", line 977, in 
self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
  File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line 166,
in execute
self.errorhandler(self, exc, value)
  File "/var/lib/python-support/python2.5/MySQLdb/connections.py", line
35, in defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (2014, "Commands out of sync; you can't run this
command now")

I'm thinking about possibility to raise the size of my poll. But in the
past with higher poll I think I was receiving more OperationalError:
(2006, 'MySQL server has gone away'). Because I am referring to a live
server, I would prefer to avoid experiments which could make frequency
of db errors even worse :)

thanks & wishing you a nice day..
David

mdipierro wrote:
> I cannot say without looking at the code. MySQL has lots of
> undocumented quirks about what you can do and what you cannot do
> within one transaction.
> 
> Try add a db.commit() after each insert/unpdate/form.accepts/
> crud.update/crud.select IF you do a select after that.
> 
> Do you have any try:...except in your controllers and db queries
> inside?
> 
> 
> On Nov 8, 2:57 am, David Zejda  wrote:
> The MySQL error occurs quite often, several times every day. The app has
> about 2 page views daily and heavily communicates with db (tens of
> queries per request, in db I have about 100 tables). Currently I have
> pool with size for 10 connections.
> 
> Meaning of the error message is described here:
> 
> http://dev.mysql.com/doc/refman/4.1/en/commands-out-of-sync.html
> 
> It seems that with MySQL statements on the same db connection have to be
> exhausted one-by-one, never in parallel. Two statements returning data
> to the process must be using separate DBConnections (possibly to the
> same host/db). Multiple statements on the same connection are supported,
> but only 1 may be in a state to 'fetch' data.
> 
> Traces for the errors look like this:
> 
>   File "/opt/web2py/gluon/sql.py", line 3378, in count
> return self.select('count(*)')[0]._extra['count(*)']
>   File "/opt/web2py/gluon/sql.py", line 3237, in select
> rows = response(query)
>   File "/opt/web2py/gluon/sql.py", line 3232, in response
> db._execute(query)
>   File "/opt/web2py/gluon/sql.py", line 977, in 
> self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
>   File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line 166,
> in execute
> self.errorhandler(self, exc, value)
>   File "/var/lib/python-support/python2.5/MySQLdb/connections.py", line
> 35, in defaulterrorhandler
> raise errorclass, errorvalue
> ProgrammingError: (2014, "Commands out of sync; you can't run this
> command now")
> 
> Or e.g.:
> 
> Traceback (most recent call last):
>   File "/opt/web2py/gluon/main.py", line 475, in wsgibase
> BaseAdapter.close_all_instances(BaseAdapter.rollback)
>   File "/opt/web2py/gluon/sql.py", line 810, in close_all_instances
> action(instance)
>   File "/opt/web2py/gluon/sql.py", line 1393, in rollback
> self._connection.rollback()
> ProgrammingError: (2014, "Commands out of sync; you can't run this
> command now")
> 
> Do you have any tips how to aviod these errors?
> 
> Thanks!
> 

- --
David Zejda, Open-IT cz
web development & services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkzZhPcACgkQ3oCkkciamVGyjwCfc0HsoJyvD8DuRWDjT02UJwae
U0cAmgKsRs7vhz2j5MTljR6TQDulBvt9
=HFwI
-END PGP SIGNATURE-


[web2py] Can´t do redirect

2010-11-09 Thread yamandu
After upgraded I got exception when try to redirect using
redirect(URL()).

I used to do :
return redirect(URL(r=request, f='modelo'))

but it works no more, gives me a ticket that don´t tells the error
just the line.
The folowing is an exerpt from the ticket thrown by the book example:

def redirect(location, how=303):
location = location.replace('\r', '%0D').replace('\n', '%0A')
raise HTTP(how,
   'You are being redirected here' %
location,
Location=location)

* Location: undefined
* location: '/welcome/default/index/1/2/3?a=b'




[web2py] [Link] Form validation design

2010-11-09 Thread Bruno Rocha
Interesting about form validation design

http://webdesign.tutsplus.com/articles/design-theory/user-experience-designing-form-validation-the-right-way/


[web2py] Re: Plugin_JqGrid long-polling

2010-11-09 Thread AsmanCom
How can I add the JavaScript:
var server_time="test"

to the vars dict:
callback = URL(r=request,c='plugin_jqgrid',f='data',
   vars=dict(tablename=table._tablename,
 columns=','.join(columns),
 fieldname=fieldname or '',
 fieldvalue=fieldvalue,
 ))

???

THX

On 7 Nov., 15:25, "mr.freeze"  wrote:
> Anything that is put in the vars dict of a URL will end up in
> request.vars when navigated to. For example:
> URL(vars=dict(server_time=request.now)) will be
> request.vars.server_time.  Is that what you're asking?
>
> On Nov 7, 3:12 am, AsmanCom  wrote:
>
> > Can I include the var server_time in the vars=dict somehow?
>
> > THX
>
>


Re: [web2py] Re: RFC: Why web2py rocks

2010-11-09 Thread Branko Vukelic
On Tue, Nov 9, 2010 at 1:44 PM, Bruno Rocha  wrote:
> I just need to find out how to edit .svg in a Mac. I'll try InkScape for
> Mac/X11

It's an Inkscape SVG, so Inkscape would be your best bet. Just so you
know, line wrapping is manual (that's how I did it, that is).



-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


[web2py] Re: making layout plugin

2010-11-09 Thread mdipierro
This could be another typos in the book.

layout.html should be

{{extend 'plugin_layout_name/layout.html'}}
{{include}}

but replacing the file entirely is fine.



On Nov 9, 4:25 am, John Murphy  wrote:
> There are numerous web2py themes, but none of them are very good. So I
> decided to make a nice one based 
> on:http://demo.woothemes.com/?name=meta-morphosis.
>
> I'm creating a layout plugin according to these instructions:
> -http://web2py.com/book/default/chapter/13#Layout-plugins
> -http://www.web2py.com/AlterEgo/default/show/92
>
> I tried the following from the official book:
>
> > Third, modify the "views/layout.html" so that it simply reads:
>
> 1. {{include 'plugin_layout_name/layout.html'}}
>
> It almost works, however the {{include}} in my layout.html is not expanded.
> Earlier in the same file, "{{include 'web2py_ajax.html'}}" expands as
> expected.
> If I over-write the "views/layout.html" file instead of {{including}} it as
> recommended, it works. Any ideas as to why?
>
> Also, what's the easiest way to package this as a web2py plugin? 
> (Like:http://www.web2py.com/layouts/static/plugin_layouts/plugins/web2py.pl...
> )
> I'd be happy to share my work if anyone is interested. I intentionally
> picked a free, GPL'ed theme.
>
> Thanks,
> John
> --www.leftium.com


[web2py] making layout plugin

2010-11-09 Thread John Murphy
There are numerous web2py themes, but none of them are very good. So I
decided to make a nice one based on:
http://demo.woothemes.com/?name=meta-morphosis.

I'm creating a layout plugin according to these instructions:
- http://web2py.com/book/default/chapter/13#Layout-plugins
- http://www.web2py.com/AlterEgo/default/show/92

I tried the following from the official book:

> Third, modify the "views/layout.html" so that it simply reads:

1. {{include 'plugin_layout_name/layout.html'}}


It almost works, however the {{include}} in my layout.html is not expanded.
Earlier in the same file, "{{include 'web2py_ajax.html'}}" expands as
expected.
If I over-write the "views/layout.html" file instead of {{including}} it as
recommended, it works. Any ideas as to why?

Also, what's the easiest way to package this as a web2py plugin? (Like:
http://www.web2py.com/layouts/static/plugin_layouts/plugins/web2py.plugin.layout_ConcreteV2.w2p
)
I'd be happy to share my work if anyone is interested. I intentionally
picked a free, GPL'ed theme.

Thanks,
John
-- 
www.leftium.com 


Re: [web2py] Re: RFC: Why web2py rocks

2010-11-09 Thread Branko Vukelic
On Tue, Nov 9, 2010 at 3:04 PM, Branko Vukelic  wrote:
> On Tue, Nov 9, 2010 at 1:44 PM, Bruno Rocha  wrote:
>> I just need to find out how to edit .svg in a Mac. I'll try InkScape for
>> Mac/X11
>
> It's an Inkscape SVG, so Inkscape would be your best bet. Just so you
> know, line wrapping is manual (that's how I did it, that is).

If Inkscape doesn't work for you, e-mail me the translation, and I'll
enter it for you.


-- 
Branko Vukelić

bg.bra...@gmail.com
stu...@brankovukelic.com

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)
I hang out on identi.ca: http://identi.ca/foxbunny

Gimp Brushmakers Guild
http://bit.ly/gbg-group


[web2py] Re: number of logged users

2010-11-09 Thread mdipierro
This is not a well defined concept. You can look into sessions/ and
figure out which files were modified within the last N minutes.

On Nov 9, 4:50 am, salbefe  wrote:
> Hello,
>
> I would like to know how can I obtain the number of the current users
> that are logged on.
>
> Thanks in advance!


[web2py] Re: How to switch back to English for the Admin interface?

2010-11-09 Thread mdipierro
wait. You should not need to delete files. The language is set by your
browser.

On Nov 9, 3:41 am, Stefan Scholl  wrote:
> Oops, found it 5 minutes later.
>
> In case somebody wants to switch back to English, too:
>
> Delete (or rename) your language in applications/admin/languages


Re: [web2py] Re: RFC: Why web2py rocks

2010-11-09 Thread Bruno Rocha
I am working on Inkscape for Mac! very nice!, I should never open coreldraw
or Illustrator anymore.

Thank you!

2010/11/9 Branko Vukelic 

> On Tue, Nov 9, 2010 at 3:04 PM, Branko Vukelic 
> wrote:
> > On Tue, Nov 9, 2010 at 1:44 PM, Bruno Rocha 
> wrote:
> >> I just need to find out how to edit .svg in a Mac. I'll try InkScape for
> >> Mac/X11
> >
> > It's an Inkscape SVG, so Inkscape would be your best bet. Just so you
> > know, line wrapping is manual (that's how I did it, that is).
>
> If Inkscape doesn't work for you, e-mail me the translation, and I'll
> enter it for you.
>
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog: http://www.brankovukelic.com/
> Check out my portfolio: http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca: http://identi.ca/foxbunny
>
> Gimp Brushmakers Guild
> http://bit.ly/gbg-group
>



-- 

http://rochacbruno.com.br


[web2py] Re: new admin in trunk

2010-11-09 Thread mdipierro
Perfect. Thanks. I did not know.

On Nov 9, 1:54 am, Branko Vukelic  wrote:
> On Tue, Nov 9, 2010 at 8:05 AM, mdipierro  wrote:
> >> - 'logout' in french ('deconnexion') is too long for the button area
> >> (top right buttons in the design view).
>
> > this is a major problem. Now that all buttons have a fixed size, this
> > is going to break on multiple languages, and it is going to constrain
> > new buttons we may want to add.
>
> This is not a big problem. Buttons can be made to be arbitrary width
> by just removing the width property and providing the background image
> that is wide enough.
>
> Speaking of which, here are the small button backgrounds made to be
> 240px wide. Massimo, please put these in the images folder and
> database administration problem should be gone. I've also attached the
> help icon just in case you don't have it.
>
> As for the code, I cannot make the adjustment right now as I have to
> go to work. If you don't beat me to it, I'll send in the patch tonite.
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog:http://www.brankovukelic.com/
> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca:http://identi.ca/foxbunny
>
> Gimp Brushmakers Guildhttp://bit.ly/gbg-group
>
>  small_button.png
> 1KViewDownload
>
>  small_special_button.png
> 1KViewDownload
>
>  help.png
> < 1KViewDownload


Re: [web2py] Re: RFC: Why web2py rocks

2010-11-09 Thread Bruno Rocha
I just need to find out how to edit .svg in a Mac. I'll try InkScape for
Mac/X11

2010/11/9 Branko Vukelic 

> On Tue, Nov 9, 2010 at 2:54 AM, Bruno Rocha  wrote:
> > Branko, I want to have a portuguese version, do you mind if I edit the
> file
> > translating into portuguese?
>
> Sure, Bruno. Here's the SVG. You need two fonts (both are free):
>
> http://www.fontsquirrel.com/fonts/ChunkFive
> http://www.fontcubes.com/Sansation.font
>
> I hereby release this work under Creative Commons Unported 3.0
> Attribution-Share-Alike.
>
>
> --
> Branko Vukelić
>
> bg.bra...@gmail.com
> stu...@brankovukelic.com
>
> Check out my blog: http://www.brankovukelic.com/
> Check out my portfolio: http://www.flickr.com/photos/foxbunny/
> Registered Linux user #438078 (http://counter.li.org/)
> I hang out on identi.ca: http://identi.ca/foxbunny
>
> Gimp Brushmakers Guild
> http://bit.ly/gbg-group
>



-- 

http://rochacbruno.com.br


[web2py] Re: Command-line support

2010-11-09 Thread blackthorne
Well, shell mode is not quite what I was looking for but thank you.
Many of us, prefer to use a common IDE such as Netbeans or Emacs or
Wing, or even an OS like Emacs. The command-line is a first class tool
for developers and it is great to integrate with my IDE or bash
script.
It would be nice to be able to issue commands that I could use with my
IDE, or bash script.

This is relevant. Many people using other frameworks vibrate just to
think about web frameworks without this interface.

Thank you
Best regards

On Nov 9, 12:24 pm, Bruno Rocha  wrote:
> You can use from the command line
>
> -S Run in shell mode
> appname connect with an app
> -M execute the app models
>
> $python web2py.py -S appname -M
>
> to generate SQL code you have to use _ before DAL methods such as:
>
> db(...)_select()
>
> 2010/11/9 blackthorne 
>
> > Is there a way so that I can use all web2py operations, such as
> > generating the SQL code from the model definition from the command-
> > line or is the web interface our only option?
>
> > Thank you
> > Best regards
>
> --
>
> http://rochacbruno.com.br


[web2py] Re: Windows binary distribution

2010-11-09 Thread cjrh
On Nov 9, 2:27 pm, Bruno Rocha  wrote:
> I use this script to create my custom web2py.exe
>
> http://code.google.com/p/web2py/source/browse/setup_exe.py

I just saw the Makefile in the web2py folder now.   It does everything
it seems, except on Windows if you don't have a make available :(

Will try it in an Ubuntu VM.


[web2py] Re: Command-line support

2010-11-09 Thread mdipierro
What operations specifically do you want to do in shell mode?

On Nov 9, 7:20 am, blackthorne  wrote:
> Well, shell mode is not quite what I was looking for but thank you.
> Many of us, prefer to use a common IDE such as Netbeans or Emacs or
> Wing, or even an OS like Emacs. The command-line is a first class tool
> for developers and it is great to integrate with my IDE or bash
> script.
> It would be nice to be able to issue commands that I could use with my
> IDE, or bash script.
>
> This is relevant. Many people using other frameworks vibrate just to
> think about web frameworks without this interface.
>
> Thank you
> Best regards
>
> On Nov 9, 12:24 pm, Bruno Rocha  wrote:
>
> > You can use from the command line
>
> > -S Run in shell mode
> > appname connect with an app
> > -M execute the app models
>
> > $python web2py.py -S appname -M
>
> > to generate SQL code you have to use _ before DAL methods such as:
>
> > db(...)_select()
>
> > 2010/11/9 blackthorne 
>
> > > Is there a way so that I can use all web2py operations, such as
> > > generating the SQL code from the model definition from the command-
> > > line or is the web interface our only option?
>
> > > Thank you
> > > Best regards
>
> > --
>
> >http://rochacbruno.com.br
>
>


[web2py] Re: Windows binary distribution

2010-11-09 Thread cjrh
On Nov 9, 3:34 pm, mdipierro  wrote:
> It is a delicate process that can go wrong and the produced binaries
> may violate the GPL license.

That's a fair point.  I think I am going to use Portable Python
(2.6.1) and the source distro of web2py.   That also gives me a no-
install version.  Among other things, it also includes pywin32 and
PIL, and a few other goodies.


Re: [web2py] Windows binary distribution

2010-11-09 Thread Bruno Rocha
I use this script to create my custom web2py.exe

http://code.google.com/p/web2py/source/browse/setup_exe.py

2010/11/9 cjrh 

> Is there a recipe somewhere showing how the binary win version of
> web2py is produced?   I would like to make my own custom zip for
> easier in-house distribution, and using  different version of python,
> for example.




-- 

http://rochacbruno.com.br


[web2py] twilio context ($100 prize)

2010-11-09 Thread mdipierro
http://blog.twilio.com/2010/11/attention-pythonistas-twilio-has-a-contest-just-for-you-ends-1114.html


[web2py] Re: Windows binary distribution

2010-11-09 Thread mdipierro
I discourage making your own binaries using setup_exe.py unless you
need to package additional binary python modules that do not come with
the official distribution.
It is a delicate process that can go wrong and the produced binaries
may violate the GPL license.

Instead this process is easier:
http://web2py.com/book/default/chapter/12#How-to-Distribute-your-Applications-as-Binaries
and license compliant.

Massimo

On Nov 9, 6:27 am, Bruno Rocha  wrote:
> I use this script to create my custom web2py.exe
>
> http://code.google.com/p/web2py/source/browse/setup_exe.py
>
> 2010/11/9 cjrh 
>
> > Is there a recipe somewhere showing how the binary win version of
> > web2py is produced?   I would like to make my own custom zip for
> > easier in-house distribution, and using  different version of python,
> > for example.
>
> --
>
> http://rochacbruno.com.br


[web2py] Build custom windows binary distro

2010-11-09 Thread cjrh
I would like to make a custom binary distro zip of web2py, using a
different version of python (2.6 or 2.7) and incorporating PIL.

Are there any recipes somewhere showing how to setup the toolchain?  I
already know about the file setup_exe.py in the web2py folder, I
reckon that will feature prominantly in whatever build recipe is
currently being used.


[web2py] Re: RFC: Why web2py rocks

2010-11-09 Thread cjrh
On Nov 9, 12:16 am, mdipierro  wrote:
> This is not the first image I have seen this this format (thin and
> long) but I am not sure I understand what it is intended for.

Beauty.   DeviantArt has a great many like this for Photoshop
tutorials, for example.


[web2py] Windows binary distribution

2010-11-09 Thread cjrh
Is there a recipe somewhere showing how the binary win version of
web2py is produced?   I would like to make my own custom zip for
easier in-house distribution, and using  different version of python,
for example.


Re: [web2py] Command-line support

2010-11-09 Thread Bruno Rocha
You can use from the command line

-S Run in shell mode
appname connect with an app
-M execute the app models

$python web2py.py -S appname -M

to generate SQL code you have to use _ before DAL methods such as:

db(...)_select()

2010/11/9 blackthorne 

> Is there a way so that I can use all web2py operations, such as
> generating the SQL code from the model definition from the command-
> line or is the web interface our only option?
>
> Thank you
> Best regards




-- 

http://rochacbruno.com.br


[web2py] Command-line support

2010-11-09 Thread blackthorne
Is there a way so that I can use all web2py operations, such as
generating the SQL code from the model definition from the command-
line or is the web interface our only option?

Thank you
Best regards


Re: [web2py] Re: Windows binary distribution

2010-11-09 Thread Bruno Rocha
I Just included PySerial and another modules to access peripherals on host
machine.

I just take web2py, include my app folder and the modules/binaries I needed,
I dont think it broke any license. or I am wrong?

2010/11/9 mdipierro 

> I discourage making your own binaries using setup_exe.py unless you
> need to package additional binary python modules that do not come with
> the official distribution.
> It is a delicate process that can go wrong and the produced binaries
> may violate the GPL license.
>
> Instead this process is easier:
>
> http://web2py.com/book/default/chapter/12#How-to-Distribute-your-Applications-as-Binaries
> and license compliant.
>
> Massimo
>
> On Nov 9, 6:27 am, Bruno Rocha  wrote:
> > I use this script to create my custom web2py.exe
> >
> > http://code.google.com/p/web2py/source/browse/setup_exe.py
> >
> > 2010/11/9 cjrh 
> >
> > > Is there a recipe somewhere showing how the binary win version of
> > > web2py is produced?   I would like to make my own custom zip for
> > > easier in-house distribution, and using  different version of python,
> > > for example.
> >
> > --
> >
> > http://rochacbruno.com.br
>



-- 

http://rochacbruno.com.br


[web2py] Error routing

2010-11-09 Thread Ruiwen Chua
Hi all,

I'm trying to route errors like 400, 403 and 404 to nice, clear URLs
like '/error/', '/forbidden/' and '/whoops/'.

Unfortunately, the Web2Py Book's section on error routing (http://
www.web2py.com/book/default/chapter/04?search=error#Routes-on-Error)
is pretty sparse, and I haven't been able to get this to work.

I have this section both within my application/app/routes.py (snipped
for brevity):

routes_in = (
('/error/', '/app/default/error/'),
)

routes_onerror = [
   (r'app/400', r'/error/')
]

However, I keep getting redirected to URLs like "error/?
code=400&ticket=None&requested_uri=None&request_url=/deh/index"

Is there a way I can hide the query string after the "error/"?


Cheers
Ruiwen


[web2py] number of logged users

2010-11-09 Thread salbefe
Hello,

I would like to know how can I obtain the number of the current users
that are logged on.


Thanks in advance!


[web2py] Re: How to switch back to English for the Admin interface?

2010-11-09 Thread Stefan Scholl
Oops, found it 5 minutes later.

In case somebody wants to switch back to English, too:

Delete (or rename) your language in applications/admin/languages



[web2py] How to switch back to English for the Admin interface?

2010-11-09 Thread Stefan Scholl
Just upgraded web2py and now I get everything in German. That's not a
good idea if you are a programmer. The programming world and all the
terms are English. And in case of an error I can't ask here, because
you can't understand the error messages. :-(

Is there a way to switch back the Admin interface to English?

No, I can't change the preferred language in my browser, because I
don't want to use different browsers to work on 1 project. And for
everything else "de" is the language I need for testing and using the
rest of the web.


[web2py] How switch back to English for the Admin interface?

2010-11-09 Thread Stefan Scholl
Just upgraded web2py and now I get everything in German. That's not a
good idea if you are a programmer. The programming world and all the
terms are English. And in case of an error I can't ask here, because
you can't understand the error messages. :-(

Is there a way to switch back the Admin interface to English?

No, I can't change the preferred language in my browser, because I
don't want to use different browsers to work on 1 project. And for
everything else "de" is the language I need for testing and using the
rest of the web.