Re: [web2py] Limit Related Field Dropdown List

2010-11-21 Thread Bernardo Botella Corbí
Hi Joe,

I don't know if I understood well. I think that you are trying to do a drop
list, putting in it the pet_type belonging to an owner?

In that case, in this thread:
http://groups.google.com/group/web2py/browse_thread/thread/3f2ea9bcd3a2e104/226561a9a21dc588?lnk=gst&q=drop+list#226561a9a21dc588

This need is discussed. I did something similar, and I used the code found
here:
http://www.web2pyslices.com/main/slices/take_slice/85

(thanks mr.freeze!!)

kind regards,
Bernardo

2010/11/21 Joe J 

> Hi All,
>  Say I have a pet table and an owner table related to each other in a
> one to many relationship (one owner has many pets).   Each owner can
> also define several pet types of their choosing.
>
> db.create_table('owner',
>Field('name', text))
> db.create_table('pet_type',
>Field('type_name','text'),
>Field('type_owner',db.owner))
> db.create_table('pet',
>Field('pet_name', 'text'),
>Field('pet_type'), db.pet_type),
>Field('pet_owner'), db.pet_owner))
>
> How do I create a model validator so that, when adding or editing a
> pet associated with a particular owner, only pet_types "belonging" to
> that owner show up in the form dropdown?  (Owners can define their own
> custom pet_types).
>
> This rule displays ALL defined pet_types in the pet_type table, and
> not simply the ones owned by a given owner.
> db.pet.pet_type.requires = IS_IN_DB(db, 'pet_type.id', '%
> (type_name)s')
>
> Any help is much appreciated.
> Joe


Re: [web2py] Re: Problems with mail.send()

2010-12-01 Thread Bernardo Botella Corbí
It prints

False

Bernardo

2010/12/1 mdipierro 

> try from the shell
>
> python web2py.py -A yourapp -N -M
>
> print mail.send(to="@...", message="", subject="...")
>
> Massimo
>
> On Dec 1, 11:55 am, Bernardo  wrote:
> > Hi Massimo,
> >
> > thanks for your reply. I connected without problems using telnet on
> > port 25
> >
> > >telnet mydomain.com 25
> >
> > Connected to mydomain.com.
> > Escape character is '^]'.
> > 220 mydomain.com ESMTP Postfix (Ubuntu)
> > EHLO mydomain.com
> > 250-mydomain.com
> > 250-PIPELINING
> > 250-SIZE 1024
> > 250-ETRN
> > 250-STARTTLS
> > 250-AUTH CRAM-MD5 DIGEST-MD5 LOGIN PLAIN
> > 250-ENHANCEDSTATUSCODES
> > 250-8BITMIME
> > 250 DSN
> >
> > on the other hand, the username is the same I use to send an email
> > from thunderbird.
> >
> > kind regards,
> > Bernardo
> >
> > On 1 dic, 16:49, mdipierro  wrote:
> >
> > > try telnet mail.mydomain.com 25 and see if it is accepting remote
> > > connections (by defau postfix does not).
> >
> > > Also I think
> >
> > > mail.settings.login = 'berna...@mydomain.com:mypass'
> >
> > > should be
> >
> > > mail.settings.login = 'berna...:mypass'
> >
> > > On Dec 1, 5:44 am, Bernardo  wrote:
> >
> > > > Dear all,
> >
> > > > I don't know if it is exactly a web2py issue or not. The fact is that
> > > > I have a remote mail server, listening in port 25. It uses a self
> > > > created certificate to allow connections from the outside (i.e. for
> > > > thunderbird, you must accept that certificate in order to send
> mails).
> > > > The problem is that when I try to send an email:
> >
> > > > mail.send(to='estem...@gmail.com',subject='Hello world
> > > > subject',message='Hello world text')
> >
> > > > but nothing happens. Not a single messange printed on python console.
> > > > And nothing shown in postfix log
> >
> > > > The lines in db.py are:
> > > > mail.settings.server = 'mail.mydomain.com:25'
> > > > mail.settings.sender = 'berna...@mydomain.com' # your email
> > > > mail.settings.login = 'berna...@mydomain.com:mypass'  # your
> > > > credentials or None
> > > > mail.settings.cipher_type = 'x509'
> > > > mail.settings.x509_sign_keyfile = 'url_to_postfix.key'
> > > > mail.settings.x509_sign_certfile = 'url_to_postfix.cert'
> >
> > > > Does anyone can figure out what is wrong with all of this?
> >
> > > > thanks a lot for your time,
> > > > Bernardo
> >
> >
>


Re: [web2py] Re: minimal setup on Debian for using Mail()

2010-12-04 Thread Bernardo Botella Corbí
Hi Miguel,

which test did you do from command line?
does web2py print something? Any error?

Try to do the next thing from the command line:
tail -f /var/log/mail.log

(if you are in ubuntu/debian, don't know where it would be in other
distributions...)

and see if it complaints about anything when trying to send a mail from
web2py.

Bernardo

2010/12/4 Miguel Lopes 

>
>
> On Sat, Dec 4, 2010 at 1:12 AM, mdipierro  wrote:
>
>> did you apt-get install portfix?
>>
>> Do you mean postfix? No I didn't.
>
> By the way, tp be precise in the config I'm using:
> mail.settings.server = 'myIPaddress:25'  # your
> SMTPserver
>
> since sendmail uses port 25 by default.
> Miguel
>
>
>
>>
>> On Dec 3, 6:36 pm, Miguel Lopes  wrote:
>> > I'm having problems trying to make gluon.tools.Mail work on a vps, and
>> > wonder if anyone knows what would be a minimal setup for sending mail.
>> > I just need to send the an occasional mail. The server as sendmail
>> working,
>> > which I've confirmed in the command line. However, I'm unable to make it
>> > work via web2py.
>> > My model file reads:
>> >
>> > mail.settings.server = 'localhost'  # your
>> SMTP
>> > server
>> > mail.settings.sender = 'r...@mydomain.pt' # your email
>> > #mail.settings.login = ''#
>> your
>> > credentials or None 'username:password'
>> >
>> > I confess being a complete n00b regarding linux admin.
>> > Is sendmail enough? What could I be missing?
>> > Miguel
>>
>
>


Re: [web2py] Re: minimal setup on Debian for using Mail()

2010-12-05 Thread Bernardo Botella Corbí
Hi,

did you try to send a mail from telnet?

telnet localhost 25 (this connects to your smtp server)
EHLO mail.example.com

MAIL FROM: 

RCPT TO: 

data
# enter message bodyand end with a line with only a full stop.
blah blah blah
more blah
.

with this lines you should be able to send a mail from telnet. Does that
work?

Bernardo


2010/12/4 Miguel Lopes 

> Hi Bernado,
>
> 2010/12/4 Bernardo Botella Corbí 
>
> Hi Miguel,
>>
>> which test did you do from command line?
>> does web2py print something? Any error?
>>
>> Try to do the next thing from the command line:
>> tail -f /var/log/mail.log
>>
>
> If I try to send mail from web2py using local resources it fails silently.
> I can use a gmail account to send the email it works, so perhaps I'm
> configuring gluon.tools.Mail wrongly:
> mail.settings.server = 'myIP:25'# your SMTP
> server
> mail.settings.sender = 'u...@mydomain.pt' # your email
> mail.settings.login = 'user:pass'   # your
> credentials or None 'username:password'
>
> I'm unsure about mails.settings.server. Is this correct?
>
>
>> (if you are in ubuntu/debian, don't know where it would be in other
>> distributions...)
>>
>> I'm using Debian Lenny.
>
> txs,
> Miguel
>
>


Re: [web2py] Re: Problem with DAL and Postgres

2011-02-06 Thread Bernardo Botella Corbí
Yes, the error is on my custom auth_user table. So, Do I reduce the leght
numbers?

Bernardo

2011/2/6 Massimo Di Pierro 

> Do you have a custom auth_user table? Is seems to miss a length
> attribute and default to a number too large. I changed the default to
> 32768 in trunk but I am not sure.
>
> On Feb 6, 3:13 pm, Bernardo  wrote:
> > Dear all,
> >
> > I am using web2py 1.91.6 and last version of Ubuntu. A model which
> > works perfectly using sqlite database, throws an error when using a
> > postgres database:
> >
> > ProgrammingError: syntax error at or near "100"
> > LINE 1: ALTER TABLE auth_user ADD password VARCHAR(100);
> >
> > posible bug in new DAL?
> >
> > Thanks a lot for your help,
> > Bernardo
>


Re: [web2py] Re: Problem with DAL and Postgres

2011-02-07 Thread Bernardo Botella Corbí
Dear Massimo,

I've been busy today. I'll post it as soon as possible.

thanks for your help,
Bernardo

2011/2/7 Massimo Di Pierro 

> I am very puzzled.
>
> In gluon/dal.py there is this line:
>
> field.length = min(field.length,self._db and
> self._db._adapter.maxcharlength or INFINITY)
>
> can you print field.length before and field.length after this
> statement?
>
> Massimo
>
> On Feb 7, 3:06 am, Bernardo  wrote:
> > Sure Massimo, here it goes:
> >
> > db.define_table(auth.settings.table_user_name,
> > Field('first_name', length=128, default=''),
> > Field('last_name', length=128, default=''),
> > Field('username', length=128, default=''),
> > Field('email', length=128, default='', unique=True),
> > Field('password', 'password', '''length=512, ''', readable=False,
> > label='Password'),
> > Field('registration_key', length=512, writable=False,
> > readable=False, default=''),
> > Field('reset_password_key', length=512, writable=False,
> > readable=False, default=''),
> > Field('registration_id', length=512, writable=False,
> > readable=False, default=''),
> > Field('imagen', 'upload', requires=IS_IMAGE()),
> > Field('texto_descriptivo', 'text'),
> > Field('activado', 'boolean', default=True, readable=False,
> > writable=False),
> > Field('karma', 'double', default=0, readable=False,
> > writable=False),
> > Field('acepta_registro', 'boolean', requires=IS_IN_SET(['on'],
> > error_message=T('You must accept the license terms.')), label=XML(T('I
> > \'ve read and I accept the ') + A(T('license terms'),
> > _href=URL('default', 'texto_registro'), _target='new')))
> > )
> >
> > On 7 feb, 05:09, Massimo Di Pierro  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Can you show your custom auth_user. I am still puzzled by the error.
> >
> > > On Feb 6, 4:21 pm, Bernardo Botella Corbí  wrote:
> >
> > > > Yes, the error is on my custom auth_user table. So, Do I reduce the
> leght
> > > > numbers?
> >
> > > > Bernardo
> >
> > > > 2011/2/6 Massimo Di Pierro 
> >
> > > > > Do you have a custom auth_user table? Is seems to miss a length
> > > > > attribute and default to a number too large. I changed the default
> to
> > > > > 32768 in trunk but I am not sure.
> >
> > > > > On Feb 6, 3:13 pm, Bernardo  wrote:
> > > > > > Dear all,
> >
> > > > > > I am using web2py 1.91.6 and last version of Ubuntu. A model
> which
> > > > > > works perfectly using sqlite database, throws an error when using
> a
> > > > > > postgres database:
> >
> > > > > > ProgrammingError: syntax error at or near "100"
> > > > > > LINE 1: ALTER TABLE auth_user ADD password VARCHAR(100);
> >
> > > > > > posible bug in new DAL?
> >
> > > > > > Thanks a lot for your help,
> > > > > > Bernardo
>


Re: [web2py] Re: Upload file default

2011-02-08 Thread Bernardo Botella Corbí
Hi Massimo,

I'm trying it, but maybe I am doing something wrong.

in the model I have this:
Field('imagen', 'upload',
default='auth_user.imagen.a9ea07ced8e92070.56657370615f4c58565f323030375f31315f31303234783736382e6a7067.jpg'),

being that jpg file an upload file inside the upload folder. If I leave the
upload field blank at the form, in database imagen appears with None value.
Am I doing anything wrong?

thanks a lot,
Bernardo

2011/2/7 Massimo Di Pierro 

> If you have an uploaded file (with name given by web2py) you can set
> default='' its filename without path.
> Did you try it?
>
> On Feb 7, 1:40 pm, Bernardo  wrote:
> > Dear all,
> >
> > is there a way to use a default file in an upload field? Something
> > like:
> >
> > Field('whatever', 'upload', 'default=...')
> >
> > Which one is the best way to do this?
> >
> > thanks a lot for your help,
> > Bernardo
>


Re: [web2py] Re: Problem with DAL and Postgres

2011-02-08 Thread Bernardo Botella Corbí
Hi Massimo,

tested like that, and still the same error.

Bernardo

2011/2/8 Massimo Di Pierro 

> Your problem is that this:
>
> Field('password', 'password', '''length=512, ''', readable=False,
> label='Password'),
>
> should be
>
> Field('password', 'password', length=512, readable=False,
> label='Password'),
>
>
>
> On Feb 8, 2:36 am, Bernardo Botella Corbí  wrote:
> > Hi Massimo,
> >
> > please find attached the output you asked for. I must say that it works
> > using mysql.
> >
> > regards,
> > Bernardo
> >
> > 2011/2/7 Massimo Di Pierro 
> >
> >
> >
> >
> >
> >
> >
> > > I am very puzzled.
> >
> > > In gluon/dal.py there is this line:
> >
> > > field.length = min(field.length,self._db and
> > > self._db._adapter.maxcharlength or INFINITY)
> >
> > > can you print field.length before and field.length after this
> > > statement?
> >
> > > Massimo
> >
> > > On Feb 7, 3:06 am, Bernardo  wrote:
> > > > Sure Massimo, here it goes:
> >
> > > > db.define_table(auth.settings.table_user_name,
> > > > Field('first_name', length=128, default=''),
> > > > Field('last_name', length=128, default=''),
> > > > Field('username', length=128, default=''),
> > > > Field('email', length=128, default='', unique=True),
> > > > Field('password', 'password', '''length=512, ''', readable=False,
> > > > label='Password'),
> > > > Field('registration_key', length=512, writable=False,
> > > > readable=False, default=''),
> > > > Field('reset_password_key', length=512, writable=False,
> > > > readable=False, default=''),
> > > > Field('registration_id', length=512, writable=False,
> > > > readable=False, default=''),
> > > > Field('imagen', 'upload', requires=IS_IMAGE()),
> > > > Field('texto_descriptivo', 'text'),
> > > > Field('activado', 'boolean', default=True, readable=False,
> > > > writable=False),
> > > > Field('karma', 'double', default=0, readable=False,
> > > > writable=False),
> > > > Field('acepta_registro', 'boolean', requires=IS_IN_SET(['on'],
> > > > error_message=T('You must accept the license terms.')),
> label=XML(T('I
> > > > \'ve read and I accept the ') + A(T('license terms'),
> > > > _href=URL('default', 'texto_registro'), _target='new')))
> > > > )
> >
> > > > On 7 feb, 05:09, Massimo Di Pierro 
> wrote:
> >
> > > > > Can you show your custom auth_user. I am still puzzled by the
> error.
> >
> > > > > On Feb 6, 4:21 pm, Bernardo Botella Corbí 
> wrote:
> >
> > > > > > Yes, the error is on my custom auth_user table. So, Do I reduce
> the
> > > leght
> > > > > > numbers?
> >
> > > > > > Bernardo
> >
> > > > > > 2011/2/6 Massimo Di Pierro 
> >
> > > > > > > Do you have a custom auth_user table? Is seems to miss a length
> > > > > > > attribute and default to a number too large. I changed the
> default
> > > to
> > > > > > > 32768 in trunk but I am not sure.
> >
> > > > > > > On Feb 6, 3:13 pm, Bernardo  wrote:
> > > > > > > > Dear all,
> >
> > > > > > > > I am using web2py 1.91.6 and last version of Ubuntu. A model
> > > which
> > > > > > > > works perfectly using sqlite database, throws an error when
> using
> > > a
> > > > > > > > postgres database:
> >
> > > > > > > > ProgrammingError: syntax error at or near "100"
> > > > > > > > LINE 1: ALTER TABLE auth_user ADD password
> VARCHAR(100);
> >
> > > > > > > > posible bug in new DAL?
> >
> > > > > > > > Thanks a lot for your help,
> > > > > > > > Bernardo
> >
> >
> >
> >  output.txt
> > 66KViewDownload


Re: [web2py] Re: 1.93.2 broken update_record!

2011-03-08 Thread Bernardo Botella Corbí
Hi Clayton,

How did you fix it?

Thanks for your help,
Bernardo

2011/3/7 Clayton 

> Issue 210:  Typo in gluon.dal.update_record
>
> Patched it manually to get my app up and running.
>
> This breaks a lot of apps; how soon can a new release get out?
>
> Clayton
>
> On Mar 7, 4:11 pm, Clayton  wrote:
> > sess.update_record(lockedby=request.vars.client) used to set the field
> > "lockedby" in the database to the value of request.vars.client
> >
> > As of 1.93.2, it sets the field "lockedby" to the value
> > "lockedby" (the string!). This is with sqlite.
> >
> > Crashes my app. Was I using it wrong to begin with?
> >
> > Clayton
>


Re: [web2py] Re: 1.93.2 broken update_record!

2011-03-08 Thread Bernardo Botella Corbí
Ok,

On line 4776 should appear the following:

colset[k] = v

kind regards,
Bernardo

2011/3/8 Bernardo Botella Corbí 

> Hi Clayton,
>
> How did you fix it?
>
> Thanks for your help,
> Bernardo
>
> 2011/3/7 Clayton 
>
> Issue 210:  Typo in gluon.dal.update_record
>>
>> Patched it manually to get my app up and running.
>>
>> This breaks a lot of apps; how soon can a new release get out?
>>
>> Clayton
>>
>> On Mar 7, 4:11 pm, Clayton  wrote:
>> > sess.update_record(lockedby=request.vars.client) used to set the field
>> > "lockedby" in the database to the value of request.vars.client
>> >
>> > As of 1.93.2, it sets the field "lockedby" to the value
>> > "lockedby" (the string!). This is with sqlite.
>> >
>> > Crashes my app. Was I using it wrong to begin with?
>> >
>> > Clayton
>>
>
>