Re: [web2py] Show in select list a field of another table

2011-03-10 Thread Norbert Klamann
"""
a) I don't think DAL has SQL view... If someone can correct me on this 
affirmation...
"""
I speculate that the query Object comes close, but I do not knwo how to 
reference it in a validator.


"""
c) I Think that your table company is not necessary if there is always only 
one person for one company, but if you have many person in the same company 
you will get a person table nomalised level 1 if you don't have a company 
table.
"""
I gave only s asimplified extract of my model, A company has a lot of 
properties and relations of its own, so it has to be a table.



Re: [web2py] Re: Lacking nginx deployment guide

2011-03-10 Thread Vasile Ermicioi
yes, a guide for nginx + uwsgi will be great


[web2py] Re: Operational Error

2011-03-10 Thread pbreit
I'm not sure the exact problem. Did it show you what line of code caused the 
error?

I would suggest starting over and just putting this at the bottom of db.py 
(starting at about line 80). This worked OK for me.

db.define_table('estudantes', 
Field('nome'),
Field('pais'),
Field('nascimento', 'date'),
Field('sexo'),
Field('email'))

Some tips: 1) try to avoid changing or deleting what web2py gives you, 2) 
use all lower case names and 3) don't rename things unnecessarily.


[web2py] Re: web2py in the Pypi

2011-03-10 Thread pbreit
Weird. The version is listed as 1.95.6 when we are only at 1.93.2.

Best to get it from here:
http://web2py.com/examples/default/download


[web2py] Operational Error

2011-03-10 Thread Eduardo
Hello,

I generated a new simple app  through "New Simple Application" and
then changed its db.py to the following:

db = DAL('sqlite://MyDB.sqlite')



db.define_table('estudantes',

# DADOS PESSOAIS

Field('Nome', 'string'),

Field('Pais', 'string'),

Field('Nascimento', 'date'),

Field('Sexo', 'string'),

Field('Email', 'string'))

Well, now every time I try to insert a new entry via appadmin, I get
an Operational Error message:

Traceback (most recent call last):
  File "/home/eduardo/web2py/gluon/restricted.py", line 188, in
restricted
exec ccode in environment
  File "/home/eduardo/web2py/applications/teste4/controllers/
appadmin.py", line 412, in 
  File "/home/eduardo/web2py/gluon/globals.py", line 95, in 
self._caller = lambda f: f()
  File "/home/eduardo/web2py/applications/teste4/controllers/
appadmin.py", line 127, in insert
if form.accepts(request.vars, session):
  File "/home/eduardo/web2py/gluon/sqlhtml.py", line 1186, in accepts
self.vars.id = self.table.insert(**fields)
  File "/home/eduardo/web2py/gluon/dal.py", line 3952, in insert
return self._db._adapter.insert(self,self._listify(fields))
  File "/home/eduardo/web2py/gluon/dal.py", line 717, in insert
raise e
OperationalError: near ")": syntax error


What am I missing here?

Eduardo


[web2py] web2py in the Pypi

2011-03-10 Thread contatogilson...@gmail.com
The web2py in the Pypi is old. When go to update? Need to help?
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*


[web2py] Re: make validator accept empty fields

2011-03-10 Thread Eduardo
Thank you, DenesL.

Eduardo

On Mar 10, 4:14 pm, DenesL  wrote:
> ...requires=IS_EMPTY_OR(IS_EMAIL(...))
>
> Seehttp://web2py.com/book/default/chapter/07#Validators
>
> On Mar 10, 1:21 pm, Eduardo  wrote:
>
> > Hello,
>
> > I need to validate a field as e-mail but I also would like to accept
> > it if it is left empty; the following:
>
> > db.table.field.requires = IS_EMAIL(error_message=T('Not a valid e-mail
> > address!'))
>
> > flashes the error message for invalid e-mail when the field is left
> > empty.
>
> > How can I fix that?
>
> > Thanks,
>
> > Eduardo
>
>


[web2py] Re: How to implement 3rd party authentication on a site with twitter and facebook without going the Janrain route?

2011-03-10 Thread Massimo Di Pierro
Use

gluon/contrib/login_methods/extended_login_form.py

to have more than one form in one page

then you should be able to use
gluon/contrib/login_methods/oauth20_account.py
gluon/contrib/login_methods/oauth10a_account.py

to login with twitter and facebook respectively.
Mind that if the same user logins with twitter and facebook he will be
treated as different persons.

On Mar 10, 5:41 pm, Pystar  wrote:
> I would like to know how to implement 3rd party authentication using
> Twitter and Facebook without going the Janrain route because of
> certain constraints they have like cost and number of unique users. I
> would really appreciate if I can be pointed to 3rd party python
> libraries etc.
> thanks


[web2py] Re: Groups and Roles using LDAP

2011-03-10 Thread Massimo Di Pierro
to use ldap login with MS Active
Directory::

from gluon.contrib.login_methods.ldap_auth import
ldap_auth
 
auth.settings.login_methods.append(ldap_auth(
mode='ad',
server='my.domain.controller',
 
base_dn='ou=Users,dc=domain,dc=com'))

to use ldap login with Notes
Domino::

 
auth.settings.login_methods.append(ldap_auth(
 
mode='domino',server='my.domino.server'))

to use ldap login with
OpenLDAP::

 
auth.settings.login_methods.append(ldap_auth(
server='my.ldap.server',
base_dn='ou=Users,dc=domain,dc=com'))

to use ldap login with OpenLDAP and subtree search and
(optionally) multiple DNs:
 
auth.settings.login_methods.append(ldap_auth(
mode='uid_r',
server='my.ldap.server',
 
base_dn=['ou=Users,dc=domain,dc=com','ou=Staff,dc=domain,dc=com']))

or (if using
CN)::

 
auth.settings.login_methods.append(ldap_auth(
mode='cn',
server='my.ldap.server',
base_dn='ou=Users,dc=domain,dc=com'))

whatever you do this will work with Auth, so you can create roles in
web2py.
These would be web2py roles and not ldap roles.



On Mar 10, 4:55 pm, Ialejandro  wrote:
> Hi! I have this question, how could I use LDAP auth and use roles. So
> I need to take the users from an active directory (microsoft exchange)
> and they must have a role.
>
> How could I do that?? I need 2 basic roles, Boss, User (boss can
> create, delete) and have access to every controller in the app, while
> user just can acces to some pages. Is it possible??


Re: [web2py] Re: greetings from PyCon

2011-03-10 Thread Martín Mulone
Great!. Congratulations! I'm too far from there :(

2011/3/10 Anthony 

> I think it went very well from the audience perspective as well. Massimo's
> computer was set on Chicago time (Atlanta is an hour later), so he
> accidentally gave us our break an hour late -- but no one seemed to notice
> or care because Massimo's tour de force of web2py's capabilities was so
> engaging. Most attendees were relatively new to web2py, so Massimo had to
> spend some extra time on the basics, but folks seemed quite impressed with
> what they saw (looks like a couple of them sent out some tweets during the
> tutorial). Massimo had a prepared script, but as questions came up, he
> quickly whipped up some cool examples on the fly as well (e.g.,
> demonstrating web services). Near the end, Massimo said, "Now let's do
> something more complex -- we've got 20 minutes left, so let's build a
> Facebook clone." The audience thought he was joking a chuckled, but sure
> enough, 20 minutes later we had a working Facebook clone created from
> scratch (friend relationships and wall postings). Although it ended right in
> the middle of lunch hour, most folks stayed an extra 20 minutes or so for
> some Q&A (including more impromptu coding examples by Massimo). A number of
> folks stayed even later to chat with Massimo. Overall, I think it was very
> successful. We even had Guido van Rossum drop in for a good chunk of the
> tutorial.
>
> Anthony
>
> On Wednesday, March 9, 2011 5:41:09 PM UTC-5, Massimo Di Pierro wrote:
>
>> I am at PyCon in Atlanta. Greetings to all of you. The web2py tutorial
>> went very well (at least from my prospective) there were about 18 in
>> the room which is more than I was told would attend.
>>
>> If you are in Atlanta,  see you in the lobby at 6pm and we go out for
>> dinner.
>>
>> Massimo
>>
>>


-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

My blog: http://martin.tecnodoc.com.ar
Expert4Solution Profile:
http://www.experts4solutions.com/e4s/default/expert/6


Re: [web2py] How to implement unique click on web2py

2011-03-10 Thread Jonathan Lundell
On Mar 10, 2011, at 3:09 PM, Tito Garrido wrote:
> I'm wondering what is the best implementation for a "unique click" counting 
> in web2py... somehow I need to capture the ip address of the client and store 
> it on a table, I guess... So I'd like a piece of your knowledge on this :-)

The requesting IP address can be found in request.env. But keep in mind that 
the IP address will yield false positives, since all browsers behind a NAT 
router will appear to have the same IP address.



[web2py] How to implement 3rd party authentication on a site with twitter and facebook without going the Janrain route?

2011-03-10 Thread Pystar
I would like to know how to implement 3rd party authentication using
Twitter and Facebook without going the Janrain route because of
certain constraints they have like cost and number of unique users. I
would really appreciate if I can be pointed to 3rd party python
libraries etc.
thanks


[web2py] How to implement unique click on web2py

2011-03-10 Thread Tito Garrido
Hi folks,

I'm wondering what is the best implementation for a "unique click" counting
in web2py... somehow I need to capture the ip address of the client and
store it on a table, I guess... So I'd like a piece of your knowledge on
this :-)

Thanks!

Tito

-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___


[web2py] Groups and Roles using LDAP

2011-03-10 Thread Ialejandro
Hi! I have this question, how could I use LDAP auth and use roles. So
I need to take the users from an active directory (microsoft exchange)
and they must have a role.

How could I do that?? I need 2 basic roles, Boss, User (boss can
create, delete) and have access to every controller in the app, while
user just can acces to some pages. Is it possible??


[web2py] Re: Why doesnt this code snippet from the web2py book work

2011-03-10 Thread pbreit
Where do you see that snippet of code?

You've got a few problems.

You need to return the form in the dict:

def display_manual_form():
   form = SQLFORM(db.person)
   if form.accepts(request.vars, formname='test'):
   response.flash = 'form accepted'
   elif form.errors:
   response.flash = 'form has errors'
   else:
   response.flash = 'please fill the form'
   return dict(form=form)

Then, make sure name your view the same as the function name so that
web2py knows which view to show.

=== display_manual_form.html ===
{{extend 'layout.html'}}
{{=form}}

If you don't want all of the fields in db.table to display, you can
either set some fields to writable/readable=False or create custom
forms in your view. There are two options outlined here:
http://web2py.com/book/default/chapter/07#Custom-forms

As you can see, the more customized you make it, the less help you get
from web2py. Try to use web2py's features as much as possible in the
beginning. Then once you are comfortable, you can customize as
desired.



On Mar 10, 2:11 pm, DenesL  wrote:
> The form.accepts in the controller checks the fields using their
> validators.
>
> The error messages you have to handle yourself in your custom form.
> For an example see:http://web2py.com/book/default/chapter/07#Hide-Errors
>
> On Mar 10, 4:33 pm, Pystar  wrote:
>
>
>
>
>
>
>
> > So how do I design my forms manually and still have it display error
> > messages and use validators?
>
> > On Mar 10, 10:25 pm, DenesL  wrote:
>
> > > Because the code to show those errors is in the form created by
> > > SQLFORM and that form is neither being returned nor displayed in the
> > > view.
>
> > > On Mar 10, 4:00 pm, Pystar  wrote:
>
> > > > tried this snippet of code from the web2py book, but it doesnt work
> > > > the way I feel it should
>
> > > > def display_manual_form():
> > > >    form = SQLFORM(db.person)
> > > >    if form.accepts(request.vars, formname='test'):
> > > >        response.flash = 'form accepted'
> > > >    elif form.errors:
> > > >        response.flash = 'form has errors'
> > > >    else:
> > > >        response.flash = 'please fill the form'
> > > >    return dict()
>
> > > > {{extend 'layout.html'}}
> > > > 
> > > > 
> > > >   Your name is 
> > > > 
> > > >   
> > > >   
> > > > 
>
> > > > On submission, if there are errors in the form, it doesnt display any
> > > > error messages. why is this so?


Re: [web2py] Re: problem with type Int

2011-03-10 Thread Jonathan Lundell
On Mar 10, 2011, at 2:18 PM, LightOfMooN wrote:
> 
> because it's not beautiful ;)

Well, the field you're using in the database doesn't have a beautiful 
constraint...

> 
> On 11 мар, 03:16, Jonathan Lundell  wrote:
>> On Mar 10, 2011, at 11:57 AM, LightOfMooN wrote:
>> 
>> 
>> 
>>> the same result..
>> 
>>> so my validate for value is:
>>> isinstance(value, int) and -2147483649> 
>>> It works fine, but... it's not good...
>> 
>> Why not? You shouldn't be relying on sizeof(int).
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> On 10 мар, 23:32, Martín Mulone  wrote:
 Better use:
>> 
 if isinstance(value, int):
>> 
 instead of
>> 
 if type(value)==int:
>> 
 2011/3/9 LightOfMooN 
>> 
> value=request.vars.myvar
>> 
> try:
>value = int(value)
> except:
>pass
>> 
> if type(value)==int:
>insert()
>> 
> it rises
> (current transaction is aborted,
> commands ignored until end of transaction block)
> even if value > 2147483647
>> 
> But why?
> It's so strange, because type(value) must be long.
>> 
 --
 Pablo Martín Mulone (mar...@tecnodoc.com.ar)http://www.tecnodoc.com.ar/
>> 
 My blog:http://martin.tecnodoc.com.ar
 Expert4Solution 
 Profile:http://www.experts4solutions.com/e4s/default/expert/6




[web2py] Re: problem with type Int

2011-03-10 Thread LightOfMooN
because it's not beautiful ;)

On 11 мар, 03:16, Jonathan Lundell  wrote:
> On Mar 10, 2011, at 11:57 AM, LightOfMooN wrote:
>
>
>
> > the same result..
>
> > so my validate for value is:
> > isinstance(value, int) and -2147483649
> > It works fine, but... it's not good...
>
> Why not? You shouldn't be relying on sizeof(int).
>
>
>
>
>
>
>
>
>
> > On 10 мар, 23:32, Martín Mulone  wrote:
> >> Better use:
>
> >> if isinstance(value, int):
>
> >> instead of
>
> >> if type(value)==int:
>
> >> 2011/3/9 LightOfMooN 
>
> >>> value=request.vars.myvar
>
> >>> try:
> >>>    value = int(value)
> >>> except:
> >>>    pass
>
> >>> if type(value)==int:
> >>>    insert()
>
> >>> it rises
> >>> (current transaction is aborted,
> >>> commands ignored until end of transaction block)
> >>> even if value > 2147483647
>
> >>> But why?
> >>> It's so strange, because type(value) must be long.
>
> >> --
> >> Pablo Martín Mulone (mar...@tecnodoc.com.ar)http://www.tecnodoc.com.ar/
>
> >> My blog:http://martin.tecnodoc.com.ar
> >> Expert4Solution 
> >> Profile:http://www.experts4solutions.com/e4s/default/expert/6


Re: [web2py] Re: problem with type Int

2011-03-10 Thread Jonathan Lundell
On Mar 10, 2011, at 11:57 AM, LightOfMooN wrote:
> 
> the same result..
> 
> so my validate for value is:
> isinstance(value, int) and -2147483649 
> It works fine, but... it's not good...

Why not? You shouldn't be relying on sizeof(int).

> 
> On 10 мар, 23:32, Martín Mulone  wrote:
>> Better use:
>> 
>> if isinstance(value, int):
>> 
>> instead of
>> 
>> if type(value)==int:
>> 
>> 2011/3/9 LightOfMooN 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> value=request.vars.myvar
>> 
>>> try:
>>>value = int(value)
>>> except:
>>>pass
>> 
>>> if type(value)==int:
>>>insert()
>> 
>>> it rises
>>> (current transaction is aborted,
>>> commands ignored until end of transaction block)
>>> even if value > 2147483647
>> 
>>> But why?
>>> It's so strange, because type(value) must be long.
>> 
>> --
>> Pablo Martín Mulone (mar...@tecnodoc.com.ar)http://www.tecnodoc.com.ar/
>> 
>> My blog:http://martin.tecnodoc.com.ar
>> Expert4Solution Profile:http://www.experts4solutions.com/e4s/default/expert/6




[web2py] Re: Why doesnt this code snippet from the web2py book work

2011-03-10 Thread DenesL

The form.accepts in the controller checks the fields using their
validators.

The error messages you have to handle yourself in your custom form.
For an example see:
http://web2py.com/book/default/chapter/07#Hide-Errors


On Mar 10, 4:33 pm, Pystar  wrote:
> So how do I design my forms manually and still have it display error
> messages and use validators?
>
> On Mar 10, 10:25 pm, DenesL  wrote:
>
> > Because the code to show those errors is in the form created by
> > SQLFORM and that form is neither being returned nor displayed in the
> > view.
>
> > On Mar 10, 4:00 pm, Pystar  wrote:
>
> > > tried this snippet of code from the web2py book, but it doesnt work
> > > the way I feel it should
>
> > > def display_manual_form():
> > >    form = SQLFORM(db.person)
> > >    if form.accepts(request.vars, formname='test'):
> > >        response.flash = 'form accepted'
> > >    elif form.errors:
> > >        response.flash = 'form has errors'
> > >    else:
> > >        response.flash = 'please fill the form'
> > >    return dict()
>
> > > {{extend 'layout.html'}}
> > > 
> > > 
> > >   Your name is 
> > > 
> > >   
> > >   
> > > 
>
> > > On submission, if there are errors in the form, it doesnt display any
> > > error messages. why is this so?
>
>


[web2py] Re: Why doesnt this code snippet from the web2py book work

2011-03-10 Thread Pystar
So how do I design my forms manually and still have it display error
messages and use validators?

On Mar 10, 10:25 pm, DenesL  wrote:
> Because the code to show those errors is in the form created by
> SQLFORM and that form is neither being returned nor displayed in the
> view.
>
> On Mar 10, 4:00 pm, Pystar  wrote:
>
>
>
>
>
>
>
> > tried this snippet of code from the web2py book, but it doesnt work
> > the way I feel it should
>
> > def display_manual_form():
> >    form = SQLFORM(db.person)
> >    if form.accepts(request.vars, formname='test'):
> >        response.flash = 'form accepted'
> >    elif form.errors:
> >        response.flash = 'form has errors'
> >    else:
> >        response.flash = 'please fill the form'
> >    return dict()
>
> > {{extend 'layout.html'}}
> > 
> > 
> >   Your name is 
> > 
> >   
> >   
> > 
>
> > On submission, if there are errors in the form, it doesnt display any
> > error messages. why is this so?


[web2py] Re: Lacking nginx deployment guide

2011-03-10 Thread minux
pbreit, thanks your concise guide

http://web2pyslices.com/main/slices/take_slice/110

I could set up cherokee+uwsgi.
However, I don't like Windowish attitude that treats users as dumbs
(like, "this settings are not meant to be changed by you"...etc) and
commercialized self-promoting approach of cherokee.

So I would love to see a nginx+uwsgi guide like yours for cherokee. As
this benchmarks shows:

http://nichol.as/benchmark-of-python-web-servers

uwsgi is among the best (if not the best) option to be used for a
python web framework. So if you want to write a guide,  I guess it
would be better to implement uwsgi, rather than fcgi.


On Mar 10, 6:31 pm, pbreit  wrote:
> OK, good to know. I think I might try it out. If so, I'll publish my
> fabfile.


[web2py] Re: Why doesnt this code snippet from the web2py book work

2011-03-10 Thread DenesL

Because the code to show those errors is in the form created by
SQLFORM and that form is neither being returned nor displayed in the
view.

On Mar 10, 4:00 pm, Pystar  wrote:
> tried this snippet of code from the web2py book, but it doesnt work
> the way I feel it should
>
> def display_manual_form():
>    form = SQLFORM(db.person)
>    if form.accepts(request.vars, formname='test'):
>        response.flash = 'form accepted'
>    elif form.errors:
>        response.flash = 'form has errors'
>    else:
>        response.flash = 'please fill the form'
>    return dict()
>
> {{extend 'layout.html'}}
> 
> 
>   Your name is 
> 
>   
>   
> 
>
> On submission, if there are errors in the form, it doesnt display any
> error messages. why is this so?


[web2py] Why doesnt this code snippet from the web2py book work

2011-03-10 Thread Pystar
tried this snippet of code from the web2py book, but it doesnt work
the way I feel it should

def display_manual_form():
   form = SQLFORM(db.person)
   if form.accepts(request.vars, formname='test'):
   response.flash = 'form accepted'
   elif form.errors:
   response.flash = 'form has errors'
   else:
   response.flash = 'please fill the form'
   return dict()


{{extend 'layout.html'}}


  Your name is 

  
  


On submission, if there are errors in the form, it doesnt display any
error messages. why is this so?


Re: [web2py] [tip] Head JS script loader

2011-03-10 Thread mikech
Thanks great find!

[web2py] Re: Lacking nginx deployment guide

2011-03-10 Thread minux
I have used nginx + fcgi for php (before moving to php5-fmp, which is
more robust), however, I really lack technical talent to implement the
same for web2py, given the nginx.conf that you kindly shared. So I
would be grateful if you write up a complete guide, when you have
time.

Cheers


I would love to see the complete

On Mar 10, 12:23 pm, Michele Alzetta 
wrote:
> On Thu, Mar 10, 2011 at 12:09 AM, minux  wrote:
>
> > Cutting the long story short, I really appreciate it if someone could
> > point me to a complete guide for nginx deployment, or writhe one :)
>
> I have web2py on a linode.com VPS deployed on nginx with ssl access so I can
> have access to administrative interface.
>
> As linux distro I use gentoo. Nginx and spawn-fcgi I emerge, whereas web2py
> I just download and install by hand.
>
> nginx.conf contains:
>
> server {
>         listen       443;
>         ssl                  on;
>         ssl_certificate      /etc/ssl/nginx/nginx.pem;
>         ssl_certificate_key  /etc/ssl/nginx/nginx.key;
>         keepalive_timeout    70;
>         server_name  my.server.name;
>         access_log  /var/log/nginx/web2py.access.log;
>         location / {
>         set $fixed_destination $http_destination;
>         if ($http_destination ~* ^https(.*)$)
>         {
>         set $fixed_destination http$1;
>         }
>         proxy_passhttp://127.0.0.1:8000;
>         proxy_set_header Host $host;
>         proxy_set_header X-Real-IP $remote_addr;
>         proxy_set_header X-Forwarded-For $remote_addr;
>         proxy_set_header        Destination     $fixed_destination;
>         }
>
> Is this enough for you? If people really feel it is useful I could write a
> guide for nginx deployment, but give me some time!   :)


Re: [web2py] [tip] Head JS script loader

2011-03-10 Thread Bruno Rocha
That is exactly what I am trying do to here...

2011/3/10 Martín Mulone 

> I'm thinking... this can be go very well with web2py.
>
> For example this come to my mind...
>
> in web2py
> response.scripts.insert(0,URL('static','js/jquery.js'))
> response.scripts.insert(1,URL('static','js/calendar.js'))
>
> render as
> 
> head.js("/path/to/jquery.js", "/path/to/calendar.js");
> 
>
> in web2py
> response.scripts.insert(2,'http://www.google-analytics.com/ga.js')
> response.scripts.insert(3,'''function() {
>  var tracker = _gat._getTracker("UA-20001309-1");
> tracker._trackPageview();
>  }''')
>
> render as
> 
> head.js('http://www.google-analytics.com/ga.js', function() {
>  var tracker = _gat._getTracker("UA-20001309-1");
> tracker._trackPageview();
> });
> 
>
> + More modular.
> + Insert scripts from models and controllers. (very good for plugins)
>
> 2011/3/10 contatogilson...@gmail.com 
>
> That's what I was looking for!
>> _
>> *Gilson Filho*
>> *Web Developer
>> http://gilsondev.com*
>>
>>
>>
>> 2011/3/10 Martín Mulone 
>>
>> Very interesting
>>>
>>> 2011/3/10 Richard Vézina 
>>>
>>> Thanks to share Bruno

 Richard


 On Wed, Mar 9, 2011 at 9:09 PM, Bruno Rocha wrote:

>  Head JS script loader
>
> With Head JS your scripts load like images - completely separated from
> the page rendering process. The page is ready sooner. Always. This is
> guaranteed even with a single combined JavaScript file. See it yourself:
>
> Sample page with 5 SCRIPT SRC tags
>
> Same scripts loaded with Head JS 
>
> Non-blocking loading is the key to fast pages. Moreover Head JS loads
> scripts in *parallel* no matter how many of them and what the browser
> is. The speed difference can be dramatic especially on the initial page 
> load
> when the scripts are not yet in cache. It's your crucial first impression.
>
> Pages no longer "hang" and there is less or zero "flashing" between
> pages. User only cares when the page is ready. Unfortunately current
> networking tools don't highlight this crucial point. They focus on the
> overall loading of assets instead.
>
> Head JS can make your pages load 100% or even 400% faster. It can make
> the largest impact on client side optimization.
>
>
> http://headjs.com/
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
>
>

>>>
>>>
>>> --
>>> Pablo Martín Mulone (mar...@tecnodoc.com.ar)
>>> http://www.tecnodoc.com.ar/
>>>
>>> My blog: http://martin.tecnodoc.com.ar
>>> Expert4Solution Profile:
>>> http://www.experts4solutions.com/e4s/default/expert/6
>>>
>>>
>>>
>>
>
>
> --
> Pablo Martín Mulone (mar...@tecnodoc.com.ar)
> http://www.tecnodoc.com.ar/
>
> My blog: http://martin.tecnodoc.com.ar
> Expert4Solution Profile:
> http://www.experts4solutions.com/e4s/default/expert/6
>
>
>


Re: [web2py] Legacy PostgreSQL Database using case sensitive table and field names

2011-03-10 Thread Richard Vézina
remove the " from web2py model and add the sequence name that postgres
create by default with a different name then web2py expect like this :

db.define_table('GlobalSettings',
Field('settingName', length=255, unique=True),
Field('settingValue', 'text'),
Field('settingID', 'id'),
sequence_name='GlobalSettings_settingID_seq'
)

It should works...

Richard

On Thu, Mar 10, 2011 at 2:42 PM, Ross Peoples wrote:

> I have a legacy PostgreSQL database that has its tables and field names
> created using a case-sensitive means. Whenever I try to do a select(), it
> returns no rows, and an insert() fails. This is the error that web2py gives:
>
> ProgrammingError: relation "globalsettings_id_seq" does not exist
> LINE 1: select currval('GlobalSettings_id_Seq')
>
>
> This is the actual table definition from pgAdmin3:
>
> CREATE TABLE "GlobalSettings"
> (
>   "settingName" character varying(255) NOT NULL,
>   "settingValue" text NOT NULL,
>   "settingID" serial NOT NULL,
>   CONSTRAINT "GlobalSettings_pkey" PRIMARY KEY ("settingID")
> )
>
> Attempting to define my table in web2py using double-quotes between
> single-quotes, like this:
>
> db.define_table('"GlobalSettings"',
> Field('"settingName"', length=255, unique=True),
> Field('"settingValue"', 'text'),
> Field('"settingID"', 'id')
> )
>
> results in the following error message: SyntaxError: only [0-9a-zA-Z_] allowed
> in table and field names, received "settingName"
>


[web2py] Re: problem with type Int

2011-03-10 Thread LightOfMooN
the same result..

so my validate for value is:
isinstance(value, int) and -2147483649 wrote:
> Better use:
>
> if isinstance(value, int):
>
> instead of
>
> if type(value)==int:
>
> 2011/3/9 LightOfMooN 
>
>
>
>
>
>
>
>
>
> > value=request.vars.myvar
>
> > try:
> >    value = int(value)
> > except:
> >    pass
>
> > if type(value)==int:
> >    insert()
>
> > it rises
> > (current transaction is aborted,
> > commands ignored until end of transaction block)
> > even if value > 2147483647
>
> > But why?
> > It's so strange, because type(value) must be long.
>
> --
> Pablo Martín Mulone (mar...@tecnodoc.com.ar)http://www.tecnodoc.com.ar/
>
> My blog:http://martin.tecnodoc.com.ar
> Expert4Solution Profile:http://www.experts4solutions.com/e4s/default/expert/6


Re: [web2py] [tip] Head JS script loader

2011-03-10 Thread contatogilson...@gmail.com
Very good!
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*


Re: [web2py] [tip] Head JS script loader

2011-03-10 Thread Martín Mulone
I'm thinking... this can be go very well with web2py.

For example this come to my mind...

in web2py
response.scripts.insert(0,URL('static','js/jquery.js'))
response.scripts.insert(1,URL('static','js/calendar.js'))

render as

head.js("/path/to/jquery.js", "/path/to/calendar.js");


in web2py
response.scripts.insert(2,'http://www.google-analytics.com/ga.js')
response.scripts.insert(3,'''function() {
var tracker = _gat._getTracker("UA-20001309-1");
tracker._trackPageview();
}''')

render as

head.js('http://www.google-analytics.com/ga.js', function() {
var tracker = _gat._getTracker("UA-20001309-1");
tracker._trackPageview();
});


+ More modular.
+ Insert scripts from models and controllers. (very good for plugins)

2011/3/10 contatogilson...@gmail.com 

> That's what I was looking for!
> _
> *Gilson Filho*
> *Web Developer
> http://gilsondev.com*
>
>
>
> 2011/3/10 Martín Mulone 
>
> Very interesting
>>
>> 2011/3/10 Richard Vézina 
>>
>> Thanks to share Bruno
>>>
>>> Richard
>>>
>>>
>>> On Wed, Mar 9, 2011 at 9:09 PM, Bruno Rocha wrote:
>>>
  Head JS script loader

 With Head JS your scripts load like images - completely separated from
 the page rendering process. The page is ready sooner. Always. This is
 guaranteed even with a single combined JavaScript file. See it yourself:

 Sample page with 5 SCRIPT SRC tags 

 Same scripts loaded with Head JS 

 Non-blocking loading is the key to fast pages. Moreover Head JS loads
 scripts in *parallel* no matter how many of them and what the browser
 is. The speed difference can be dramatic especially on the initial page 
 load
 when the scripts are not yet in cache. It's your crucial first impression.

 Pages no longer "hang" and there is less or zero "flashing" between
 pages. User only cares when the page is ready. Unfortunately current
 networking tools don't highlight this crucial point. They focus on the
 overall loading of assets instead.

 Head JS can make your pages load 100% or even 400% faster. It can make
 the largest impact on client side optimization.


 http://headjs.com/
 --
 Bruno Rocha
 [ About me: http://zerp.ly/rochacbruno ]


>>>
>>
>>
>> --
>> Pablo Martín Mulone (mar...@tecnodoc.com.ar)
>> http://www.tecnodoc.com.ar/
>>
>> My blog: http://martin.tecnodoc.com.ar
>> Expert4Solution Profile:
>> http://www.experts4solutions.com/e4s/default/expert/6
>>
>>
>>
>


-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

My blog: http://martin.tecnodoc.com.ar
Expert4Solution Profile:
http://www.experts4solutions.com/e4s/default/expert/6


[web2py] Re: list and loop problem

2011-03-10 Thread DenesL

You can create two actions, one to show the items and the other one to
delete them one by one via request.args[0]:

# list of items with delete link
def show_items():
  rr=db(db.item.id>0).select()
  return dict(items=TABLE(*[ (
TD(r.name),
TD(A('delete this
item',_href=URL(c=request.controller,f='del_item',args=[r.id])))
) for r in rr ]))

def del_item():
  if request.args and request.args[0]:
item_id=request.args[0]
db(db.item.id==item_id).delete()
session.flash='item %s deleted' %item_id
  else:
session.flash='item not found'
  redirect(URL(c=request.controller,f='show_items'))


On Mar 10, 2:19 pm, Rick  wrote:
> I meant that I'd like to print on a html _page_.
>
> On Mar 10, 6:34 pm, Rick  wrote:
>
> > I'd like to print the list in a html file.
>
> > On Mar 10, 6:16 pm, Bruno Rocha  wrote:
>
> > > where do you want to output this?
>
> > > in to pure HTML or in a SQLTABLE?
>
> > > 2011/3/10 Rick 
>
> > > > Hi,
>
> > > > I want to print a linked list and add a "delete this item" button next
> > > > to each item:
> > > > 
> > > > [item 1][delete this item]
> > > > [item 2][delete this item]
> > > > [item 3][delete this item]
> > > > 
> > > > ...but I've no clue how to write the code. The problem is to direct
> > > > the second delete button to the second item.
>
> > > > Thanks in advance for help!
>
>


[web2py] Legacy PostgreSQL Database using case sensitive table and field names

2011-03-10 Thread Ross Peoples
I have a legacy PostgreSQL database that has its tables and field names 
created using a case-sensitive means. Whenever I try to do a select(), it 
returns no rows, and an insert() fails. This is the error that web2py gives:

ProgrammingError: relation "globalsettings_id_seq" does not exist
LINE 1: select currval('GlobalSettings_id_Seq')


This is the actual table definition from pgAdmin3:

CREATE TABLE "GlobalSettings"
(
  "settingName" character varying(255) NOT NULL,
  "settingValue" text NOT NULL,
  "settingID" serial NOT NULL,
  CONSTRAINT "GlobalSettings_pkey" PRIMARY KEY ("settingID")
)

Attempting to define my table in web2py using double-quotes between 
single-quotes, like this:

db.define_table('"GlobalSettings"',
Field('"settingName"', length=255, unique=True),
Field('"settingValue"', 'text'),
Field('"settingID"', 'id')
)

results in the following error message: SyntaxError: only [0-9a-zA-Z_] allowed 
in table and field names, received "settingName"


Re: [web2py] [tip] Head JS script loader

2011-03-10 Thread contatogilson...@gmail.com
That's what I was looking for!
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*



2011/3/10 Martín Mulone 

> Very interesting
>
> 2011/3/10 Richard Vézina 
>
> Thanks to share Bruno
>>
>> Richard
>>
>>
>> On Wed, Mar 9, 2011 at 9:09 PM, Bruno Rocha wrote:
>>
>>>  Head JS script loader
>>>
>>> With Head JS your scripts load like images - completely separated from
>>> the page rendering process. The page is ready sooner. Always. This is
>>> guaranteed even with a single combined JavaScript file. See it yourself:
>>>
>>> Sample page with 5 SCRIPT SRC tags 
>>>
>>> Same scripts loaded with Head JS 
>>>
>>> Non-blocking loading is the key to fast pages. Moreover Head JS loads
>>> scripts in *parallel* no matter how many of them and what the browser
>>> is. The speed difference can be dramatic especially on the initial page load
>>> when the scripts are not yet in cache. It's your crucial first impression.
>>>
>>> Pages no longer "hang" and there is less or zero "flashing" between
>>> pages. User only cares when the page is ready. Unfortunately current
>>> networking tools don't highlight this crucial point. They focus on the
>>> overall loading of assets instead.
>>>
>>> Head JS can make your pages load 100% or even 400% faster. It can make
>>> the largest impact on client side optimization.
>>>
>>>
>>> http://headjs.com/
>>> --
>>> Bruno Rocha
>>> [ About me: http://zerp.ly/rochacbruno ]
>>>
>>>
>>
>
>
> --
> Pablo Martín Mulone (mar...@tecnodoc.com.ar)
> http://www.tecnodoc.com.ar/
>
> My blog: http://martin.tecnodoc.com.ar
> Expert4Solution Profile:
> http://www.experts4solutions.com/e4s/default/expert/6
>
>
>


Re: [web2py] [tip] Head JS script loader

2011-03-10 Thread Martín Mulone
Very interesting

2011/3/10 Richard Vézina 

> Thanks to share Bruno
>
> Richard
>
>
> On Wed, Mar 9, 2011 at 9:09 PM, Bruno Rocha  wrote:
>
>>  Head JS script loader
>>
>> With Head JS your scripts load like images - completely separated from the
>> page rendering process. The page is ready sooner. Always. This is guaranteed
>> even with a single combined JavaScript file. See it yourself:
>>
>> Sample page with 5 SCRIPT SRC tags 
>>
>> Same scripts loaded with Head JS 
>>
>> Non-blocking loading is the key to fast pages. Moreover Head JS loads
>> scripts in *parallel* no matter how many of them and what the browser is.
>> The speed difference can be dramatic especially on the initial page load
>> when the scripts are not yet in cache. It's your crucial first impression.
>>
>> Pages no longer "hang" and there is less or zero "flashing" between pages.
>> User only cares when the page is ready. Unfortunately current networking
>> tools don't highlight this crucial point. They focus on the overall loading
>> of assets instead.
>>
>> Head JS can make your pages load 100% or even 400% faster. It can make the
>> largest impact on client side optimization.
>>
>>
>> http://headjs.com/
>> --
>> Bruno Rocha
>> [ About me: http://zerp.ly/rochacbruno ]
>>
>>
>


-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

My blog: http://martin.tecnodoc.com.ar
Expert4Solution Profile:
http://www.experts4solutions.com/e4s/default/expert/6


[web2py] Re: How to validate/notify this simple form with db

2011-03-10 Thread DenesL

You are not using the form generated by SQLFORM in your view, which
has the code to show the errors.

To fix, in the controller:

return dict(form=form)

and in the view just have:

{{=form}}


On Mar 10, 12:47 pm, Jamboo  wrote:
> http://www.pastie.org/1656418
>
> I have a form, and when I fill out the fields required, it gets pushed
> to the db no problem.  The issue is that I want it to have a
> notification where if a field is empty it makes that red rectangle
> appear to alert the user to fill in the field properly.  I thought how
> I have my controller setup, it would do this.  Does it have to deal
> with request.vars ?


[web2py] Re: list and loop problem

2011-03-10 Thread Rick
I meant that I'd like to print on a html _page_.

On Mar 10, 6:34 pm, Rick  wrote:
> I'd like to print the list in a html file.
>
> On Mar 10, 6:16 pm, Bruno Rocha  wrote:
>
>
>
>
>
>
>
> > where do you want to output this?
>
> > in to pure HTML or in a SQLTABLE?
>
> > 2011/3/10 Rick 
>
> > > Hi,
>
> > > I want to print a linked list and add a "delete this item" button next
> > > to each item:
> > > 
> > > [item 1][delete this item]
> > > [item 2][delete this item]
> > > [item 3][delete this item]
> > > 
> > > ...but I've no clue how to write the code. The problem is to direct
> > > the second delete button to the second item.
>
> > > Thanks in advance for help!


[web2py] Re: make validator accept empty fields

2011-03-10 Thread DenesL

...requires=IS_EMPTY_OR(IS_EMAIL(...))

See http://web2py.com/book/default/chapter/07#Validators


On Mar 10, 1:21 pm, Eduardo  wrote:
> Hello,
>
> I need to validate a field as e-mail but I also would like to accept
> it if it is left empty; the following:
>
> db.table.field.requires = IS_EMAIL(error_message=T('Not a valid e-mail
> address!'))
>
> flashes the error message for invalid e-mail when the field is left
> empty.
>
> How can I fix that?
>
> Thanks,
>
> Eduardo


[web2py] How to validate/notify this simple form with db

2011-03-10 Thread Jamboo
http://www.pastie.org/1656418

I have a form, and when I fill out the fields required, it gets pushed
to the db no problem.  The issue is that I want it to have a
notification where if a field is empty it makes that red rectangle
appear to alert the user to fill in the field properly.  I thought how
I have my controller setup, it would do this.  Does it have to deal
with request.vars ?


Re: [web2py] Re: ('active') when running plugin_wiki

2011-03-10 Thread mat --
It works now. Thanks!

On Thu, Mar 10, 2011 at 6:10 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> fixed now
>
> On Mar 9, 8:15 pm, villas  wrote:
> > Yes, plugin_wiki is broken because the field active was deleted. I
> > already reported this and I hope Massimo will fix it soon.
> >
> > On Mar 9, 11:24 pm, mat --  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi
> >
> > > I downloaded latest version of Web2py and plugin_wiki.
> >
> > > I setup Janrain. I can login.
> >
> > > I created a new app and uploaded plugin_wiki as a plugin.
> >
> > > I can create a first page and save it using plugin_wiki features.
> >
> > > But second time I click the "Page" tab i get the following error:
> >
> > > Version
> > >  web2py™ Version 1.93.2 (2011-03-06 10:18:04)  Python Python 2.6.6:
> > > /usr/bin/python
> > > Traceback
> >
> > > 1.
> > > 2.
> > > 3.
> > > 4.
> > > 5.
> > > 6.
> > > 7.
> > > 8.
> > > 9.
> > > 10.
> >
> > > Traceback (most recent call last):
> > >   File "/home/linux/Dev/web2py/gluon/restricted.py", line 188, in
> restricted
> > > exec ccode in environment
> > >   File
> "/home/linux/Dev/web2py/applications/Docs/views/plugin_wiki/index.html",
> > > line 113, in 
> > >   File "/home/linux/Dev/web2py/gluon/dal.py", line 3347, in __getattr__
> > > return self[key]
> > >   File "/home/linux/Dev/web2py/gluon/dal.py", line 3338, in __getitem__
> > > return dict.__getitem__(self, key)
> > > KeyError: 'active'
> >
> > > Error snapshot [image: help] Detailed traceback description
> >
> > > ('active')
> >
> > > Anyone knows what is the issue here?
> >
> > > Thanks!
> >
> > > Mat
>


Re: [web2py] [tip] Head JS script loader

2011-03-10 Thread Richard Vézina
Thanks to share Bruno

Richard

On Wed, Mar 9, 2011 at 9:09 PM, Bruno Rocha  wrote:

>  Head JS script loader
>
> With Head JS your scripts load like images - completely separated from the
> page rendering process. The page is ready sooner. Always. This is guaranteed
> even with a single combined JavaScript file. See it yourself:
>
> Sample page with 5 SCRIPT SRC tags 
>
> Same scripts loaded with Head JS 
>
> Non-blocking loading is the key to fast pages. Moreover Head JS loads
> scripts in *parallel* no matter how many of them and what the browser is.
> The speed difference can be dramatic especially on the initial page load
> when the scripts are not yet in cache. It's your crucial first impression.
>
> Pages no longer "hang" and there is less or zero "flashing" between pages.
> User only cares when the page is ready. Unfortunately current networking
> tools don't highlight this crucial point. They focus on the overall loading
> of assets instead.
>
> Head JS can make your pages load 100% or even 400% faster. It can make the
> largest impact on client side optimization.
>
>
> http://headjs.com/
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
>
>


Re: [web2py] problem with type Int

2011-03-10 Thread Martín Mulone
Better use:

if isinstance(value, int):

instead of

if type(value)==int:


2011/3/9 LightOfMooN 

> value=request.vars.myvar
>
> try:
>value = int(value)
> except:
>pass
>
> if type(value)==int:
>insert()
>
> it rises
> (current transaction is aborted,
> commands ignored until end of transaction block)
> even if value > 2147483647
>
> But why?
> It's so strange, because type(value) must be long.




-- 
Pablo Martín Mulone (mar...@tecnodoc.com.ar)
http://www.tecnodoc.com.ar/

My blog: http://martin.tecnodoc.com.ar
Expert4Solution Profile:
http://www.experts4solutions.com/e4s/default/expert/6


Re: [web2py] Lacking nginx deployment guide

2011-03-10 Thread pbreit
OK, good to know. I think I might try it out. If so, I'll publish my 
fabfile.

Re: [web2py] Show in select list a field of another table

2011-03-10 Thread Richard Vézina
On Thu, Mar 10, 2011 at 12:55 PM, Richard Vézina <
ml.richard.vez...@gmail.com> wrote:

> Ok,
>
> a) I don't think DAL has SQL view... If someone can correct me on this
> affirmation...
>
> b) Label is a way to give different name to a field... It is not useful for
> what you expect. You want to use the value of record instead of it id as a
> representation of this record into a dropbox (requires) or a select
> (represent). For this there is "format=" or "requires=" that share the same
> purpose in a slightly different manner. You can read about those in the
> book.
>
> c) I Think that your table company is not necessary if there is always only
> one person for one company, but if you have many person in the same company
> you will get a person table nomalised level 1 if you don't have a company
> table.
>
> The solution a post is not kind of web2py SQL View... It's not a SQL view
> in the sens that records are duplicated. I don't know how to implement a SQL
> View into web2py and there is surely an other better solution, but it works
> as you expect (as far as I can understand your model).
>
> Corrections :

The solution I post is a kind of web2py SQL View... It's not a SQL view in
the sens that records are duplicated. I don't know how to implement a SQL
View into web2py and there is surely an other better solution, but it works
as you expect (as far as I can understand your model).



>
> Richard
>
>
> On Thu, Mar 10, 2011 at 12:28 PM, Norbert Klamann <
> norbert.klam...@googlemail.com> wrote:
>
>> Hello Richard,
>> many thanks for your work. When I think about it : The table
>> 'person_company' could be a view, couldn't it ?
>> But i have not understood :
>>
>> a) how to define a view in DAL ?
>>
>> b) How to use it as the 'label' Parameter for the IS_IN_DB Validator.
>>
>> If this would be possible the redundant table 'person_company' could be
>> omitted.
>>
>> Thanks again for listening (and answering  of course)
>>
>> Norbert
>>
>
>


[web2py] make validator accept empty fields

2011-03-10 Thread Eduardo
Hello,

I need to validate a field as e-mail but I also would like to accept
it if it is left empty; the following:

db.table.field.requires = IS_EMAIL(error_message=T('Not a valid e-mail
address!'))

flashes the error message for invalid e-mail when the field is left
empty.

How can I fix that?

Thanks,

Eduardo


Re: [web2py] Re: javascript/jquery advice

2011-03-10 Thread Richard Vézina
There is server-side processing available with DataTables... But PowerTables
is not implementing it.

>From Datatables doc and forum, no server-side processing is needed below
5000 rows after it is suggested to pass to server-side processing.

I found that the initialisation of datatables could impact the searchbox and
columns sorting speed particularly when using FixedColumns.js. Allan is
working actually on improving the FixedColumns.js. There is
also bScrollInfinite and bAutoWidth that could help improve speed. Read the
doc of datatables...

Richard

On Thu, Mar 10, 2011 at 12:59 PM, Ross Peoples wrote:

> I tried using DataTables a year or two ago for a project, but I ended up
> needing to use jqgrid because with DataTables, you had to load all of your
> table entries into the HTML at once. When you have 30 items or so, this
> isn't a big deal, but I had to deal with about 10,000 records, so loading
> all records into an HTML table isn't feasible. I don't know if this has
> changed at all, so if I'm wrong, please let me know, as I will soon have to
> make a decision about how I want to approach the same requirement for a new
> project.
>
>
> On Thursday, March 10, 2011 11:46:29 AM UTC-5, Anthony wrote:
>>
>> For grid stuff, also check out Bruno's excellent PowerTable plugin:
>> http://powertable.blouweb.com/
>> https://bitbucket.org/rochacbruno/powertable
>>
>>
>> On Thursday, March 10, 2011 9:29:31 AM UTC-5, spyker wrote:
>>
>>> I am starting to learn javascript and am thinking of using more jquery
>>> and jquery UI  and ajax elements in my applications and would appreciate on
>>> how to approach it:
>>>
>>> 1. Starting with javascript tutorials (e.g. from developer.mozilla.org)
>>> and move on to jquery tutorials and later on to how web2py uses them.
>>> 2. Starting with web2py-customised jquery elements (or do you call them
>>> 'components') and try to explore that further.
>>>
>>> I have looked at some jquery-related slices and it seems that the way to
>>> include jquery ui stuff in web2py is not that straight forward.  Some of the
>>> slices' have outdated documentation.  The documentation for
>>> http://web2pyslices.com/main/slices/take_slice/11 for example is no
>>> longer used by the latest code one can download from a link on the slice.
>>>
>>> Also: I have seen that for example jqgrid has a lot more capabilities
>>> that is available in the plugin-wiki.  I would like to learn how to use for
>>> example more complicated datasources with jqgrid and subtables when clicked
>>> on a row of data linked to other tables.
>>>
>>> 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: Dotcloud hosting great tutorial but stuck

2011-03-10 Thread ron_m
Type in the terminal window

echo $PATH

upper lower case is important. It should have /bin between colon characters 
somewhere

or try

/bin/ls

as a command.

Either you PATH environment is messed up or some important command files are 
missing from the /bin directory.


[web2py] Re: javascript/jquery advice

2011-03-10 Thread Ross Peoples
I tried using DataTables a year or two ago for a project, but I ended up 
needing to use jqgrid because with DataTables, you had to load all of your 
table entries into the HTML at once. When you have 30 items or so, this 
isn't a big deal, but I had to deal with about 10,000 records, so loading 
all records into an HTML table isn't feasible. I don't know if this has 
changed at all, so if I'm wrong, please let me know, as I will soon have to 
make a decision about how I want to approach the same requirement for a new 
project.

On Thursday, March 10, 2011 11:46:29 AM UTC-5, Anthony wrote:
>
> For grid stuff, also check out Bruno's excellent PowerTable plugin:
> http://powertable.blouweb.com/
> https://bitbucket.org/rochacbruno/powertable
>  
>
> On Thursday, March 10, 2011 9:29:31 AM UTC-5, spyker wrote:
>
>> I am starting to learn javascript and am thinking of using more jquery and 
>> jquery UI  and ajax elements in my applications and would appreciate on how 
>> to approach it:
>>
>> 1. Starting with javascript tutorials (e.g. from developer.mozilla.org)  
>> and move on to jquery tutorials and later on to how web2py uses them.
>> 2. Starting with web2py-customised jquery elements (or do you call them 
>> 'components') and try to explore that further.
>>
>> I have looked at some jquery-related slices and it seems that the way to 
>> include jquery ui stuff in web2py is not that straight forward.  Some of the 
>> slices' have outdated documentation.  The documentation for 
>> http://web2pyslices.com/main/slices/take_slice/11 for example is no 
>> longer used by the latest code one can download from a link on the slice.
>>
>> Also: I have seen that for example jqgrid has a lot more capabilities that 
>> is available in the plugin-wiki.  I would like to learn how to use for 
>> example more complicated datasources with jqgrid and subtables when clicked 
>> on a row of data linked to other tables.  
>>
>> 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] Show in select list a field of another table

2011-03-10 Thread Richard Vézina
Ok,

a) I don't think DAL has SQL view... If someone can correct me on this
affirmation...

b) Label is a way to give different name to a field... It is not useful for
what you expect. You want to use the value of record instead of it id as a
representation of this record into a dropbox (requires) or a select
(represent). For this there is "format=" or "requires=" that share the same
purpose in a slightly different manner. You can read about those in the
book.

c) I Think that your table company is not necessary if there is always only
one person for one company, but if you have many person in the same company
you will get a person table nomalised level 1 if you don't have a company
table.

The solution a post is not kind of web2py SQL View... It's not a SQL view in
the sens that records are duplicated. I don't know how to implement a SQL
View into web2py and there is surely an other better solution, but it works
as you expect (as far as I can understand your model).


Richard

On Thu, Mar 10, 2011 at 12:28 PM, Norbert Klamann <
norbert.klam...@googlemail.com> wrote:

> Hello Richard,
> many thanks for your work. When I think about it : The table
> 'person_company' could be a view, couldn't it ?
> But i have not understood :
>
> a) how to define a view in DAL ?
>
> b) How to use it as the 'label' Parameter for the IS_IN_DB Validator.
>
> If this would be possible the redundant table 'person_company' could be
> omitted.
>
> Thanks again for listening (and answering  of course)
>
> Norbert
>


[web2py] Re: Problem with unicode data in mssql

2011-03-10 Thread Ross Peoples
I noticed that you use mssql2:// in there. I don't know if it will help, or 
make things worse, but try just mssql:// instead of mssql2://, as that 
adapter is still in development and is not yet supposed to be backwards 
compatible. I have to use MSSQL2000 for an application I'm developing, and 
the mssql adapter is quite buggy. For now, I'm just using sqlite for 
development, then I'll move back to the mssql adapter when I'm ready for 
testing.

Re: [web2py] Lacking nginx deployment guide

2011-03-10 Thread Norbert Klamann


However, don't you have to run nginx behind apache or another server?

No, ngingx is a fine fromtend 


[web2py] Re: encoding problem

2011-03-10 Thread Eduardo
Alright, neither opening in NotePad and resaving with different
encodings nor copying from one editor to another worked.

Opening on NotePad++, however, and copying/pasting to a new file on
the same editor, then saving as UTF-8 solved the problem.

Eduardo

On 10 mar, 13:23, Massimo Di Pierro 
wrote:
> How did you edit using utf8 or did you insert latin-1 chars?
>
> On Mar 10, 9:44 am, Eduardo  wrote:
>
> > Hi,
>
> > I modified the insert( ) function of appadmin.py from the example app
> > by passing a dict to the labels attribute of SQLFORM( ) - in other
> > words:
>
> > appadmin.py > insert( ) > SQLFORM(.. labels=dict)
>
> > The labels, with Portuguese characters, are not correctly encoded on
> > the final result. Note that both appadmin.py and layout.html are
> > declared as utf-8, and those two, together with appadmin.html, were
> > saved as utf-8.
>
> > Also note that a dict passed to SQLTABLE within appadmin.html is being
> > correctly displayed, which makes me confuse.
>
> > Any suggestions?
>
> > Eduardo
>
>


Re: [web2py] Re: problem with type Int

2011-03-10 Thread Jonathan Lundell
On Mar 10, 2011, at 9:36 AM, LightOfMooN wrote:
> 
> Full function is too complex.
> But this little shows the problem well:
> 
> value=request.vars.myvar
> t = type(value)
> value = float(value)
> t2 = type(value)
> value = int(value)
> t3 = type(value)
> print value, t, t2, t3
> 
> result:
> 99,,,
> 
> Why it makes int from 99?

Probably because you're running 64-bit Python.

> 
> On 10 мар, 16:50, villas  wrote:
>> Why don't you try testing the value of 'value' in your code by using a
>> print statement to the console? At least that's what I usually do.
>> 
>> You would ideally provide the entire controller function because your
>> code does not explain itself very well to me (although it may be
>> obvious to others!).
>> 
>> On Mar 10, 8:27 am, LightOfMooN  wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> Yes, ofc
>> 
>>> controller/function:
>> 
>>> prop = db(db.properties.id==request.args(0)).select().first()
>>> value=request.vars.myvar
>> 
>>> try:
>>> value = int(value)
>>> except:
>>> pass
>> 
>>> if value!=prop.value and type(value)==int:
>>> try:
>>> db(db.properties.id==request.args(0)).update(value=value)
>>> except:
>>> pass
>> 
>>> it rises error
>>> (current transaction is aborted,
>>> commands ignored until end of transaction block)
>>> only if value not in range (-2147483648 : 2147483647)
>> 
>>> so I type in shell
>>> a = 2147483647
>>> type(a)>>> 
>> 
>>> a +=
>>> a
>> 
>> 2147493646
>>> type(a)
>> 
>> 
>>> but I think it's already must be long
>> 
>>> On 10 ÍÁÒ, 03:35, Massimo Di Pierro 
>>> wrote:
>> 
 Can I see more of the code without ...
>> 
 On Mar 9, 3:17špm, LightOfMooN  wrote:
>> 
> value=request.vars.myvar
>> 
> try:
> š š value = int(value)
> except:
> š š pass
>> 
> if type(value)==int:
> š š insert()
>> 
> it rises
> (current transaction is aborted,
> commands ignored until end of transaction block)
> even if value > 2147483647
>> 
> But why?
> It's so strange, because type(value) must be long.




Re: [web2py] Attempting to view error in application causes an error in the admin application

2011-03-10 Thread Ross Peoples
Massimo created a new revision (1693) in the trunk about an hour ago that 
reverts the changes to template.py temporarily until it gets fixed. Thanks.

[web2py] Re: problem with type Int

2011-03-10 Thread LightOfMooN
Full function is too complex.
But this little shows the problem well:

value=request.vars.myvar
t = type(value)
value = float(value)
t2 = type(value)
value = int(value)
t3 = type(value)
print value, t, t2, t3

result:
99,,,

Why it makes int from 99?

On 10 мар, 16:50, villas  wrote:
> Why don't you try testing the value of 'value' in your code by using a
> print statement to the console? At least that's what I usually do.
>
> You would ideally provide the entire controller function because your
> code does not explain itself very well to me (although it may be
> obvious to others!).
>
> On Mar 10, 8:27 am, LightOfMooN  wrote:
>
>
>
>
>
>
>
> > Yes, ofc
>
> > controller/function:
>
> > prop = db(db.properties.id==request.args(0)).select().first()
> > value=request.vars.myvar
>
> > try:
> >     value = int(value)
> > except:
> >     pass
>
> > if value!=prop.value and type(value)==int:
> >     try:
> >         db(db.properties.id==request.args(0)).update(value=value)
> >     except:
> >         pass
>
> > it rises error
> > (current transaction is aborted,
> > commands ignored until end of transaction block)
> > only if value not in range (-2147483648 : 2147483647)
>
> > so I type in shell
> > a = 2147483647
> > type(a)>>> 
>
> > a +=
> > a
>
> > >>> 2147493646
> > type(a)
> > >>> 
>
> > but I think it's already must be long
>
> > On 10 ÍÁÒ, 03:35, Massimo Di Pierro 
> > wrote:
>
> > > Can I see more of the code without ...
>
> > > On Mar 9, 3:17špm, LightOfMooN  wrote:
>
> > > > value=request.vars.myvar
>
> > > > try:
> > > > š š value = int(value)
> > > > except:
> > > > š š pass
>
> > > > if type(value)==int:
> > > > š š insert()
>
> > > > it rises
> > > > (current transaction is aborted,
> > > > commands ignored until end of transaction block)
> > > > even if value > 2147483647
>
> > > > But why?
> > > > It's so strange, because type(value) must be long.


[web2py] Re: list and loop problem

2011-03-10 Thread Rick
I'd like to print the list in a html file.

On Mar 10, 6:16 pm, Bruno Rocha  wrote:
> where do you want to output this?
>
> in to pure HTML or in a SQLTABLE?
>
> 2011/3/10 Rick 
>
>
>
>
>
>
>
> > Hi,
>
> > I want to print a linked list and add a "delete this item" button next
> > to each item:
> > 
> > [item 1][delete this item]
> > [item 2][delete this item]
> > [item 3][delete this item]
> > 
> > ...but I've no clue how to write the code. The problem is to direct
> > the second delete button to the second item.
>
> > Thanks in advance for help!


[web2py] Re: Is a UNION query possible with DAL ?

2011-03-10 Thread Norbert Klamann
For the time being the following seems(!) to work:
I want to show the socument with a direct relation to a company and those 
documents, which belong to a person, which belongs to the company
company_id is the key.

   r1=db((db.document.person==db.person.id) & (db.person.company == 
company_id)).select(db.document.ALL,orderby=db.document.name)
   r2=db(db.document.company == 
company_id).select(orderby=db.document.name)
   docs=r1|r2

nearly untested !

I raise the ticket in Google 


Re: [web2py] Show in select list a field of another table

2011-03-10 Thread Norbert Klamann
Hello Richard,
many thanks for your work. When I think about it : The table 
'person_company' could be a view, couldn't it ?
But i have not understood :

a) how to define a view in DAL ?

b) How to use it as the 'label' Parameter for the IS_IN_DB Validator.

If this would be possible the redundant table 'person_company' could be 
omitted.

Thanks again for listening (and answering  of course)

Norbert


Re: [web2py] list and loop problem

2011-03-10 Thread Bruno Rocha
where do you want to output this?

in to pure HTML or in a SQLTABLE?

2011/3/10 Rick 

> Hi,
>
> I want to print a linked list and add a "delete this item" button next
> to each item:
> 
> [item 1][delete this item]
> [item 2][delete this item]
> [item 3][delete this item]
> 
> ...but I've no clue how to write the code. The problem is to direct
> the second delete button to the second item.
>
> Thanks in advance for help!


Re: [web2py] Lacking nginx deployment guide

2011-03-10 Thread pbreit
Probably good to have nginx instructions since that seems to be the fashionabl 
web server right now. I'm a bit annoyed by Cherokee's lack of reliable 
file-based configuration as well as it's lame new marketplace.


[web2py] Re: howto publish own podcast with web2py?

2011-03-10 Thread DenesL

Have you seen this section in the manual?
http://web2py.com/book/default/chapter/09#RSS


On Mar 10, 10:52 am, plavcik  wrote:
> Hello,
>
> I'm creating own podcast and like to publish relevant feed in web2py.
> Could you point me to some examples (regular RSS feed for example),
> which can be good starting point?
>
> Thank you,
> Jiri


Re: [web2py] Show in select list a field of another table

2011-03-10 Thread Richard Vézina
For this purpose I do a view at database level, but you can do it in web2py
and use it in your requires or represent.

Here is my solution :

## Model ##

db.define_table('company',
Field('name', readable=False))

db.define_table('person',
Field('person_id','id'),
Field('first_name',readable=False),
Field('last_name'),
Field('company',db.company,label='Firma',readable=False),
Field('role',label='Rolle',readable=False))

db.person.company.requires=IS_IN_DB(db,'company.id', '%(name)s')

db.define_table('person_company',
Field('person_id','id'),
db.person,
db.company,
format='%(first_name)s %(last_name)s %(name)s')

db.define_table('document',
Field('name'),
Field('file','upload'),
Field('filename','string',writable=False,label='Dateiname'),
Field('person',db.person))

db.document.person.requires=IS_EMPTY_OR(IS_IN_DB(db,'person_company.id','%(first_name)s
%(last_name)s %(name)s' %))


## Controller ## In default or anywhere esle

def create_company():
form = crud.create(db.company)
return dict(form=form)

def create_person():
form = crud.create(db.person)
if form.accepts(request.vars, session):
__trigger_person_company_insert(form.vars.id,request.vars) # Here we
trigger the insertion in db.person into a db.person_company that will be use
as an "SQL view"
session.flash = 'form accepted'
redirect(URL())
return dict(form=form)

def __trigger_person_company_insert(person_id,vars):
db.person_company.insert(person_id=person_id,
first_name=vars.first_name,
last_name=vars.last_name,
company=vars.company,
role=vars.role,
name=db(db.company.id==vars.company).select(db.company.name
).first().name)
db.commit()


Since the all the information from both table (person and company) are
available into person_company you can use it for requires and
representation...

How it sounds?

Richard

On Thu, Mar 10, 2011 at 6:20 AM, Norbert Klamann <
norbert.klam...@googlemail.com> wrote:

> Hello all,
> I want to shoe in the select list a field from another table and don't know
> how to do it.
>
> I want to show a select list for persons with their name and the name of
> the company to which they belong
>
> Consider the following model
> db.define_table('document',
> Field('name'),
> Field('file','upload'),
> Field('filename','string',writable=False,label='Dateiname'),
> Field('person',db.person),
>  )
>
> db.document.person.requires=IS_EMPTY_OR(IS_IN_DB(db,'person.id', '%(name)s
> %(company)s')) ## here i can only show  the number !
>
> db.define_table('person',
> Field('name',readable=False),
> Field('company',db.company,label='Firma',readable=False),
> Field('role',label='Rolle',readable=False),
> )
> db.define_table('company',
> Field('name', readable=False),
> )
>
> Thanks a lot
>
> Norbert
>
>


[web2py] list and loop problem

2011-03-10 Thread Rick
Hi,

I want to print a linked list and add a "delete this item" button next
to each item:

[item 1][delete this item]
[item 2][delete this item]
[item 3][delete this item]

...but I've no clue how to write the code. The problem is to direct
the second delete button to the second item.

Thanks in advance for help!


[web2py] Re: Dotcloud hosting great tutorial but stuck

2011-03-10 Thread pbreit
For dot cloud you need to be using the web2py source code, not the Mac download.

You should be able to type "ls -al" in any terminal window. If not, you have 
big problems. That's ELL ESS space dash A ELL


[web2py] Re: encoding problem

2011-03-10 Thread Eduardo
I edited appadmin.py via Notepad++ configured to save as UTF-8 (the
file itself already begins with # -*- coding: utf-8 -*-).

Exactly the same way I typed the Portuguese characters on
appadmin.html (which are displayed correctly).

Note that appadmin.py isn't displayed correctly through the
framework's editor. I even 'corrected' the characters through the
framework - just to see them messed up on NotePad++ this time.

Thanks,

Eduardo

On 10 mar, 13:23, Massimo Di Pierro 
wrote:
> How did you edit using utf8 or did you insert latin-1 chars?
>
> On Mar 10, 9:44 am, Eduardo  wrote:
>
> > Hi,
>
> > I modified the insert( ) function of appadmin.py from the example app
> > by passing a dict to the labels attribute of SQLFORM( ) - in other
> > words:
>
> > appadmin.py > insert( ) > SQLFORM(.. labels=dict)
>
> > The labels, with Portuguese characters, are not correctly encoded on
> > the final result. Note that both appadmin.py and layout.html are
> > declared as utf-8, and those two, together with appadmin.html, were
> > saved as utf-8.
>
> > Also note that a dict passed to SQLTABLE within appadmin.html is being
> > correctly displayed, which makes me confuse.
>
> > Any suggestions?
>
> > Eduardo
>
>


[web2py] Re: javascript/jquery advice

2011-03-10 Thread Anthony
For grid stuff, also check out Bruno's excellent PowerTable plugin:
http://powertable.blouweb.com/
https://bitbucket.org/rochacbruno/powertable
 

On Thursday, March 10, 2011 9:29:31 AM UTC-5, spyker wrote:

> I am starting to learn javascript and am thinking of using more jquery and 
> jquery UI  and ajax elements in my applications and would appreciate on how 
> to approach it:
>
> 1. Starting with javascript tutorials (e.g. from developer.mozilla.org)  
> and move on to jquery tutorials and later on to how web2py uses them.
> 2. Starting with web2py-customised jquery elements (or do you call them 
> 'components') and try to explore that further.
>
> I have looked at some jquery-related slices and it seems that the way to 
> include jquery ui stuff in web2py is not that straight forward.  Some of the 
> slices' have outdated documentation.  The documentation for 
> http://web2pyslices.com/main/slices/take_slice/11 for example is no longer 
> used by the latest code one can download from a link on the slice.
>
> Also: I have seen that for example jqgrid has a lot more capabilities that 
> is available in the plugin-wiki.  I would like to learn how to use for 
> example more complicated datasources with jqgrid and subtables when clicked 
> on a row of data linked to other tables.  
>
> 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
>
>

[web2py] Re: Is a UNION query possible with DAL ?

2011-03-10 Thread Massimo Di Pierro
can you open a ticket on google code about this?

On Mar 10, 9:28 am, Norbert Klamann 
wrote:
> I look for something like
>
>  select a,b,c from table1
> union
> select a,b,c from table2
>
> I also tried to combine 2 distinct 'Rows' objects and dal.Sets (with the
> same structure) , but both don't support this operation.
>
> Norbert


[web2py] howto publish own podcast with web2py?

2011-03-10 Thread plavcik
Hello,

I'm creating own podcast and like to publish relevant feed in web2py.
Could you point me to some examples (regular RSS feed for example),
which can be good starting point?

Thank you,
Jiri


Re: [web2py] Re: Show in select list a field of another table

2011-03-10 Thread Richard Vézina
No he wants also to make a cross table requires or represent...

I am working on something for him... I almost finish, I would like criticism
when I post my solution...

Richard

On Thu, Mar 10, 2011 at 11:14 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> You need to change the order
>
> db.define_table('person',
>Field('name',readable=False),
>Field('company',db.company,label='Firma',readable=False),
>Field('role',label='Rolle',readable=False),
> )
> db.define_table('company',
>Field('name', readable=False),
> )
> db.define_table('document',
>Field('name'),
>Field('file','upload'),
>Field('filename','string',writable=False,label='Dateiname'),
>Field('person',db.person),
>  )
>
> db.document.person.requires=IS_EMPTY_OR(IS_IN_DB(db,'person.id', '%
> (name)s %(company)s'))
>
>
>
>
>
>
> On Mar 10, 5:20 am, Norbert Klamann 
> wrote:
> > Hello all,
> > I want to shoe in the select list a field from another table and don't
> know
> > how to do it.
> >
> > I want to show a select list for persons with their name and the name of
> the
> > company to which they belong
> >
> > Consider the following model
> > db.define_table('document',
> > Field('name'),
> > Field('file','upload'),
> > Field('filename','string',writable=False,label='Dateiname'),
> > Field('person',db.person),
> >  )
> >
> > db.document.person.requires=IS_EMPTY_OR(IS_IN_DB(db,'person.id',
> '%(name)s
> > %(company)s')) ## here i can only show  the number !
> >
> > db.define_table('person',
> > Field('name',readable=False),
> > Field('company',db.company,label='Firma',readable=False),
> > Field('role',label='Rolle',readable=False),
> > )
> > db.define_table('company',
> > Field('name', readable=False),
> > )
> >
> > Thanks a lot
> >
> > Norbert
>


[web2py] Re: Performing database inserts with FORM( )

2011-03-10 Thread Anthony
On Thursday, March 10, 2011 11:23:43 AM UTC-5, Eduardo wrote: 
>
> OK, let's try SQLFORM.factory without diverting from my original 
> purpose: if I use SQLFORM.factory to generate the form, should I use 
> the following to make the inserts? 
>
> form = SQLFORM.factory() # Field( )s go here 
> if form.accepts(request.vars): 
> db.table.insert(**db.table._filter_fields(form.vars))

 
I haven't tried it, but that's exactly what the book says. I think 
_filter_fields filters the form.vars to only include fields that are 
actually in the table.
 
Anthony


[web2py] Re: Performing database inserts with FORM( )

2011-03-10 Thread Eduardo
OK, let's try SQLFORM.factory without diverting from my original
purpose: if I use SQLFORM.factory to generate the form, should I use
the following to make the inserts?

form = SQLFORM.factory() # Field( )s go here
if form.accepts(request.vars):
db.table.insert(**db.table._filter_fields(form.vars))

Eduardo

On 10 mar, 11:18, Ross Peoples  wrote:
> Let's not forget about SQLFORM.factory either. This lets you create a
> SQLFORM based on a virtual table that you create as an argument to
> SQLFORM.factory. For example, I used this code to provide edit capabilities
> when editing time clock entries for an app I'm writing. It includes form
> validation, and I wrote a module that handles the actual db update. When you
> see "timeclock.edit_entry()", this is just handing off the form
> variables to the module, which performs extra validation on the data before
> committing it to the db. NOTE: All of this code is inside my "def edit():"
> function.
>
> def validate_form(form):
>         users = [auth.user.id]
>         for user in user_security.get_subordinates(auth.user):
>             users.append(user.auth_user.id)
>
>         if int(form.vars.auth_user) not in users:
>             form.errors.adjusted_start = "You do not have permission to
> modify this person's time clock."
>
> if not request.args(0): raise HTTP(400, 'Timeclock ID not found')
>     timeclock_id = request.args(0)
>     timeclock_entry = db(db.timeclock.id==timeclock_id).select().first()
>     if timeclock_entry is None: raise HTTP(400, 'Timeclock ID not found')
>
>     form = SQLFORM.factory(
>         Field('adjusted_start', 'datetime', requires=IS_NOT_EMPTY()),
>         Field('adjusted_end', 'datetime'),
>         Field('reason', 'text', requires=IS_NOT_EMPTY()),
>         Field('auth_user', db.auth_user, readable=False, writable=False),
>         hidden = {'id': timeclock_id, 'auth_user':
> timeclock_entry.auth_user.id}
>     )
>     form.vars.auth_user = timeclock_entry.auth_user.id
>     form.vars.adjusted_start = timeclock_entry.adjusted_start
>     form.vars.adjusted_end = timeclock_entry.adjusted_end
>     if form.accepts(request.vars, session, keepvalues=True,
> onvalidation=validate_form(form)):
>         row_id = timeclock.edit_entry(auth.user, timeclock_entry,
> form.vars.reason, form.vars.adjusted_start, form.vars.adjusted_end)
>         if isinstance(row_id, str):
>             response.flash = row_id
>         else:
>             redirect(URL('index'))
>
>     return dict(form=form, timeclock_entry=timeclock_entry, history=history)


[web2py] Re: Is a UNION query possible with DAL ?

2011-03-10 Thread Massimo Di Pierro
Not yet. Will look into it.

On Mar 10, 9:28 am, Norbert Klamann 
wrote:
> I look for something like
>
>  select a,b,c from table1
> union
> select a,b,c from table2
>
> I also tried to combine 2 distinct 'Rows' objects and dal.Sets (with the
> same structure) , but both don't support this operation.
>
> Norbert


[web2py] Re: Suggested functionality extention for SQLTABLE

2011-03-10 Thread Massimo Di Pierro
Can you please email this to me as a patch?

diff original modified > sqltable.patch


On Mar 10, 9:47 am, Andrew Buchan  wrote:
> Hello,
>
> I wasn't happy with two things about SQLTABLE :
>
> A) How you are obliged to show the id field if you want linkto
> functionality. Not only do I not always want the user to see that id
> field (they may use a different identifier, or it may simply confuse
> them), I would also rather be able to label the link with 'edit',
> 'approve' or 'delete' etc... and preferably have as many options as I
> want.
>
> B) How it generates hyperlinks for all fields of type 'reference', as
> opposed to just the id field. I was about to submit this as a bug
> until I checked the code and saw it was done on purpose. The reason it
> seems wrong to me is that the function I would typically supply as the
> linkto argument is designed to handle records from the table from
> which SQLTABLE was generated, and not records from one of the
> referenced tables, yet the generated hyperlink creates a URL to that
> function passing an id from the referenced table, which is dangerous
> if that's not what was intended. There also doesn't seem to be a way
> to escape this behaviour if I want to use linkto functionality.
>
> So I set out to change SQLTABLE to have an optional argument:
> linkColumns, which takes a list/tuple of format [(ColumnHeaderText,
> Function, LinkText), ...].
>
> This adds columns to the right of the table with links to which the id
> of the record in that row will be passed.
> With this you can skip the linkto argument, and if you specify columns
> in the columns args you can avoid showing the id (although it needs to
> be included in the first argument: sqlrows), so it becomes trivial to
> generate a table like so:
>
> Micky Mouse     Disney       $15,000       [edit]      [show
> photos]      [archive]     [delete]
> Donald Duck      Disney       $18,000       [edit]      [show
> photos]      [archive]     [delete]
>
> It works just the way I want it and doesn't interfere with the normal
> functioning of SQLTABLE, as far as I can tell (although I had to move
> linkColumns=None to the end of the argument list as it would otherwise
> go wrong when the appadmin's database adminstration page called
> it...It seemed to be explicitly naming linkColumns in the arguments,
> which is strange...)
>
> I'm pretty pleased with this, I've never extended an open-source
> framework's functionality before, and was wondering whether it should
> be included in web2py?
> I've listed the 3 changes to sqlhtml.py below, I think the only
> additional steps needed is for someone to go test it and make sure I'm
> not doing anything daft.
> Perhaps some users would also prefer if the LinkText argument could
> accept something similar to the format string used in field
> definitions, i.e. "%(another_column_name_used_in_the_row)s"...
>
> Changes to sqlhtml.py (I'm on version 1.93.2):
>
>  circa line 1264:
>
> def __init__(
>         self,
>         sqlrows,
>         linkto=None,
>         upload=None,
>         orderby=None,
>         headers={},
>         truncate=16,
>         columns=None,
>         th_link='',
>         linkColumns=None,
>         **attributes
>         ):
>
>  circa line 1296:
>
>         if headers!=None:
>             for c in columns:
>                 if orderby:
>                     row.append(TH(A(headers.get(c, c),
>                                     _href=th_link+'?orderby=' + c)))
>                 else:
>                     row.append(TH(headers.get(c, c)))
>             if linkColumns:
>                 for lc in linkColumns:
>                     row.append(TH(lc[0]))
>             components.append(THEAD(TR(*row)))
>
>         tbody = []
>
>  circa line 1390:
>
>             if linkColumns:
>                 if not record.has_key('id'):
>                     raise SyntaxError, 'Sqlrows must include the id
> field when the linkColumns argument is specified in SQLTABLE()'
>                 for lc in linkColumns:
>                     # Not sure why I need a try catch here...
>                     try:
>                         href = lc[1](record.id, 'table', tablename)
>                     except TypeError:
>                         href = '%s/%s/%s' % (linkto, tablename,
> record.id)
>                     r = A(lc[2], _href=href)
>                     row.append(TD(r))


[web2py] Re: plugin_wiki: KeyError: 'active'

2011-03-10 Thread villas
On Mar 10, 3:06 pm, Massimo Di Pierro 
wrote:
> This was fixed yesterday night.

Don't you still need to add 'is_active' to the model
'plugin_wiki_page' ??




[web2py] Re: encoding problem

2011-03-10 Thread Massimo Di Pierro
How did you edit using utf8 or did you insert latin-1 chars?

On Mar 10, 9:44 am, Eduardo  wrote:
> Hi,
>
> I modified the insert( ) function of appadmin.py from the example app
> by passing a dict to the labels attribute of SQLFORM( ) - in other
> words:
>
> appadmin.py > insert( ) > SQLFORM(.. labels=dict)
>
> The labels, with Portuguese characters, are not correctly encoded on
> the final result. Note that both appadmin.py and layout.html are
> declared as utf-8, and those two, together with appadmin.html, were
> saved as utf-8.
>
> Also note that a dict passed to SQLTABLE within appadmin.html is being
> correctly displayed, which makes me confuse.
>
> Any suggestions?
>
> Eduardo


Re: [web2py] Lacking nginx deployment guide

2011-03-10 Thread pbreit
Probably good to have nginx instructions since that seems to be the fashionabl 
web server right now. I'm a bit annoyed by Cherokee's lack of reliable 
file-based configuration as well as it's lame new marketplace.

However, don't you have to run nginx behind apache or another server?


[web2py] Re: conditionally include in view

2011-03-10 Thread Massimo Di Pierro
correct

On Mar 9, 5:14 pm, ron_m  wrote:
> I use this in a portion of the views coded for what I am working on and it
> works for me. I just ran the page with the test true and again with the test
> false and I get the include file content inside the {{if condition:}} branch
> if the condition is True and the html in the {{else:} branch if the
> condition is False. I verified with a View Source in the browser, the code
> from the include file is not there when the condition is False. I am on
> 1.93.2 but this has been consistent for several months now.
>
> Here is a chunk of code
>
> {{site_names =  session.user_access['site_names']}}
> {{if len(site_names) > 1:}}
>     {{include 'common/site_switcher.html'}}
>     
> {{else:}}
>     {{=B(header)}}
>     {{pass}}
> {{include 'live/display_mode_switcher.html'}}
> 
>
> I think the include is indeed expanded out unconditionally but when the
> Python logic runs the response.write is not executed for that portion of the
> code if condition is False.
>
> Replace someData in your example with True and then with False and refresh
> the page to see what you get in each case. The truthness or falseness of a
> variable can be deceiving. Also the include file name should be the path
> portion past views.


[web2py] Re: ('active') when running plugin_wiki

2011-03-10 Thread Massimo Di Pierro
fixed now

On Mar 9, 8:15 pm, villas  wrote:
> Yes, plugin_wiki is broken because the field active was deleted. I
> already reported this and I hope Massimo will fix it soon.
>
> On Mar 9, 11:24 pm, mat --  wrote:
>
>
>
>
>
>
>
> > Hi
>
> > I downloaded latest version of Web2py and plugin_wiki.
>
> > I setup Janrain. I can login.
>
> > I created a new app and uploaded plugin_wiki as a plugin.
>
> > I can create a first page and save it using plugin_wiki features.
>
> > But second time I click the "Page" tab i get the following error:
>
> > Version
> >  web2py™ Version 1.93.2 (2011-03-06 10:18:04)  Python Python 2.6.6:
> > /usr/bin/python
> > Traceback
>
> > 1.
> > 2.
> > 3.
> > 4.
> > 5.
> > 6.
> > 7.
> > 8.
> > 9.
> > 10.
>
> > Traceback (most recent call last):
> >   File "/home/linux/Dev/web2py/gluon/restricted.py", line 188, in restricted
> >     exec ccode in environment
> >   File 
> > "/home/linux/Dev/web2py/applications/Docs/views/plugin_wiki/index.html",
> > line 113, in 
> >   File "/home/linux/Dev/web2py/gluon/dal.py", line 3347, in __getattr__
> >     return self[key]
> >   File "/home/linux/Dev/web2py/gluon/dal.py", line 3338, in __getitem__
> >     return dict.__getitem__(self, key)
> > KeyError: 'active'
>
> > Error snapshot [image: help] Detailed traceback description
>
> > ('active')
>
> > Anyone knows what is the issue here?
>
> > Thanks!
>
> > Mat


Re: [web2py] Attempting to view error in application causes an error in the admin application

2011-03-10 Thread Jonathan Lundell
On Mar 10, 2011, at 7:47 AM, Ross Peoples wrote:
> I just updated to the latest trunk and I am now having problems view errors 
> in my application, as clicking on a ticket creates another ticket, but in the 
> admin application this time. I opened the latest error in the 
> applications/admin/errors folder, and this is the contents of the latest 
> error:

Here's a workaround (Massimo, this is an effect of the template patch; don't 
release until we fix it one way or the other):

In applications/admin/views/default/ticket.html find lines 85-86:

{{=CODE('\n'.join([x[1] for x in sorted(frame['lines'].items(),key=lambda 
x: x[0])]), 
language='python', link=None, counter=min(frame['lines'].keys()), 
highlight_line=frame['lnum'])}}

...and escape the newline at the end of line 85, thus:

{{=CODE('\n'.join([x[1] for x in sorted(frame['lines'].items(),key=lambda 
x: x[0])]), \
language='python', link=None, counter=min(frame['lines'].keys()), 
highlight_line=frame['lnum'])}}



[web2py] Re: Show in select list a field of another table

2011-03-10 Thread Massimo Di Pierro
You need to change the order

db.define_table('person',
Field('name',readable=False),
Field('company',db.company,label='Firma',readable=False),
Field('role',label='Rolle',readable=False),
)
db.define_table('company',
Field('name', readable=False),
)
db.define_table('document',
Field('name'),
Field('file','upload'),
Field('filename','string',writable=False,label='Dateiname'),
Field('person',db.person),
 )

db.document.person.requires=IS_EMPTY_OR(IS_IN_DB(db,'person.id', '%
(name)s %(company)s'))






On Mar 10, 5:20 am, Norbert Klamann 
wrote:
> Hello all,
> I want to shoe in the select list a field from another table and don't know
> how to do it.
>
> I want to show a select list for persons with their name and the name of the
> company to which they belong
>
> Consider the following model
> db.define_table('document',
>     Field('name'),
>     Field('file','upload'),
>     Field('filename','string',writable=False,label='Dateiname'),
>     Field('person',db.person),
>  )
>
> db.document.person.requires=IS_EMPTY_OR(IS_IN_DB(db,'person.id', '%(name)s
> %(company)s')) ## here i can only show  the number !
>
> db.define_table('person',
>     Field('name',readable=False),
>     Field('company',db.company,label='Firma',readable=False),
>     Field('role',label='Rolle',readable=False),
> )
> db.define_table('company',
>     Field('name', readable=False),
> )
>
> Thanks a lot
>
> Norbert


Re: [web2py] Re: Cant make a simple database

2011-03-10 Thread pbreit
Yeah I saw that. What are people's thoughts on that? It seems like clutter to 
me but can definitely mak things easier in places.


[web2py] Re: Dotcloud hosting great tutorial but stuck

2011-03-10 Thread pbreit
For dot cloud you need to be using the web2py source code, not the Mac download.

You should be able to type "ls -al" in any terminal window. If not, you have 
big problems. That's ELL ESS space dash A ELL

You can develop on the Mac download but you ar going to need to first deploy 
web2py from the source code and then deploy your app from the app directory in 
your Mac download version.


[web2py] Re: filtering selection list

2011-03-10 Thread Massimo Di Pierro
Two things:

1)
do not do:
t_list = gdb(gdb.select(gdb.t_table.code, gdb.t_table.name))
Field('t', requires = [IS_NOT_EMPTY(), IS_IN_SET(t_list)])

instead fo

Field('t', requires = IS_IN_DB(gdb,'t_table.code','%(name)s'))

2) for v you can do

Field('v', requires = IS_IN_DB(gdb(query),'v_table.code','%(name)s'))
where query depends on request.vars.t

On Mar 9, 7:25 pm, Nik  wrote:
> i need to validate a field based on an external read-only database (i
> call it gdb)
>
> there are four tables that are related by their own codes
> gdb.r_table.code
> gdb.p_table.code
> gdb.t_table.code
> gdb.v_table.code
>
> I have no use for the the id field of each table. Each table has,
> among others:
> r_table.code is unique but r_table.name may not be so.
> p_table.code is unique but p_table.name may not be.
> t_table.code is uniquely composed of r_table.code + p_table.code.
> t_table.name may not be unique.
> v_table-code is uniquely composed of t.table-code+serial numbers
> v_table.name may not be unique.
>
> In my app database, I only need to store the v_table-code since I can
> programatically find out what the other codes are from it. But for the
> convenience of the user (who is probably unaware of the codes), I need
> to present a selection list of v_table.names based on choices they
> made from p_table.name and t_table.name. There are 100 records in
> p_table, 1,500 in t_table and 40,000 in v_table.
>
> What's the best way to do this?
>
> I thought that I could populate a variable with the list of each
> p_list = gdb(gdb.select(gdb.p_table.code, gdb.p_table_name))
> t_list = gdb(gdb.select(gdb.t_table.code, gdb.t_table_name))
> v_list = gdb(gdb.select(gdb.v_table.code, gdb.v_table_name)) # prolly
> not a good idea to retrieve all 40,000 but 
>
> then in the requires argument of each field
> form = SQLFORM.factory(
>         # snip. other fields here
>
>         Field('p', requires = [IS_NOT_EMPTY(), IS_IN_SET(p_list)), # this
> works
>         Field('t', requires = [IS_NOT_EMPTY(), IS_IN_SET(t_list)), # how to
> trigger controller to present a sublist of t_list
>         Field('v', requires = [IS_NOT_EMPTY(), IS_IN_SET(v_list)) # how to
> trigger controller to present a sublist of v_list
>
>         # snip. other fields here)
>
> Above works but no validation is enforced. (i.e. a user can select a
> 'v' that is not actually a member of his/her 't' selection)
> How can i trigger a controller that will filter t_list based on
> selection made on 'p' field, and another controller to do the same for
> v_list based on 'T' selection from t_list.
>
> thanks.


[web2py] javascript/jquery advice

2011-03-10 Thread pbreit
Start with th Ajax chapter in the web2py book.


[web2py] Re: javascript/jquery advice

2011-03-10 Thread Ross Peoples
I would read a few short tutorials on JavaScript before jumping into jQuery. 
It is important to understand things like dictionaries, as nearly every 
jQuery UI component requires you to pass a dictionary of arguments. Working 
with jQuery is much different than working with regular JavaScript, so don't 
feel like you need to be a JS expert to use jQuery, as jQuery is almost a 
language on its own.

The important thing to remember with using JavaScript is to terminate every 
line with a semi-colon (;), even though this is not a requirement, you will 
save yourself hours of debugging by just doing it. Another thing is to never 
declare a variable like you do in Python. Always declare your variables 
using: "var myvar = 1;" The key component being the "var" keyword. If you 
forget to add that keyword to the beginning, the variable you declare will 
be available globally, and this can cause a lot of unexpected problems.

As for jqgrid, it is part of plugin-wiki, I believe. However, jqgrid itself 
is a beast. If you are anything like me, you will find yourself writing a 
full page of just initialization arguments. I would work to become 
proficient in jQuery, jQuery UI, and web2py long before you start playing 
with jqgrid, as there is a lot of stuff you have to figure out in order to 
get everything working properly. To avoid frustration, it would help to 
already know how all the individual pieces work before trying to integrate 
them.


Re: [web2py] Re: Cron not running/starting on windows

2011-03-10 Thread Andrew Buchan
Thanks, I think the pywin32 extensions are needed to run web2py from
source on windows full stop. Either way, I have them installed.

I'm working around this issue using cURL and a scheduled task, which
actually suits my fine for now.


On Thu, Mar 10, 2011 at 1:57 PM, villas  wrote:
> If you are running from source,  I believe you needed the Mark Hammond
> extensions to get cron working. I didn't see this mentioned in this
> thread so I thought I'd post it in case it helps or gives an extra
> clue.
>
> Regards, David
>
> On Mar 9, 11:49 am, Andrew Buchan  wrote:
>> Hello,
>>
>> I have web2py running as a service on Windows Server 2003 from source
>> at version 1.93.2.
>> I'm trying to get cron to work but nothing seems to be happening. I
>> can't figure out if its running and failing, or not running at all, so
>> it would be really useful if someone could answer the following for
>> me:
>>
>> a) Do I need to restart the service for changes to the cron file to
>> take effect?
>> b) Does the crontab file need to be in a specific encoding - could I
>> have screwed it up with Notepad?
>> c) Does the cron.master file in the admin application play a role?
>> d) Do I need to do anything in the options.py file (which I use as I
>> run web2py as a windows service)?
>> e) If one line in the crontab file fails, do the subsequent lines
>> still run?
>>
>> I've been through all the documentation and searched this group but
>> can't figure it out. Assuming I'm doing nothing wrong with regards to
>> the above, if anyone can shed any light on the file contents below I
>> would be most grateful.
>>
>> Thanks,
>>
>> Andrew.
>>
>> --
>> Here's the cron file:
>>
>> #crontab
>> */1     *       *       *       *       root 
>> **applications/HubFormsDev/cron/Script1.py
>>
>> --
>> Here's Script1.py:
>>
>> import datetime
>>
>> TimeString = datetime.datetime.now().strftime('%d.%m -- %H.%M.%S')
>> f = open('C:\\Program Files\\Hub Pages\\web2py\\applications\
>> \HubFormsDev\\cron\\%s.txt' % TimeString, 'w')
>> f.close()
>>
>> --
>> Here's options.py:
>>
>> import socket
>> import os
>>
>> ip = '0.0.0.0'
>> port = 80
>> password = 'abuchan'  # ##  means use the previous password
>> pid_filename = 'httpserver.pid'
>> log_filename = 'httpserver.log'
>> profiler_filename = None
>> ssl_certificate = ''  # ## path to certificate file
>> ssl_private_key = ''  # ## path to private key file
>> numthreads = 10
>> server_name = socket.gethostname()
>> request_queue_size = 5
>> timeout = 10
>> shutdown_timeout = 5
>> folder = os.getcwd()
>> extcron = None
>> nocron = None
>>
>> --


[web2py] Re: Performing database inserts with FORM( )

2011-03-10 Thread DenesL


On Mar 10, 9:14 am, Eduardo  wrote:
> Thank you, DenesL; I know that. I don't see how that would help me. I
> do need to insert the data on the DB.
>
> Eduardo
>
> On 10 mar, 11:11, DenesL  wrote:
>
> > FYI you can turn off the automatic DB functions when using SQLFORM
> > specifying dbio=False as a parameter in the form.accepts(...), see:
>
> >http://web2py.com/book/default/chapter/07#SQLFORM-without-database-IO
>
> > On Mar 10, 9:03 am, Eduardo  wrote:
>
> > > I need to reorder fields and group then into  tags. Also,
> > > because I'm dealing with a legacy database, I have to implement
> > > validation on new entries only, not on db.py.
>
> > > Please note I am just guessing FORM() and  accepts() would be the best
> > > alternative. Feel free to suggest alternatives.
>
> > > Thanks,
>
> > > Eduardo
>
> > > On 10 mar, 10:51, Kenneth Lundström 
> > > wrote:
>
> > > > Please explain what kind of control you need. It's much easier to help.
>
> > > > Kenneth
>
> > > > > Hello,
>
> > > > > I understand database inserts with SQLFORM( ) and accepts( ) are
> > > > > automatic when input is valid.

Just pointing out that you can turn the auto part off.

> > > > > However, I need more control over the
> > > > > form fields and validation upon data entry, not on the model level.
> > > > > Those are limited when using SQLFORM.

You can still use SQLFORM if you want, and do any validation you might
need after form.accepts with dbio=False; alternatively you could use
the onvalidation parameter.

SQLFORM and FORM are not fieldset friendly, but you can use them as a
base in your own custom forms.

> > > > > Can anyone point out a simple example of using FORM( ) and accepts( )
> > > > > to then insert the values on a database?

After all the custom validation you have control over when to insert
if you have dbio=False.
Hope it helps.

> > > > > Thanks,
>
> > > > > Eduardo
>
>


[web2py] Suggested functionality extention for SQLTABLE

2011-03-10 Thread Andrew Buchan
Hello,

I wasn't happy with two things about SQLTABLE :

A) How you are obliged to show the id field if you want linkto
functionality. Not only do I not always want the user to see that id
field (they may use a different identifier, or it may simply confuse
them), I would also rather be able to label the link with 'edit',
'approve' or 'delete' etc... and preferably have as many options as I
want.

B) How it generates hyperlinks for all fields of type 'reference', as
opposed to just the id field. I was about to submit this as a bug
until I checked the code and saw it was done on purpose. The reason it
seems wrong to me is that the function I would typically supply as the
linkto argument is designed to handle records from the table from
which SQLTABLE was generated, and not records from one of the
referenced tables, yet the generated hyperlink creates a URL to that
function passing an id from the referenced table, which is dangerous
if that's not what was intended. There also doesn't seem to be a way
to escape this behaviour if I want to use linkto functionality.

So I set out to change SQLTABLE to have an optional argument:
linkColumns, which takes a list/tuple of format [(ColumnHeaderText,
Function, LinkText), ...].

This adds columns to the right of the table with links to which the id
of the record in that row will be passed.
With this you can skip the linkto argument, and if you specify columns
in the columns args you can avoid showing the id (although it needs to
be included in the first argument: sqlrows), so it becomes trivial to
generate a table like so:

Micky Mouse Disney   $15,000   [edit]  [show
photos]  [archive] [delete]
Donald Duck  Disney   $18,000   [edit]  [show
photos]  [archive] [delete]

It works just the way I want it and doesn't interfere with the normal
functioning of SQLTABLE, as far as I can tell (although I had to move
linkColumns=None to the end of the argument list as it would otherwise
go wrong when the appadmin's database adminstration page called
it...It seemed to be explicitly naming linkColumns in the arguments,
which is strange...)

I'm pretty pleased with this, I've never extended an open-source
framework's functionality before, and was wondering whether it should
be included in web2py?
I've listed the 3 changes to sqlhtml.py below, I think the only
additional steps needed is for someone to go test it and make sure I'm
not doing anything daft.
Perhaps some users would also prefer if the LinkText argument could
accept something similar to the format string used in field
definitions, i.e. "%(another_column_name_used_in_the_row)s"...

Changes to sqlhtml.py (I'm on version 1.93.2):

 circa line 1264:

def __init__(
self,
sqlrows,
linkto=None,
upload=None,
orderby=None,
headers={},
truncate=16,
columns=None,
th_link='',
linkColumns=None,
**attributes
):

 circa line 1296:

if headers!=None:
for c in columns:
if orderby:
row.append(TH(A(headers.get(c, c),
_href=th_link+'?orderby=' + c)))
else:
row.append(TH(headers.get(c, c)))
if linkColumns:
for lc in linkColumns:
row.append(TH(lc[0]))
components.append(THEAD(TR(*row)))

tbody = []

 circa line 1390:

if linkColumns:
if not record.has_key('id'):
raise SyntaxError, 'Sqlrows must include the id
field when the linkColumns argument is specified in SQLTABLE()'
for lc in linkColumns:
# Not sure why I need a try catch here...
try:
href = lc[1](record.id, 'table', tablename)
except TypeError:
href = '%s/%s/%s' % (linkto, tablename,
record.id)
r = A(lc[2], _href=href)
row.append(TD(r))


[web2py] encoding problem

2011-03-10 Thread Eduardo
Hi,

I modified the insert( ) function of appadmin.py from the example app
by passing a dict to the labels attribute of SQLFORM( ) - in other
words:

appadmin.py > insert( ) > SQLFORM(.. labels=dict)

The labels, with Portuguese characters, are not correctly encoded on
the final result. Note that both appadmin.py and layout.html are
declared as utf-8, and those two, together with appadmin.html, were
saved as utf-8.

Also note that a dict passed to SQLTABLE within appadmin.html is being
correctly displayed, which makes me confuse.

Any suggestions?

Eduardo


[web2py] Is a UNION query possible with DAL ?

2011-03-10 Thread Norbert Klamann
I look for something like

 select a,b,c from table1
union
select a,b,c from table2

I also tried to combine 2 distinct 'Rows' objects and dal.Sets (with the 
same structure) , but both don't support this operation.

Norbert


Re: [web2py] Re: [tip] Head JS script loader

2011-03-10 Thread Bruno Rocha
I dont know, I never used these other libs, I am using head.js and it seems
very good.

2011/3/9 Carlos 

> Hi Bruno,
>
> How does HeadJs compare with RequireJs and LabJs?.
>
> http://requirejs.org/
>
> http://labjs.com/
>
> Thanks,
>
>Carlos
>
>


[web2py] Re: Components and session: forbidden?

2011-03-10 Thread carlo
sorry my fault.

You can have:
session.mysession=total

you can not have:
session.mysession=tot1+tot2+tot3



On 10 Mar, 15:42, carlo  wrote:
> I tried to set a session in a component "post.load" and I receive a
> "RestrictedError" Ticket.
>
> Why you can not have a new session set in a component?
>
> Thank you
>
> carlo


[web2py] Re: plugin_wiki: KeyError: 'active'

2011-03-10 Thread Massimo Di Pierro
This was fixed yesterday night.

On Mar 9, 9:27 pm, Anthony  wrote:
> Yes, this error occurred during the PyCon tutorial this morning. Massimo
> used his Emacs foo to fix the problem on the spot in about 30 seconds and
> then proceeded with his example without skipping a beat. I think he's
> planning to push a fix out tonight or tomorrow.
>
> Anthony
>
>
>
>
>
>
>
> On Wednesday, March 9, 2011 9:03:29 PM UTC-5, villas wrote:
> > I have already posted several messages about this issue.  Plugin_wiki
> > is broken at the moment.  Massimo has deleted the 'active' field
> > (because 'active' is a reserved word).  He may eventually replace it
> > with another field named 'activated' or similar.
>
> > On Mar 10, 1:16 am, LotS  wrote:
> > > I use the source version of web2py: Version 1.93.2 (2011-03-04
> > > 23:48:59)
> > > on Windows XP.
>
> > > I managed to install plugin_wiki.
>
> > > After I signed in with an authenticated user id, the "Pages" on the
> > > menu will be shown.
> > > Click on it and I can access to the /plugin_wiki/index
>
> > > After I created a meta-menu page, and try to access  /plugin_wiki/
> > > index again.  I hit into an error as follow,
>
> > > 
> > > Traceback (most recent call last):
> > >   File "C:\web2py\gluon\restricted.py", line 188, in restricted
> > >     exec ccode in environment
> > >   File "C:\web2py\applications\myapp2/views\plugin_wiki/index.html",
> > > line 113, in 
> > >   File "C:\web2py\gluon\dal.py", line 3347, in __getattr__
> > >     return self[key]
> > >   File "C:\web2py\gluon\dal.py", line 3338, in __getitem__
> > >     return dict.__getitem__(self, key)
> > > KeyError: 'active'
> > > 
>
> > > But I still can point my browser directly to "http://127.0.0.1:8000/
> > > myapp2/plugin_wiki/page/meta-menu" and the rest of the pages works as
> > > normal.
>
> > > Hope someone can help.


[web2py] Problem with unicode data in mssql

2011-03-10 Thread Skiros
Hi everyone !

I have an application working correctly with version 1.87.3 of web2py
and SQL Server 2000. The database has a collation
Modern_Spanish_CI_AS.

My problems start when upgrade to version 1.93.2. In my code have
originally:

db = SQLDB('mssql2://User:Password@MyServer/MyDataBase', pool_size=10,
db_code="LATIN-1")

from gluon.tools import *
auth = Auth(globals(), db)
auth.define_tables(migrate = False)

db.define_table('Tareas'
, SQLField('Descripcion', 'string', length=200, required=True)
, migrate = False
)

The Auth tables was created with this setup. String values are
nvarchar datatype in table.

Whe I try to login obtain this error:

Traceback (most recent call last):
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\restricted.py", line 188, in restricted
exec ccode in environment
  File "C:/Documents and Settings/hansen/Escritorio/Web2Py/web2py
fuentes 1-93-2/applications/sgs/controllers/default.py", line 55, in

  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\globals.py", line 95, in 
self._caller = lambda f: f()
  File "C:/Documents and Settings/hansen/Escritorio/Web2Py/web2py
fuentes 1-93-2/applications/sgs/controllers/default.py", line 34, in
user
return dict(form=auth())
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\tools.py", line 1032, in __call__
return self.login()
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\tools.py", line 1447, in login
user = self.db(table_user[username] ==
form.vars[username]).select().first()
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\dal.py", line 4737, in select
return self.db._adapter.select(self.query,fields,attributes)
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\dal.py", line 1025, in select
rows = response(sql)
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\dal.py", line 1015, in response
self.execute(sql)
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\dal.py", line 1931, in execute
return self.log_execute(a,'utf8')
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\dal.py", line 1094, in log_execute
return self.cursor.execute(*a,**b)
ProgrammingError: ('The SQL contains 0 parameter markers, but 1
parameters were supplied', 'HY000')


I try changing the connection string to "mssql"

db = DAL('mssql://User:Password@MyServer/MyDataBase', pool_size=10,
db_code="LATIN-1")

and everything go fine until I discover errors updating nvarchar
fields. If read a record with the string "Cañería" and update with the
same, the result was something like "cañeria".

Put a print and the result was

UPDATE Tareas SET Descripcion='Instalar impresora ca+¦eria' WHERE
(Tareas.id = 1);

of course, no unicode modificator "N".

Ok, I know "mssql2" is needed with unicode strings, but if I use an
error appears, the same when all this thing start...

Traceback (most recent call last):
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\restricted.py", line 188, in restricted
exec ccode in environment
  File "C:/Documents and Settings/hansen/Escritorio/Web2Py/web2py
fuentes 1-93-2/applications/sgs/controllers/tareas.py", line 408, in

  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\globals.py", line 95, in 
self._caller = lambda f: f()
  File "C:/Documents and Settings/hansen/Escritorio/Web2Py/web2py
fuentes 1-93-2/applications/sgs/controllers/tareas.py", line 292, in
Consulta
return GenerarFormularioBusqueda("C")
  File "C:/Documents and Settings/hansen/Escritorio/Web2Py/web2py
fuentes 1-93-2/applications/sgs/controllers/tareas.py", line 84, in
GenerarFormularioBusqueda
Registros = db().select(db.TareasTipo.id,
db.TareasTipo.Descripcion, orderby=db.TareasTipo.Descripcion)
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\dal.py", line 4737, in select
return self.db._adapter.select(self.query,fields,attributes)
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\dal.py", line 1025, in select
rows = response(sql)
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\dal.py", line 1015, in response
self.execute(sql)
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\dal.py", line 1931, in execute
return self.log_execute(a,'utf8')
  File "C:\Documents and Settings\hansen\Escritorio\Web2Py\web2py
fuentes 1-93-2\gluon\dal.py", line 1094, in log_execute
return self.cursor.execute(*a,**b)
ProgrammingError: ('The SQL contains 0 parameter markers, but 1
parameters were supplied', 'HY000')


Try changing db_code property without any results.

Some i

[web2py] Re: about SQLFORM

2011-03-10 Thread DenesL

After an insert, form.vars.id will have the new record's id.

But to avoid another DB access you can make the changes before the
record is written using the onvalidation parameter in the accepts.

@auth.requires_login()
def new():
def set_name(form):
form.vars.name=author
return
form = SQLFORM(db.autos, fields=['num'],
   labels={'num':'Number'},
   submit_button='GO',
   formstyle='divs')
if form.accepts(request.vars, session,
onvalidation=set_name):
response.flash = 'Yoh-ho-ho!'
elif form.errors:
response.flash = 'Bad-bad-bad!'
else:
response.flash = 'Fill the form'
return dict(form=form)


On Mar 10, 5:56 am, cyber  wrote:
> The code in controller:
> @auth.requires_login()
> def new():
>     author=auth.user.username
>     form = SQLFORM(db.autos, fields=['num'], labels={'num':'Number'},
> submit_button='GO', formstyle='divs')
>     if form.accepts(request.vars, session):
>         response.flash = 'It's OK!'
>     elif form.errors:
>         response.flash = 'There is an error!'
>     else:
>         response.flash = 'Fill the form!'
>     rows=db(db.autos.id>0).select()
>     last_row=rows[-1]
>     last_row.update_record(name=author)
>     return dict(form=form)
>
> ***
> And the model piece of code is:
> import datetime
> now=datetime.datetime.today()
> db.define_table('autos',
>     Field('num', length=8),
>     Field('name'),
>     Field('dtime', 'datetime', default=now),
>     Field('enter', 'boolean', default=False),
>     Field('enter_d'),
>     Field('idk', 'boolean', default=False),
>     Field('idk_d'),
>     Field('svh', 'boolean', default=False),
>     Field('svh_d'),
>     Field('reg', 'boolean', default=False),
>     Field('reg_d'),
>     Field('out', 'boolean', default=False),
>     Field('out_d')
>     )
>
> *
> And view file is:
> {{extend 'layout.html'}}
> {{=form}}
>
> So, I want user to enter only value 'num' in db.autos.
> But user_name (for current user) and date_time info have to be updated
> automaticly after user presses "GO" button.
> Could you check my code? Is it correct?
>
> On 9 мар, 17:27, DenesL  wrote:
>
> > Can you show us your current code?.
>
> > On Mar 9, 9:03 am, cyber  wrote:
>
> > > Hi
>
> > > How can I update new (just created) record in the table?
> > > Table consists of several fields but in the form page user have to
> > > enter only one value for one row.
> > > So, I need insert in the current row not only this value but user name
> > > and datetime.
> > > I can insert first value but I have no idea of how to auto update new
> > > row with required values.
>
> > > Any ideas?
>
>


[web2py] Components and session: forbidden?

2011-03-10 Thread carlo
I tried to set a session in a component "post.load" and I receive a
"RestrictedError" Ticket.

Why you can not have a new session set in a component?

Thank you

carlo


[web2py] javascript/jquery advice

2011-03-10 Thread Johann Spies
I am starting to learn javascript and am thinking of using more jquery and
jquery UI  and ajax elements in my applications and would appreciate on how
to approach it:

1. Starting with javascript tutorials (e.g. from developer.mozilla.org)  and
move on to jquery tutorials and later on to how web2py uses them.
2. Starting with web2py-customised jquery elements (or do you call them
'components') and try to explore that further.

I have looked at some jquery-related slices and it seems that the way to
include jquery ui stuff in web2py is not that straight forward.  Some of the
slices' have outdated documentation.  The documentation for
http://web2pyslices.com/main/slices/take_slice/11 for example is no longer
used by the latest code one can download from a link on the slice.

Also: I have seen that for example jqgrid has a lot more capabilities that
is available in the plugin-wiki.  I would like to learn how to use for
example more complicated datasources with jqgrid and subtables when clicked
on a row of data linked to other tables.

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


[web2py] Re: Performing database inserts with FORM( )

2011-03-10 Thread Ross Peoples
Let's not forget about SQLFORM.factory either. This lets you create a 
SQLFORM based on a virtual table that you create as an argument to 
SQLFORM.factory. For example, I used this code to provide edit capabilities 
when editing time clock entries for an app I'm writing. It includes form 
validation, and I wrote a module that handles the actual db update. When you 
see "timeclock.edit_entry()", this is just handing off the form 
variables to the module, which performs extra validation on the data before 
committing it to the db. NOTE: All of this code is inside my "def edit():" 
function.

def validate_form(form):
users = [auth.user.id]
for user in user_security.get_subordinates(auth.user):
users.append(user.auth_user.id)

if int(form.vars.auth_user) not in users:
form.errors.adjusted_start = "You do not have permission to 
modify this person's time clock."

if not request.args(0): raise HTTP(400, 'Timeclock ID not found')
timeclock_id = request.args(0)
timeclock_entry = db(db.timeclock.id==timeclock_id).select().first()
if timeclock_entry is None: raise HTTP(400, 'Timeclock ID not found')

form = SQLFORM.factory(
Field('adjusted_start', 'datetime', requires=IS_NOT_EMPTY()),
Field('adjusted_end', 'datetime'),
Field('reason', 'text', requires=IS_NOT_EMPTY()),
Field('auth_user', db.auth_user, readable=False, writable=False),
hidden = {'id': timeclock_id, 'auth_user': 
timeclock_entry.auth_user.id}
)
form.vars.auth_user = timeclock_entry.auth_user.id
form.vars.adjusted_start = timeclock_entry.adjusted_start
form.vars.adjusted_end = timeclock_entry.adjusted_end
if form.accepts(request.vars, session, keepvalues=True, 
onvalidation=validate_form(form)):
row_id = timeclock.edit_entry(auth.user, timeclock_entry, 
form.vars.reason, form.vars.adjusted_start, form.vars.adjusted_end)
if isinstance(row_id, str):
response.flash = row_id
else:
redirect(URL('index'))

return dict(form=form, timeclock_entry=timeclock_entry, history=history)


[web2py] Re: Performing database inserts with FORM( )

2011-03-10 Thread Anthony
I assume it would be the same as when using SQLFORM.factory -- see an 
example in the book here: 
http://web2py.com/book/default/chapter/07#SQLFORM.factory

On Thursday, March 10, 2011 8:23:45 AM UTC-5, Eduardo wrote:

> Hello, 
>
> I understand database inserts with SQLFORM( ) and accepts( ) are 
> automatic when input is valid. However, I need more control over the 
> form fields and validation upon data entry, not on the model level. 
> Those are limited when using SQLFORM. 
>
> Can anyone point out a simple example of using FORM( ) and accepts( ) 
> to then insert the values on a database? 
>
> Thanks, 
>
> Eduardo



[web2py] Re: Performing database inserts with FORM( )

2011-03-10 Thread Eduardo
Thank you, DenesL; I know that. I don't see how that would help me. I
do need to insert the data on the DB.

Eduardo

On 10 mar, 11:11, DenesL  wrote:
> FYI you can turn off the automatic DB functions when using SQLFORM
> specifying dbio=False as a parameter in the form.accepts(...), see:
>
> http://web2py.com/book/default/chapter/07#SQLFORM-without-database-IO
>
> On Mar 10, 9:03 am, Eduardo  wrote:
>
> > I need to reorder fields and group then into  tags. Also,
> > because I'm dealing with a legacy database, I have to implement
> > validation on new entries only, not on db.py.
>
> > Please note I am just guessing FORM() and  accepts() would be the best
> > alternative. Feel free to suggest alternatives.
>
> > Thanks,
>
> > Eduardo
>
> > On 10 mar, 10:51, Kenneth Lundström 
> > wrote:
>
> > > Please explain what kind of control you need. It's much easier to help.
>
> > > Kenneth
>
> > > > Hello,
>
> > > > I understand database inserts with SQLFORM( ) and accepts( ) are
> > > > automatic when input is valid. However, I need more control over the
> > > > form fields and validation upon data entry, not on the model level.
> > > > Those are limited when using SQLFORM.
>
> > > > Can anyone point out a simple example of using FORM( ) and accepts( )
> > > > to then insert the values on a database?
>
> > > > Thanks,
>
> > > > Eduardo
>
>


[web2py] Re: Performing database inserts with FORM( )

2011-03-10 Thread DenesL

FYI you can turn off the automatic DB functions when using SQLFORM
specifying dbio=False as a parameter in the form.accepts(...), see:

http://web2py.com/book/default/chapter/07#SQLFORM-without-database-IO


On Mar 10, 9:03 am, Eduardo  wrote:
> I need to reorder fields and group then into  tags. Also,
> because I'm dealing with a legacy database, I have to implement
> validation on new entries only, not on db.py.
>
> Please note I am just guessing FORM() and  accepts() would be the best
> alternative. Feel free to suggest alternatives.
>
> Thanks,
>
> Eduardo
>
> On 10 mar, 10:51, Kenneth Lundström 
> wrote:
>
> > Please explain what kind of control you need. It's much easier to help.
>
> > Kenneth
>
> > > Hello,
>
> > > I understand database inserts with SQLFORM( ) and accepts( ) are
> > > automatic when input is valid. However, I need more control over the
> > > form fields and validation upon data entry, not on the model level.
> > > Those are limited when using SQLFORM.
>
> > > Can anyone point out a simple example of using FORM( ) and accepts( )
> > > to then insert the values on a database?
>
> > > Thanks,
>
> > > Eduardo
>
>


  1   2   >