The docs say to declare the portable class as a client side module, so it can be read by both client and server. @meredydd’s announcement also says PCs can be used in uplink code.
Problem is the uplink code cannot see the module so I cannot import it on the remote server, and therefore I cannot use it. So I recreate the PC module on the uplink server to get the uplink code to run.
When I call the uplink server function, I get this error when attempting to return a PC :
ImportError: No module named portable_classes
and the line number given is the client form with the server call.
Here is a test app :
https://anvil.works/build#clone:TKXY5PPLJQCFLWLS=AXILEBBZSFI2QLTVFFIYSEHL
and here is the uplink code :
import anvil.server
from portable_classes import Response
anvil.server.connect("redacted")
@anvil.server.callable
def remote_test():
return Response(500, [], "test remote")
and here is the PC module copied straight from the IDE module :
import anvil.server
@anvil.server.portable_class
class Response:
def __init__(self, status=999, data="", text=""):
self._status = status
self._data = data
self._text = text
@property
def status(self):
return self._status
@property
def data(self):
return self._data
@property
def text(self):
return self._text