Unable to open new forms in existing project!

What I’m trying to do:

Open a newly created form. The form was created after converting the project to use environments (I had to to activate the uplink). All existing code seems to run fine.

What I’ve tried and what’s not working:

open_form("ssstel2")

returns the following error :

NameError: name 'ssstel2Template' is not defined

and the line number for the error is the class definition line below. Anvil creates that template itself so I don’t quite know what to do about this?

Code Sample:

from anvil import *
import anvil.server
import anvil.users
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables

class ssstel2(ssstel2Template):
  def __init__(self, **properties):
    # Set Form properties and Data Bindings.
    self.init_components(**properties)

UPDATE - this now occurs with any new form that I add (ie I can’t add any more forms to the project).

UPDATE 2 - trying to switch back to the classic editor to see if that helps, and it just sits there with a blue spinner, eventually giving me this :

We’re sorry, but an error occurred while loading Anvil. If this keeps happening, please contact support@anvil.works.

UPDATE 3 - I’ve had this before but I don’t know how it was fixed by Anvil :

Clone link:
I can’t, it contains confidential data.

There’s normally an import for the template on the first line of the form, e.g.:

from ._anvil_designer import MainFormTemplate

Maybe try adding that manually?

1 Like

Damned fine catch, thank you! That worked.

It looks like on a converted project, that line is not added automatically. Well, at least not on this one.

Interestingly, none of the preexisting forms after the conversion have that line, either, but they still work.

Hi @david.wylie,

It looks like something went wrong in converting your project to use packages. That conversion process should have automatically added the from ._anvil_designer ... line @jshaffstall mentioned.

Did this project ever get formally converted to use packages? Can you go back to the editor and do that?

(If you didn’t convert it to use packages, but opened it in the beta editor and added forms inside packages anyway, then it’s possible that Strange Things could happen…)

1 Like

No. This is a very old project that works so well I leave it alone normally. I only reluctantly did the conversion because I had to enable the uplink.

What would you recommend I do now I’m in this half way state? By that I mean the old forms work but do not have that import added to them, but newly created forms (which don’t get that line added automatically) don’t work without it.

If you mean the old editor then no, I can’t. It won’t open for me (see the error in the OP).

Right, that’s an editor bug! Time to email support@anvil.works with the app ID and give us permission to snoop on your code…

ok, but I want a webcam on you to prove you’re not laughing!

Actually, it does [the spinning thing then crashes] without even loading a project.

Does this help any? This was just loading the editor with the list of available projects (without opening one) :

Uncaught (in promise)

  1. {data: ‘An internal error occurred: 948e17f4e0e1ef1c’, status: 500, config: {…}, statusText: ‘Internal Server Error’, headers: ƒ, …}

  2. config:

1. headers: {Accept: 'application/json, text/plain, */*'}
2. jsonpCallbackParam: "callback"
3. method: "GET"
4. paramSerializer: ƒ (a)
5. transformRequest: [ƒ]
6. transformResponse: [ƒ]
7. url: "/ide/user-details"
8. [[Prototype]]: Object
  1. data: “An internal error occurred: 948e17f4e0e1ef1c”
  2. headers: ƒ (d)
  3. status: 500
  4. statusText: “Internal Server Error”
  5. xhrStatus: “complete”

I get this seriously all the time and I only use the classic editor.

I have to:

  1. Go directly to the https://anvil.works/build#page:apps page.
  2. Hit hard-refresh (ctrl-F5 on pc/windows)
  3. Wait forever until the blue spinner stops spinning. (Without clicking ANYTHING else)
  4. Then click my project and it will open.

Optional 5 - 6: (Not seriously, but kinda seriously) :stuck_out_tongue:

  1. Never close the tab to that project so you don’t have to wait to try and re-open it
  2. Install double the ram so chrome lets you do anything else on your computer with all the IDE tabs open.