How to rename an app?

60 views
Skip to first unread message

Michael S

unread,
Feb 26, 2016, 10:23:39 AM2/26/16
to Tethys Platform, Nathan Swain
I want to install someone else's app, but I already have an app with that name. I found that I can install the new app, but it will overwrite the previous one I had. I can always go back to the previous app by reinstalling it in the same way, but it would be much easier if there was a way to rename an app.

I appreciate your help.

Thanks,
Michael

swainn

unread,
Feb 26, 2016, 6:30:17 PM2/26/16
to Tethys Platform, nsw...@aquaveo.com
There are two levels of renaming apps. 

The first level is changing the title of the app or display name of the app in the Apps Library. This can be done easily by changing the value of the name attribute of the app class (see: http://docs.tethysplatform.org/en/latest/tethys_sdk/app_class.html#TethysAppBase.name)

The second level is if you need two or more versions of the same app in the same portal. This not easy. It essentially boils down to two steps:

1) Rename a couple folders of the app.
2) Rename references to those folders throughout the code.

This limitation is imposed by the fact that the names of python modules (each app is a python module) are file system based and you can't have two files or directories in the same directory with the same name. The first step is to rename the directories and files of the app. Refer to the following diagram of an app project:

diagram of a Tethys app project for an app named my_first_app

Step 1: Rename folders - The app package is the python module/folder that is copied into Python site-packages when you install it ("my_first_app" in the example above). So, rename the app package and the folder under "templates" of the same name. These must be named the same name by convention.

Step 2: Rename references in the code - This is the hard part. The app package name is used as a namespace or id for the app by convention in several places. For example, it is used as the root of all urls for the app (e.g.: http://www.host.com/app/my_first_app/foo), it is used as a namespace for controller names (e.g. "my_first_app:controller_name"), and it is used as a namespace for static and template file paths to prevent conflicts with file names of other apps, so all paths to static files or templates need to be changed. Doing a search for the old package name on all the files in the app is a good place to start, but it won't be a "replace all" type operation. You only need to replace the names of references to the app package or namespace, not variables that may also have the app name in them. Typical places to look for the app package name/namespace:

A. App Class Properties: "index", "icon", "package", "root_url"
B. App Class Url Maps: both the "url" and "controller" paths
C. Other Paths to Functions in the App Class: for example the "initializer" parameter of PersistentStores
D. Use in import statements of all Python files of the app, including __init__.py files (e.g. from tethysapp.my_first_app.models import * )
E. Paths to templates at the end of most controllers (e.g.: return render(request, 'my_first_app/home.html', context) )
F. Calls to controllers using either the "url" template tag in templates  (e.g.: {% url 'my_first_app:home' %} ) or the "reverse" Django function in controllers (e.g. reverse('my_first_app:home') )
G. In "extends" template tags in the templates (e.g.: {% extends "my_first_app/base.html" %} )
H. Places where the app URLs might be hard coded like JS or CSS files (e.g. var url = '/apps/my_first_app/do-something';).

That probably would take care of about 97% of cases, but there are probably some cases that would be specific to the app. 

sdc50

unread,
Jul 20, 2016, 2:58:18 PM7/20/16
to Tethys Platform, nsw...@aquaveo.com
I feel like there was a discussion at some point of add a utility in the tethys CLI to automate renaming an app. If not, then I'd like to start it now. Is that doable and is there interest in having that done? Should it rename the app in place or create a copy of an app and allow all of the metadata for the app to be reassigned?

swainn

unread,
Jul 20, 2016, 4:26:08 PM7/20/16
to Tethys Platform, nsw...@aquaveo.com
I think there would be great interest in such a utility. However, what needs are motivating you wanting to do this? If it is to have multiple versions of an app in one portal, I have a few ideas for how we could change Tethys to allow for multiple installations of one app in a portal without renaming necessarily. But I haven't really formulated it. If that is your motivation, I think I'd prefer your effort put toward the latter option.

Scott Christensen

unread,
Jul 20, 2016, 5:03:36 PM7/20/16
to swainn, Tethys Platform, nsw...@aquaveo.com
The motivation is that I've got repository for an app that I would like to use as the starting point for a completely different app. I don't intend to have both apps on my portal, but the name of the app in the repo isn't appropriate for the new app that I'm going to develop, and thus I would like to rename it. I know I could go through the steps to manually rename it as you've described, but this is the second time I've wanted to do this, and I think others have wanted it as well, so it may warrant automating.

On Wed, Jul 20, 2016 at 3:26 PM swainn <nathan....@gmail.com> wrote:
I think there would be great interest in such a utility. However, what needs are motivating you wanting to do this? If it is to have multiple versions of an app in one portal, I have a few ideas for how we could change Tethys to allow for multiple installations of one app in a portal without renaming necessarily. But I haven't really formulated it. If that is your motivation, I think I'd prefer your effort put toward the latter option.

--
You received this message because you are subscribed to a topic in the Google Groups "Tethys Platform" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tethysplatform/-cONj_2Olr8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tethysplatfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tethysplatform/7efd9ed9-cada-422e-9a13-7b844b0155f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Scott D. Christensen, E.I.T
Research Assistant 
Brigham Young University

swainn

unread,
Jul 20, 2016, 5:15:47 PM7/20/16
to Tethys Platform, nathan....@gmail.com, nsw...@aquaveo.com
Thanks for the clarification. I think a command line tool would be great for that use case. I think I would have an option to either copy or rename in place. I can see cases for both options.

+1

Jacob Fullerton

unread,
Jul 29, 2016, 3:10:39 PM7/29/16
to Tethys Platform, nsw...@aquaveo.com
+1

Jacob Fullerton

unread,
Feb 1, 2017, 12:13:54 PM2/1/17
to Tethys Platform, nsw...@aquaveo.com
So I'm resurrecting this question because I'm having unexpected behavior as I'm trying to rename my app. I'm finding that even when I modify the contents of the app.py to match what I want, the original data I entered when I scaffolded my original app are what persist. I've tried uninstalling, reinstalling and redeveloping the app after making the changes I want to the app.py to no avail. Where else does the information from app.py get stored?

To clarify, I'm simply trying to change the title of my app from "Wellhead Protection" to "TimML-Cloud". I do not need to change the file names, I only want to change the displayed title and the little text that appears when hovering over the info button on the apps page (the little description of the app). Any help would be great! Thanks

Scott Christensen

unread,
Feb 1, 2017, 1:25:49 PM2/1/17
to Jacob Fullerton, Tethys Platform, nsw...@aquaveo.com
If all you want to do is change the name of your app that shows up on Tethys Portal then there are two things to understand:

  1. At the top of the app.py module there are several properties listed. One of these is the name. That represents the default name for the app when it is installed. If you change this and then uninstall and reinstall your app then the name should be updated on the portal.
  2. In the Tethys Portal admin pages there is a section called Tethys Apps. Under that you will find a list of all of the installed apps. There you can change the name property for any of the apps that are installed. So even if you have changed the name property in your app.py the administrator of the Tethys Portal where your app installed can change the name from the default to something else.
Hopefully that is clear and answers your questions.

On Wed, Feb 1, 2017 at 11:13 AM Jacob Fullerton <jacob...@gmail.com> wrote:
So I'm resurrecting this question because I'm having unexpected behavior as I'm trying to rename my app. I'm finding that even when I modify the contents of the app.py to match what I want, the original data I entered when I scaffolded my original app are what persist. I've tried uninstalling, reinstalling and redeveloping the app after making the changes I want to the app.py to no avail. Where else does the information from app.py get stored?

To clarify, I'm simply trying to change the title of my app from "Wellhead Protection" to "TimML-Cloud". I do not need to change the file names, I only want to change the displayed title and the little text that appears when hovering over the info button on the apps page (the little description of the app). Any help would be great! Thanks

--
You received this message because you are subscribed to the Google Groups "Tethys Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tethysplatfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tethysplatform/8e248e4e-b607-446e-8303-c308608d6485%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Scott D. Christensen, PhD
Research Civil Engineer
Information Technology Laboratory  
US Army Corps of Engineers
 

swainn

unread,
Feb 1, 2017, 2:27:50 PM2/1/17
to Tethys Platform
Sounds like the database is out of sync. You need to restart the server after uninstalling the app and before reinstalling to clear out the old entry from the database. Then stop the server, install the app and start it again. We need to extend the uninstall command to also remove the entry from the app database.
Reply all
Reply to author
Forward
0 new messages