[web2py] Multiple instances of same class

2016-01-21 Thread killzane
I write a class in modules, and create instance in controller. But whatever I create different variable, they point to same instance. May I create new instance when page reload? here is the class # -*- coding: utf-8 -*- from gluon import current class Project: __name = None def __init__(self, id

[web2py] Re: Multiple instances of same class

2016-02-25 Thread killzane
of the class. > > Anthony > > On Thursday, January 21, 2016 at 5:24:00 PM UTC-5, killzane wrote: >> >> I write a class in modules, and create instance in controller. >> But whatever I create different variable, they point to same instance. >> May I create new in

[web2py] SQLFORM.factory upload field can't show link

2016-02-25 Thread killzane
This is my code form = SQLFORM.factory(Field('list_name', 'string', label='List Name'), db. project, table_name='project',upload=URL('download')) And here is my db.py about upload field Field('project_pdf', 'upload', label='Project PDF', comment='', uploadfolder ='app/uploads'), When I use web2py

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-25 Thread killzane
a "create" form, to what > file would you expect such a link to point? > > Anthony > > On Thursday, February 25, 2016 at 4:19:10 AM UTC-5, killzane wrote: >> >> This is my code >> form = SQLFORM.factory(Field('list_name', 'string', label

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-25 Thread killzane
db(query).select(limitby=(0,1)).first(), form.vars, t.fields) and this is in view {{=form}} Anthony於 2016年2月26日星期五 UTC+8上午12時19分03秒寫道: > > Can you show the code you are using to edit an existing record via > SQLFORM.factory? > > On Thursday, February 25, 2016 at 10:50:12 AM UTC-5,

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-28 Thread killzane
Because I want to add other field to the form so I use SQLFORM.factory. And this is my __copydata method def __copydata(src, dest, fields): if src: for k in fields: if src.has_key(k): dest[k] = src[k] return dict() Anthony於 2016年2月26日星期五 UTC+8下午9時08分1

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-28 Thread killzane
ields) Anthony於 2016年2月28日星期日 UTC+8下午9時29分52秒寫道: > > Sorry, still not clear what you are trying to do, and you have not > explained why you are iterating over the Fields of the db.project table. > > On Sunday, February 28, 2016 at 3:48:26 AM UTC-5, killzane wrote: >> &g

[web2py] Re: SQLFORM.factory upload field can't show link

2016-02-28 Thread killzane
r? Anthony於 2016年2月29日星期一 UTC+8上午8時51分27秒寫道: > > The widget gets created when the form is initialized, so if you want to > specify a value for the file URL, you should do it by setting the "default" > attribute of the upload field in the db.project table *before* creating &

[web2py] Re: SQLFORM.factory upload field can't show link

2016-03-01 Thread killzane
.project.project_pdf.default = the_file_name > > Simply setting form.vars.project_pdf will not work. > > Anthony > > On Monday, February 29, 2016 at 2:32:55 AM UTC-5, killzane wrote: >> >> So if I have this field in db.project >> Field('project_pdf'

[web2py] Re: Why I can send mail use python but can't send by web2py mail object

2016-03-22 Thread killzane
Monday, August 31, 2015 at 9:00:45 PM UTC-4, killzane wrote: >> >> As title. >> I can send mail via this example. >> 18.1.11. email: Examples >> <https://docs.python.org/2/library/email-examples.html> >> >> But when I use web2py framework and follow t

[web2py] Re: Why I can send mail use python but can't send by web2py mail object

2016-03-22 Thread killzane
Here is my stand alone code named "testMail.py" # Import smtplib for the actual sending function import smtplib # Import the email modules we'll need from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart me = 'no-reply@mydomain' you = 'reciver mail address' msg = MI

[web2py] Re: Why I can send mail use python but can't send by web2py mail object

2016-03-23 Thread killzane
Hi I test your suggestion. and mail.error shows __init__() got an unexpected keyword argument 'source_address' here is the code smtp_args = self.settings.server.split(':') kwargs = dict(timeout=self.settings.timeout) if self.settings.ssl: serve

[web2py] Re: Why I can send mail use python but can't send by web2py mail object

2016-03-23 Thread killzane
My python is 2.7.9 I tried to disable IPv6, then postfix won't auto start when I reboot my server. and use *#postfix start *will return this warning postfix/postfix-script: warning: /var/spool/postfix/etc/resolv.conf and /etc/resolv.conf differ postfix/postfix-script: starting the Postfix mail sy

[web2py] rediect after login when use decorators "@auth.requires_login"

2016-03-30 Thread killzane
I use *@auth.requires_login()* in my controller and when I visit that page, I will auto go to login page and have the "_next URL parameter" I want to use auth.settings.login_next = URL('default', 'router') according to this page

[web2py] Re: rediect after login when use decorators "@auth.requires_login"

2016-03-30 Thread killzane
.login_next *to redirect location. so how to let web2py *don't *auto add _next variable by use @auth.required_login()? Anthony於 2016年3月30日星期三 UTC+8下午8時54分30秒寫道: > > On Wednesday, March 30, 2016 at 4:06:41 AM UTC-4, killzane wrote: >> >> I use *@auth.requires_login()* in my

[web2py] how to change facebook oauth2 redirect_uri

2016-04-10 Thread killzane
I followed the web2py book http://web2py.com/books/default/chapter/29/09/access-control#Other-login-methods-and-login-forms and put the example code in my model and I use this in my controllers named *default.py* def fbLogin(): auth.settings.login_form=FaceBookAccount() form = auth() return di

Re: [web2py] how to change facebook oauth2 redirect_uri

2016-04-10 Thread killzane
tandard settings of > auth. > > > http://www.web2py.com/books/default/chapter/29/09/access-control#Auth-Settings-and-messages > > You do not need ajax, just a window.open() or a target="_blank"> or an iframe > > > > 2016-04-10 9:38 GMT+02:00 killzane &g

Re: [web2py] how to change facebook oauth2 redirect_uri

2016-04-11 Thread killzane
(c='mycontroller', f='my_login_action', > args=['login']) > > in mycontroller.py: > > def my_login_action(): > """same as default/login action""" > return dict(form=auth()) > > > @auth.requires_login(): > def f(): &

[web2py] SSL Error: bad handshake when use requests lib

2017-12-19 Thread killzane
Hi I want to use Requests lib in web2py to run facebook's Graph API. So I need to use requests.get or requests.post. The problem is, when I run requests.get in python, it's work. but when I run in web2py, it gave me an error HTTPSConnectionPool(host='graph.facebook.com', port=443): Max retries

[web2py] Re: SSL Error: bad handshake when use requests lib

2017-12-21 Thread killzane
h their webserver config or their certificates. > > Could you tell us what version of OpenSSL is used both circumstances? > terminal> openssl version and Python> print ssl.OPENSSL_VERSION > > On Wednesday, 20 December 2017 07:58:32 UTC, killzane wrote: >> >> Hi

[web2py] Re: SSL Error: bad handshake when use requests lib

2017-12-22 Thread killzane
ken so I can't try it out - perhaps there > is someone else who uses the Facebook Graph API? > > On Thursday, 21 December 2017 10:11:10 UTC, killzane wrote: >> >> 1. unubtu terminal >> OpenSSL 1.0.2g 1 Mar 2016 >> >> 2. python >> >>> impo

[web2py] use logging lib in web2py to log to database

2017-12-23 Thread killzane
as title I want to save my log into my database this is my code in model folder import logging, logging.handlers import json from DBSession import DBSession class DatabaseHandler(logging.Handler): def emit(self, record): log_entry = self.format(record) log_data = json.load

[web2py] Why I can send mail use python but can't send by web2py mail object

2015-08-31 Thread killzane
As title. I can send mail via this example. 18.1.11. email: Examples But when I use web2py framework and follow this guide Email and SMS

[web2py] Re: Facebook OAuth - newbie question

2015-08-31 Thread killzane
Hi, I follow the book and create a facebook.py in model folder. but when I called in my controller form = auth() return dict(view=view, form=form) I will receive this error from facebook { "error": { "message": "Invalid redirect_uri: \u61c9\u7528\u7a0b\u5f0f\u7684\u8a2d\u5b9a\u4e0d\u63a