Anvil example app not working ("Secure Download Portal")

Hello!

What I’m trying to do:
I try to study some anvil-examples (app structure, logic, code snippets etc.) like the “Secure Download Portal”.
Secure Download Portal

What I’ve tried and what’s not working:
Some form templates open as expected, some not (e.g. File and Folder Template) getting following error:
SDP_screenshot_error

The code behind is not shown at all. Saving to GitHub repository helps to get access to the code but the original built form template/structure is not visible in that way.

And the “Admin Portal” part of this examples does not run when trying to sign in (message: anvil.tables.Table-Error: cannot be searched or written to).

Maybe a rendering conflict between classic and new editor?
What could I do to get access to view and run the app for studying?

Thanks in advance!
Tom

Hey @tfm,

Yeah, looks like this is a pretty old example. I was able to get it mostly migrated and at least to the point where it is functional. I’m not sure how to migrate components to the new editor and clicking on existing components basically blows up the new editor. I’m sure someone here knows how to correct this classic to new editor issue.

It required a few things to get things running:

  • Fix anvil.users imports
  • Connect the user module with the user table, I just deleted then added the Users module. This fixes your Table-Error.
  • Fix relative imports for Globals in Admin App
  • Convert GroupPicker to package and nesting GroupPickerItem
  • Updated to f-strings

One oddity that I noticed is that trying to open some forms would give the error shown, but if I cleaned up the editor URL to just the /code/forms/<Form Name> it would render. Maybe some artifact of classic editor?

This app is ripe for showcasing new Anvil functionality like Portable Classes with Capabilities.

Here are the two updated apps:
Client App
Client App

Admin App
Admin App

2 Likes

Hi @racersmith

Thank you very much for your migration and updates!
These help me a lot to get the details and to learn the logic behind. Your hints to the new functions are very welcome.

At the moment it is still difficult for me to tell whether I am looking at an “old” function that is no longer being used or should be used, or whether I am looking at a new function. The documentation is helpful, but sometimes I’m not sure how up-to-date it is. The example projects from Anvil and the forum posts help me enormously as a newbie to familiarize myself with Anvil.

The shortened link you showed does the trick! That way I was able to remove the “rendering error”.

Thank you very much for your kind and quick help!

Happy to help!

As far as functions and architecture goes, I don’t think there is anything that shouldn’t be used today. The main things were just some changes to how imports and how the user modules works.

If it was recreated today, I think the main change would be on the UI side utilizing Layouts.

For example,
You would change the HomeForm in admin to a layout and reuse it for Users, Content, and Groups.
Navigation would then change to:

    def users_lnk_click(self, **event_args):
        # This method is called when the link is clicked
        self.content_panel.clear()
        self.content_panel.add_component(Users())

would change to:

    def users_lnk_click(self, **event_args):
        # This method is called when the link is clicked
        anvil.open_form('Users')

New Editor Workaround

After poking around with the UI editor I did find an odd workaround. When the the UI editor is full width, everything breaks as soon as you click. However, if you switch to the split-view editor, at least you can move things around.

1 Like

Thank you very much for your renewed help! I really appreciate it.

These hints will hopefully or certainly help me to assess other (older) code examples as well. Sometimes I don’t know exactly whether ‘older’ could also mean ‘unsafe’ and should therefore probably be programmed differently or newly. Maybe I’m just seeing “code ghosts” :ghost: when I want to avoid security issues.

Strange behaviour with the IDE! In addition to the shortened link, the split view mode also helps me. Thank you!