Skip to content

Commit

Permalink
Merge pull request #458 from chris-allan/django-4-0
Browse files Browse the repository at this point in the history
Compatibility with Django 4.0
  • Loading branch information
knabar authored May 31, 2023
2 parents ac5e4cc + b5b3c17 commit ffa4eb8
Show file tree
Hide file tree
Showing 37 changed files with 395 additions and 376 deletions.
88 changes: 45 additions & 43 deletions omeroweb/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,46 @@

"""Handles all 'api' urls."""

from django.conf.urls import url
from django.urls import re_path
from omeroweb.api import views
from omeroweb.webgateway.views import LoginView
from . import api_settings
import re

versions = "|".join([re.escape(v) for v in api_settings.API_VERSIONS])

api_versions = url(r"^$", views.api_versions, name="api_versions")
api_versions = re_path(r"^$", views.api_versions, name="api_versions")

api_base = url(r"^v(?P<api_version>%s)/$" % versions, views.api_base, name="api_base")
api_base = re_path(
r"^v(?P<api_version>%s)/$" % versions, views.api_base, name="api_base"
)
"""
GET various urls listed below
"""

api_token = url(
api_token = re_path(
r"^v(?P<api_version>%s)/token/$" % versions, views.api_token, name="api_token"
)
"""
GET the CSRF token for this session. Needs to be included
in header with all POST, PUT & DELETE requests
"""

api_servers = url(
api_servers = re_path(
r"^v(?P<api_version>%s)/servers/$" % versions, views.api_servers, name="api_servers"
)
"""
GET list of available OMERO servers to login to.
"""

api_login = url(
api_login = re_path(
r"^v(?P<api_version>%s)/login/$" % versions, LoginView.as_view(), name="api_login"
)
"""
Login to OMERO. POST with 'username', 'password' and 'server' index
"""

api_save = url(
api_save = re_path(
r"^v(?P<api_version>%s)/m/save/$" % versions,
views.SaveView.as_view(),
name="api_save",
Expand All @@ -66,7 +68,7 @@
In both cases content body encodes json data.
"""

api_projects = url(
api_projects = re_path(
r"^v(?P<api_version>%s)/m/projects/$" % versions,
views.ProjectsView.as_view(),
name="api_projects",
Expand All @@ -75,7 +77,7 @@
GET all projects, using omero-marshal to generate json
"""

api_project = url(
api_project = re_path(
r"^v(?P<api_version>%s)/m/projects/(?P<object_id>[0-9]+)/$" % versions,
views.ProjectView.as_view(),
name="api_project",
Expand All @@ -84,7 +86,7 @@
Project url to GET or DELETE a single Project
"""

api_datasets = url(
api_datasets = re_path(
r"^v(?P<api_version>%s)/m/datasets/$" % versions,
views.DatasetsView.as_view(),
name="api_datasets",
Expand All @@ -93,7 +95,7 @@
GET all datasets, using omero-marshal to generate json
"""

api_project_datasets = url(
api_project_datasets = re_path(
r"^v(?P<api_version>%s)/m/projects/" "(?P<project_id>[0-9]+)/datasets/$" % versions,
views.DatasetsView.as_view(),
name="api_project_datasets",
Expand All @@ -102,7 +104,7 @@
GET Datasets in Project, using omero-marshal to generate json
"""

api_dataset = url(
api_dataset = re_path(
r"^v(?P<api_version>%s)/m/datasets/(?P<object_id>[0-9]+)/$" % versions,
views.DatasetView.as_view(),
name="api_dataset",
Expand All @@ -111,7 +113,7 @@
Dataset url to GET or DELETE a single Dataset
"""

api_images = url(
api_images = re_path(
r"^v(?P<api_version>%s)/m/images/$" % versions,
views.ImagesView.as_view(),
name="api_images",
Expand All @@ -120,7 +122,7 @@
GET all images, using omero-marshal to generate json
"""

api_dataset_images = url(
api_dataset_images = re_path(
r"^v(?P<api_version>%s)/m/datasets/" "(?P<dataset_id>[0-9]+)/images/$" % versions,
views.ImagesView.as_view(),
name="api_dataset_images",
Expand All @@ -129,7 +131,7 @@
GET Images in Dataset, using omero-marshal to generate json
"""

api_dataset_projects = url(
api_dataset_projects = re_path(
r"^v(?P<api_version>%s)/m/datasets/" "(?P<dataset_id>[0-9]+)/projects/$" % versions,
views.ProjectsView.as_view(),
name="api_dataset_projects",
Expand All @@ -138,7 +140,7 @@
GET Projects that contain a Dataset, using omero-marshal to generate json
"""

api_image = url(
api_image = re_path(
r"^v(?P<api_version>%s)/m/images/(?P<object_id>[0-9]+)/$" % versions,
views.ImageView.as_view(),
name="api_image",
Expand All @@ -147,7 +149,7 @@
Image url to GET or DELETE a single Image
"""

api_image_datasets = url(
api_image_datasets = re_path(
r"^v(?P<api_version>%s)/m/images/" "(?P<image_id>[0-9]+)/datasets/$" % versions,
views.DatasetsView.as_view(),
name="api_image_datasets",
Expand All @@ -156,7 +158,7 @@
GET Datasets that contain an Image, using omero-marshal to generate json
"""

api_screen = url(
api_screen = re_path(
r"^v(?P<api_version>%s)/m/screens/(?P<object_id>[0-9]+)/$" % versions,
views.ScreenView.as_view(),
name="api_screen",
Expand All @@ -165,7 +167,7 @@
Screen url to GET or DELETE a single Screen
"""

api_screens = url(
api_screens = re_path(
r"^v(?P<api_version>%s)/m/screens/$" % versions,
views.ScreensView.as_view(),
name="api_screens",
Expand All @@ -174,7 +176,7 @@
GET all screens, using omero-marshal to generate json
"""

api_plates = url(
api_plates = re_path(
r"^v(?P<api_version>%s)/m/plates/$" % versions,
views.PlatesView.as_view(),
name="api_plates",
Expand All @@ -183,7 +185,7 @@
GET all plates, using omero-marshal to generate json
"""

api_screen_plates = url(
api_screen_plates = re_path(
r"^v(?P<api_version>%s)/m/screens/" "(?P<screen_id>[0-9]+)/plates/$" % versions,
views.PlatesView.as_view(),
name="api_screen_plates",
Expand All @@ -192,7 +194,7 @@
GET Plates in Screen, using omero-marshal to generate json
"""

api_well_plates = url(
api_well_plates = re_path(
r"^v(?P<api_version>%s)/m/wells/" "(?P<well_id>[0-9]+)/plates/$" % versions,
views.PlatesView.as_view(),
name="api_well_plates",
Expand All @@ -201,7 +203,7 @@
GET Plates that contain a Well, using omero-marshal to generate json
"""

api_plate = url(
api_plate = re_path(
r"^v(?P<api_version>%s)/m/plates/(?P<object_id>[0-9]+)/$" % versions,
views.PlateView.as_view(),
name="api_plate",
Expand All @@ -210,7 +212,7 @@
Plate url to GET or DELETE a single Plate
"""

api_wells = url(
api_wells = re_path(
r"^v(?P<api_version>%s)/m/wells/$" % versions,
views.WellsView.as_view(),
name="api_wells",
Expand All @@ -219,7 +221,7 @@
GET all wells, using omero-marshal to generate json
"""

api_plate_plateacquisitions = url(
api_plate_plateacquisitions = re_path(
r"^v(?P<api_version>%s)/m/plates/"
"(?P<plate_id>[0-9]+)/plateacquisitions/$" % versions,
views.PlateAcquisitionsView.as_view(),
Expand All @@ -229,7 +231,7 @@
GET PlateAcquisitions in Plate, using omero-marshal to generate json
"""

api_plateacquisition = url(
api_plateacquisition = re_path(
r"^v(?P<api_version>%s)/m/plateacquisitions/" "(?P<object_id>[0-9]+)/$" % versions,
views.PlateAcquisitionView.as_view(),
name="api_plateacquisition",
Expand All @@ -238,7 +240,7 @@
Well url to GET or DELETE a single Well
"""

api_plateacquisition_wellsampleindex_wells = url(
api_plateacquisition_wellsampleindex_wells = re_path(
r"^v(?P<api_version>%s)/m/plateacquisitions/"
"(?P<plateacquisition_id>[0-9]+)/wellsampleindex/"
"(?P<index>[0-9]+)/wells/$" % versions,
Expand All @@ -249,7 +251,7 @@
GET Wells from a single Index in PlateAcquisition
"""

api_plate_wellsampleindex_wells = url(
api_plate_wellsampleindex_wells = re_path(
r"^v(?P<api_version>%s)/m/plates/"
"(?P<plate_id>[0-9]+)/wellsampleindex/"
"(?P<index>[0-9]+)/wells/$" % versions,
Expand All @@ -260,7 +262,7 @@
GET Wells from a single Index in Plate
"""

api_plate_wells = url(
api_plate_wells = re_path(
r"^v(?P<api_version>%s)/m/plates/" "(?P<plate_id>[0-9]+)/wells/$" % versions,
views.WellsView.as_view(),
name="api_plate_wells",
Expand All @@ -269,7 +271,7 @@
GET Wells in Plate, using omero-marshal to generate json
"""

api_plateacquisition_wells = url(
api_plateacquisition_wells = re_path(
r"^v(?P<api_version>%s)/m/plateacquisitions/"
"(?P<plateacquisition_id>[0-9]+)/wells/$" % versions,
views.WellsView.as_view(),
Expand All @@ -279,7 +281,7 @@
GET Wells in Plate, using omero-marshal to generate json
"""

api_well = url(
api_well = re_path(
r"^v(?P<api_version>%s)/m/wells/(?P<object_id>[0-9]+)/$" % versions,
views.WellView.as_view(),
name="api_well",
Expand All @@ -288,7 +290,7 @@
Well url to GET or DELETE a single Well
"""

api_plate_screens = url(
api_plate_screens = re_path(
r"^v(?P<api_version>%s)/m/plates/" "(?P<plate_id>[0-9]+)/screens/$" % versions,
views.ScreensView.as_view(),
name="api_plate_screens",
Expand All @@ -297,7 +299,7 @@
GET Screens that contain a Plate, using omero-marshal to generate json
"""

api_rois = url(
api_rois = re_path(
r"^v(?P<api_version>%s)/m/rois/$" % versions,
views.RoisView.as_view(),
name="api_rois",
Expand All @@ -306,7 +308,7 @@
GET all rois, using omero-marshal to generate json
"""

api_roi = url(
api_roi = re_path(
r"^v(?P<api_version>%s)/m/rois/(?P<object_id>[0-9]+)/$" % versions,
views.RoiView.as_view(),
name="api_roi",
Expand All @@ -315,7 +317,7 @@
ROI url to GET or DELETE a single ROI
"""

api_image_rois = url(
api_image_rois = re_path(
r"^v(?P<api_version>%s)/m/images/(?P<image_id>[0-9]+)/rois/$" % versions,
views.RoisView.as_view(),
name="api_image_rois",
Expand All @@ -324,7 +326,7 @@
GET ROIs that belong to an Image, using omero-marshal to generate json
"""

api_shapes = url(
api_shapes = re_path(
r"^v(?P<api_version>%s)/m/shapes/$" % versions,
views.ShapesView.as_view(),
name="api_shapes",
Expand All @@ -333,7 +335,7 @@
GET all Shapes, using omero-marshal to generate json
"""

api_shape = url(
api_shape = re_path(
r"^v(?P<api_version>%s)/m/shapes/(?P<object_id>[0-9]+)/$" % versions,
views.ShapeView.as_view(),
name="api_shape",
Expand All @@ -342,7 +344,7 @@
Shape url to GET or DELETE a single Shape
"""

api_experimenters = url(
api_experimenters = re_path(
r"^v(?P<api_version>%s)/m/experimenters/$" % versions,
views.ExperimentersView.as_view(),
name="api_experimenters",
Expand All @@ -351,7 +353,7 @@
GET Experimenters, using omero-marshal to generate json
"""

api_experimenter = url(
api_experimenter = re_path(
r"^v(?P<api_version>%s)/m/experimenters/" "(?P<object_id>[0-9]+)/$" % versions,
views.ExperimenterView.as_view(),
name="api_experimenter",
Expand All @@ -360,7 +362,7 @@
GET Experimenter, using omero-marshal to generate json
"""

api_group_experimenters = url(
api_group_experimenters = re_path(
r"^v(?P<api_version>%s)/m/experimentergroups/(?P<group_id>[0-9]+)"
"/experimenters/$" % versions,
views.ExperimentersView.as_view(),
Expand All @@ -370,7 +372,7 @@
GET Experimenters in a Group, using omero-marshal to generate json
"""

api_groups = url(
api_groups = re_path(
r"^v(?P<api_version>%s)/m/experimentergroups/$" % versions,
views.ExperimenterGroupsView.as_view(),
name="api_experimentergroups",
Expand All @@ -379,7 +381,7 @@
GET ExperimenterGroups, using omero-marshal to generate json
"""

api_group = url(
api_group = re_path(
r"^v(?P<api_version>%s)/m/experimentergroups/" "(?P<object_id>[0-9]+)/$" % versions,
views.ExperimenterGroupView.as_view(),
name="api_experimentergroup",
Expand All @@ -388,7 +390,7 @@
GET ExperimenterGroup, using omero-marshal to generate json
"""

api_experimenter_groups = url(
api_experimenter_groups = re_path(
r"^v(?P<api_version>%s)/m/experimenters/(?P<experimenter_id>[0-9]+)"
"/experimentergroups/$" % versions,
views.ExperimenterGroupsView.as_view(),
Expand Down
7 changes: 0 additions & 7 deletions omeroweb/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import re
import logging

from django.utils.encoding import force_text
from future.utils import with_metaclass

from omero import client_wrapper
Expand Down Expand Up @@ -90,12 +89,6 @@ def __repr__(self):
"""
return """["%s", %s, "%s"]""" % (self.host, self.port, self.server)

def __str__(self):
return force_text(self).encode("utf-8")

def __unicode__(self):
return str(self.id)

@classmethod
def get(cls, pk):
r = None
Expand Down
Loading

0 comments on commit ffa4eb8

Please sign in to comment.