If I want to add other forms which interface with the DB, do I edit the fastform.py file?

139 views
Skip to first unread message

c.cs...@gmail.com

unread,
Dec 26, 2015, 3:59:06 PM12/26/15
to TurboGears
Hey guys I am trying to make a create new user account page, and I have made the form, but now to connect it to the database am I supposed to edit the fastform.py file?

Thanks

Alessandro Molina

unread,
Dec 27, 2015, 11:03:29 AM12/27/15
to turbo...@googlegroups.com

Uh, no the fastform.py is something internal and you should not need to change it. It's not clear to me what you are trying to achieve, can you provide more details?


Il giorno sab 26 dic 2015 21:59  <c.cs...@gmail.com> ha scritto:
Hey guys I am trying to make a create new user account page, and I have made the form, but now to connect it to the database am I supposed to edit the fastform.py file?

Thanks

--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+...@googlegroups.com.
To post to this group, send email to turbo...@googlegroups.com.
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

c.cs...@gmail.com

unread,
Dec 30, 2015, 12:08:58 AM12/30/15
to TurboGears
Hi, First thanks for your reply. I am trying to make a web form where a user can create a new user account. And so I noticed that the default login form is redirected to the fastform.py file by a /login_handler. So i though that if I wanted to create a ‘createaccount_handler’ then I would need to edit this fastform.py file..?

Thanks.

c.cs...@gmail.com

unread,
Dec 30, 2015, 1:52:10 AM12/30/15
to TurboGears
But I think I have it figured out now... If I should not edit the fastform.py file then perhaps I should just add a file to the model directory in the tg2 base folder. Called createuser.py...

Alessandro Molina

unread,
Dec 30, 2015, 6:27:38 AM12/30/15
to TurboGears
Uhm, if I understood your question correctly you just want to provide a registration form, correct?
In that case you might want to try tgapp-registration ( https://pypi.python.org/pypi/tgapp-registration ) which provides registration out of the box for you.

In case that's not what you need, it should be fairly easy to just provide a "createaccount_handler" method to your RootController and make a form that submits there.
You just need to set the "action" of your form to /createaccount_handler and it will receive all the form data. Then you can create the user like any other model model.User(user_name="foo", email_address="b...@host.net") and just log it in with http://turbogears.readthedocs.org/en/latest/reference/classes.html#tg.controllers.util.auth_force_login


c.cs...@gmail.com

unread,
Jan 8, 2016, 6:57:36 AM1/8/16
to TurboGears
Hi, Cool, thank you. I am using tgapp-registration, I see you are the author of it, that is cool :)

Hey I am wondering if you can help me with a new question regarding the tgapp-registration... You see I get this error when I try to register a new user:

KeyError: ‘registration.email_sender'

Now I put:

registration.email_sender = turbomail

into my development.ini file but it is most likely wrong... How do I setup this properly? The registration.email_sender part..?

Thanks

Alessandro Molina

unread,
Jan 8, 2016, 9:16:57 AM1/8/16
to TurboGears
registration.email_sender is actually the email address sending the outgoing emails, something like no-r...@mydomain.com

Regarding the email delivery, if tgext.mailer is enabled and configured that is used, if tgext.mailer is not available then turbomail is checked.
If neither of those is available and configured, then python smtplib is used (which can be configured through the registration.smtp_host / registration.smtp_login and registration.smtp_passwd options).

So to have outgoing emails working make sure you have tgext.mailer configured or that you have specified the three options for smtplib delivery

c.cs...@gmail.com

unread,
Jan 8, 2016, 11:39:39 AM1/8/16
to TurboGears
Thank you Alessandro.

Alessandro Molina

unread,
Jan 8, 2016, 3:12:06 PM1/8/16
to TurboGears
Thank you for pointing out that it wasn't clear, I just made a commit to better explain the option ( https://bitbucket.org/axant/tgapp-registration/commits/2c649045529fd5846069cb8ea190061785279afa )

c.cs...@gmail.com

unread,
Jan 13, 2016, 5:10:26 AM1/13/16
to TurboGears
Hi again, Hey I am having some issue with mine... I am trying to use tgext.mailer and I have it installed and plugged and etc in my app_cfg.py and I have this listed in my development.ini file: 

"
registration.email_sender = mailer@localhost

mail.host = localhost
mail.port = 25
mail.username = username
mail.password = password
mail.tls = false
mail.ssl = false

But I keep on getting this error once I have filled out the registration form: "KeyError: ‘registration.email_sender'"

Can you please help me with this... I do not understand what I am doing wrong...

Alessandro Molina

unread,
Jan 13, 2016, 5:30:32 AM1/13/16
to TurboGears
Where did you put the options?
Make sure the options are inside the [app:main] section, otherwise you might end up providing the options to the server or logging or even other sections :D

Bests,
Alessandro

c.cs...@gmail.com

unread,
Jan 15, 2016, 12:16:45 AM1/15/16
to TurboGears
Hmm, I have the above options in my applications main section, the same directory where my controllers and public and templates and etc folders are... But it does not seem to be working... I keep getting the error: KeyError: ‘registration.email_sender'

I put the options into a file called config.ini in a file in that location... This is correct right? And it should work? :S

Alessandro Molina

unread,
Jan 15, 2016, 1:53:12 AM1/15/16
to TurboGears
On Fri, Jan 15, 2016 at 6:16 AM, <c.cs...@gmail.com> wrote:

I put the options into a file called config.ini in a file in that location... This is correct right? And it should work? :S

Uhm, when the project is quickstarted the file is named "development.ini" you should find it already created inside the project directory. 

c.cs...@gmail.com

unread,
Jan 15, 2016, 8:57:33 AM1/15/16
to TurboGears
Hmm, No I still continue to get that same error message which I mentioned above. I moved all of the configuration into my ‘development.ini’ now and reconfigured my mail server and it is definitely working now, but same error...

This is what I have in my ‘development.ini’: registration.email_sender = ro...@localhost.flowerp.com

Any ideas? :S :/

c.cs...@gmail.com

unread,
Jan 15, 2016, 9:10:11 AM1/15/16
to TurboGears
Ie. I still get this error: "KeyError: ‘registration.email_sender”...

c.cs...@gmail.com

unread,
Jan 15, 2016, 10:47:42 AM1/15/16
to TurboGears
Is there anything more that I need to do with the ‘registration.email_sender’? anywhere else I need to set something up? Or how about regarding this https://github.com/amol-/tgext.mailer , about one third of the way down the page... Where it says 'Sending Emails’, do I need to put that anywhere? Or has that been done already?

Thank you

Alessandro Molina

unread,
Jan 15, 2016, 1:10:33 PM1/15/16
to TurboGears
I'll take code from a real project, see if anything is missing

in app_cfg.py (at the end of file):

from tgext.pluggable import plug
plug(base_config, 'tgext.mailer')
plug(base_config, 'registration')

in development.ini (in [app:main]):

# tgext.mailer data:
mail.username = **USER**
mail.password = **PASS**
mail.port = 587

# tgapp-registration
registration.email_sender = no-r...@mydomain.it

In case you are still unable to resolve it, if I can clone project code from somewhere I'll gladly check it to see what's wrong.


On Fri, Jan 15, 2016 at 4:47 PM, <c.cs...@gmail.com> wrote:
Is there anything more that I need to do with the ‘registration.email_sender’? anywhere else I need to set something up? Or how about regarding this https://github.com/amol-/tgext.mailer , about one third of the way down the page... Where it says 'Sending Emails’, do I need to put that anywhere? Or has that been done already?

Thank you

--

c.cs...@gmail.com

unread,
Jan 15, 2016, 9:27:02 PM1/15/16
to TurboGears
Hi, I still cannot get it to work, and I have no idea why... If I was to upload my project directory to DropBox, you wouldn’t mind checking it for me please? To see if you are able to make sense of what is wrong with it?

Let me know and I will upload an archive of the project content...

Thanks

Chris

c.cs...@gmail.com

unread,
Jan 19, 2016, 4:39:45 AM1/19/16
to TurboGears
Hi Allesandro, are you still able to help me with this please? I could really use your help if it isn’t too much of a bother...

Let me know and I will upload an archive of my project directory from where you can unzip and view my files...

Thank you

Regards,
Chris


On Sunday, 27 December 2015 07:59:06 UTC+11, c.cs...@gmail.com wrote:

Alessandro Molina

unread,
Jan 19, 2016, 7:37:29 AM1/19/16
to TurboGears
Sorry, have been busy days :D
Yep, if you can upload it somewhere and send me the link I'll try to check it, I hope it's something that can be solved quickly.

Bests,
Alessandro

--

c.cs...@gmail.com

unread,
Jan 21, 2016, 7:38:03 AM1/21/16
to TurboGears
Oh HAI! Alessandro! Thanks for getting back to me good sir! Here are my files... I hope you can help... It should be quite easy to fix, but I changed the name of certain tablets in the database, instead of User and Permission, it is now Users and Permissions, I think that is all which I changed... Pretty sure. It made more sense like that imo... That wouldn’t be why it doesn’t work, right? :S

Anyway, here are the files. i zipped my project directory and also my tg2env file as it contains certain additions, like tgext.mailer, tgapp-registration and psycop2 and perhaps certain others, I cannot remember.

Please help, if you can. I WOULD REALLY APPRECIATE IT! I have been stuck on this for ages mange... :(

Files:


Regards,
Chris

c.cs...@gmail.com

unread,
Jan 21, 2016, 8:07:30 AM1/21/16
to TurboGears
I just replaced the passwords with “PASSWORD’ though, of course.

Alessandro Molina

unread,
Jan 21, 2016, 2:34:14 PM1/21/16
to TurboGears
On Thu, Jan 21, 2016 at 1:38 PM, <c.cs...@gmail.com> wrote:
Oh HAI! Alessandro! Thanks for getting back to me good sir! Here are my files... I hope you can help... It should be quite easy to fix, but I changed the name of certain tablets in the database, instead of User and Permission, it is now Users and Permissions, I think that is all which I changed... Pretty sure. It made more sense like that imo... That wouldn’t be why it doesn’t work, right? :S

Well, that' at least the reason why I cannot create the database :D

$ gearbox setup-app --debug
   File "/Users/amol/tmp/flower/venv/lib/python2.7/site-packages/registration/model/sqla_models.py", line 34, in Registration
    user_id = Column(Integer, ForeignKey(primary_key(app_model.User)))
  File "/Users/amol/tmp/flower/venv/lib/python2.7/site-packages/tgext/pluggable/session_wrapper.py", line 13, in __getattr__
    return getattr(self._proxied, item)
AttributeError: 'module' object has no attribute 'User'

tgapp-registration has a foreign key against an "User" model, you can rename the table (__tablename__ in model class) but the class has to be named User.
I solved that simply by adding those lines at the end of model/__init__.py:

User = Users
Permission = Permissions
Group = Groups

About the fact that it's unable to find the email_sender configuration option, it's because you actually specified it inside the [loggers] section, not inside [app:main], specifically you added that as an option of the formatter_generic.

I moved all email related options right before the [loggers] section and it's now working.




c.cs...@gmail.com

unread,
Jan 25, 2016, 1:53:08 PM1/25/16
to TurboGears
THANK YOU SO MUCH Allesandro! You helped me SO MUCH MAN! I am fixing my files now! Awesome!!! Much <3

Regards,
Csatlos Frankenstein


On Sunday, 27 December 2015 07:59:06 UTC+11, c.cs...@gmail.com wrote:

c.cs...@gmail.com

unread,
Jan 30, 2016, 5:15:58 AM1/30/16
to TurboGears
Hey I Still do not understand where you mean for me to put the files? By the “app:main” section... Is that the directory where the development.ini and setup.py sit or is it where the folders controllers, public, and templates and etc are?

Because I still have my email settings in the development.ini file...

Thanks.

c.cs...@gmail.com

unread,
Jan 31, 2016, 5:13:17 AM1/31/16
to TurboGears
Oh! I see what you mean now... Within the development.ini file. Damn I feel stupid, sorry I was just confused by what you were saying...

Thanks.
Reply all
Reply to author
Forward
0 new messages