Thanks, the variable thing works now. Also, if the server is 'logging',
will the email be sent? Sorry, I have never used this before.
Thanks for the help
-Joe peacock
On Wednesday, July 25, 2012 2:42:42 PM UTC-5, Niphlod wrote:
>
> mail.settings.server needs to be ('logging' for debugging purposes or) an
> ip(:port) where a mail daemon is listening, not the http address of a
> web2py instance......
>
> And again (this rises up quite a bit): DAL is not an ORM. DAL is a
> Database Abstraction Layer, not an Object Relational Mapper.
> With this statement I mean "your modifications to objects doesn't get
> automatically propagated to the database"
>
> db(something).select() return a Rows() object.
>
> This is a list of dictionaries accessible both as
> db['tablename']['field'] AND by db.tablename.field.
>
> When you change a value in this dict, you changed it ONLY in the object
> itself. This doesn't save the results in the db automatically.
>
> This is why you end up having "notified" always false on the next select.
>
> If you want to do that you have to call it like this:
>
> row.update_record(notified=True).
>
> Actually, I'd put it AFTER the mail is sent, so you update the notified
> field only in the case the email is actually sent (queued to the mail
> daemon)
>
>
>
> On Wednesday, July 25, 2012 9:29:57 PM UTC+2, joe wrote:
>>
>> Hello
>>
>> Two problems. First, I have no experience whatsoever with the mail
>> system, but I need to use it for a request/notification system. (when the
>> status of a run changes to what a user wanted it to change to, the user
>> gets an email). The email is not being sent. I set up email like this:
>>
>> from gluon.tools import Mail
>> mail = Mail()
>> mail.settings.server = 'http://127.0.0.1:8000'
>> mail.settings.sender = '[email protected]'
>>
>> Then I call this method in my index function, which is being accessed
>> every time a run is updated, to check for updates, and wee if they match:
>>
>> def check_reqnot():
>> for row in db().select(db.request_notification.ALL):
>> if not row.notified:
>> if row.notify_when == db.run[row.run].status:
>> row.notified = True
>> mail.send('[email protected]',
>> 'WOW!',
>> 'It Worked! (HOLY CRAP)')
>> response.flash = 'It should have worked'
>>
>> It should be working, because when the status matches the request, I see
>> the flash response, but the email is not sent (yes, I checked my junk mail
>> folder).
>>
>> The other odd thing is that notified stays false.
>>
>> For reference here is the request_notification table:
>>
>> db.define_table('request_notification',
>> Field <http://127.0.0.1:8000/examples/global/vars/Field>('run', db.run,
>> requires = IS_NOT_EMPTY
>> <http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY>()),
>> Field <http://127.0.0.1:8000/examples/global/vars/Field>('notify_when',
>> requires = IS_IN_SET
>> <http://127.0.0.1:8000/examples/global/vars/IS_IN_SET>(['Requested', 'In
>> Proccess', 'Completed'])),
>> Field <http://127.0.0.1:8000/examples/global/vars/Field>('notified',
>> 'boolean', default = False, readable = False),
>> Field
>> <http://127.0.0.1:8000/examples/global/vars/Field>('user_signature',
>> db.auth_user, compute = lambda row: auth.user_id))
>>
>>
>> And the relevant field form the run table:
>>
>> Field <http://127.0.0.1:8000/examples/global/vars/Field>('status', requires
>> = IS_EMPTY_OR
>> <http://127.0.0.1:8000/examples/global/vars/IS_EMPTY_OR>(IS_IN_SET
>> <http://127.0.0.1:8000/examples/global/vars/IS_IN_SET>(['Requested', 'In
>> Proccess', 'Completed']))),
>>
>>
--