Custom sign-up flow

What I’m trying to do:
I’m trying to play with a clone of the “Custom sign-up flow” app, from

I’ve made no changes (hence no sample code included).

  1. First try (in the IDE) , the confirmation email sent to me included the url
    None#?email=alex%40tweedly.net&confirm=uo57hKndBsd5Gr

obviously, within the IDE there is no valid URL, so not too big a surprise, but might be a better way to detect / report that problem.
Is there a function to let me know if we are running in the IDE vs published ?

  1. So I published the app, as
    https://pleasing-exhausted-coat.anvil.app/

and tried again, with a different email, and got
anvil.server.InternalError: force_login() must be passed a row from the users table

I have no idea how to track this down, so any suggestions or help would be welcomed.

Hi @alex3 and welcome to the forum!

I just followed that how-to guide and ran my app from a published environment, signed up for a new account and everything worked as expected. I’m not sure why it’s going wrong for you. Did you follow all the steps in the guide?

If you look in the Server Module of the Custom sign-up flow app, you can see that force_login() is used within the _confirm_email_address function. I recommend adding a print statement in that function to figure out what user is since that error statement indicates it’s not a row from the users table.

1 Like

Hi Brooke, thanks for the welcome.

Firstly, no, I didn’t previously follow all the steps in the guide. I thought I could (lazily) take the shortcut of cloning the example app, and that’s how I got the errors reported earlier.

So, I tried again following the steps, creating a blank app, etc. and found some problems.

  1. Instruction syas
  • Change the role to ‘primary-color’.
    I don’t see that role, I only have choices
    elevated-button, filled-button, etc.
  1. When I follow the remaining steps, and “Run”, I get

AttributeError: 'Form1' object has no attribute 'update_login_status'

I noticed that the cloned app has replaced (in Form1 / Test)

. import custom_signup.login_flow
with
. from … import login_flow
so I tried that, and get
. AttributeError: (most likely due to a circular import) partially initialized module ‘M3_App_2’ has no attribute ‘login_flow’
on this import line.

So, I’ve given up on following all the steps, and gone back to the cloned app.
You suggested:

If you look in the Server Module of the Custom sign-up flow app, you can see that force_login() is used within the _confirm_email_address function. I recommend adding a print statement in that function to figure out what user is since that error statement indicates it’s not a row from the users table.

However, I can’t get to this point in the code in the IDE, only by publishing it and running that. And in this case, I don’t see console output, I only get the alert box that says
This apop has experienced an error.
anvil.server.InternalError: force_login() must be passed a row from the users table

Is there a way to see the output from print statements when running a published app ?

Hi @alex3,

To address your points:

  1. The guide mentions changing the role to “primary” because it uses our old Material Design theme (which is still available). I’ll add it to our list to update it to a newer theme, but this doesn’t change anything about how the app works, just how the button looks.
  2. Did you create the update_login_status function as described in Step 3?
  3. import custom_signup.login_flow should work (and it worked when I tested it). custom_signup is the package name for the Custom Sign Up Flow app.
  4. Yes! You can see print statements from published environments in your App Logs.

Here is a clone link of the app I built following that guide. I haven’t included dependencies in the clone link so you’ll need to add your clone of the Custom Sign Up Flow app in the Dependencies tab: Anvil | Login

Thanks again Brooke,

  1. yes, I realised that the role (e.g. “primary”) wasn’t important - I should have said that.
  2. Yes, I did (afaik) follow step 3 fully.
  3. thanks
  4. Thanks, I’ll check out App Logs.

Thanks for the clone link for your app. I copied that, added the dependency as described, and I now get.

anvil.tables.TableError: This table cannot be written or searched by this app

Learn more about Data tables

  • <running on the server>
  • called from anvil-services/anvil/users/__init__.py:38
  • called from login_flow, line 28
  • called from login_flow, line 28
  • called from Test, line 27

line 28 is
anvil.users.login_with_email(d.email_box.text, d.password_box.text, remember=True)

Still baffled. I think I’ll go try out some of the other examples and see if I have any more luck. Thanks again, Alex.