{"id":16542157,"url":"https://github.com/painebenjamin/fruition","last_synced_at":"2025-04-13T19:34:28.528Z","repository":{"id":186372183,"uuid":"634004803","full_name":"painebenjamin/fruition","owner":"painebenjamin","description":"The Fruition framework turbocharges Python web applications with a huge array of features and easy-to-use interface.","archived":false,"fork":false,"pushed_at":"2025-02-15T22:13:24.000Z","size":536,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T16:14:21.413Z","etag":null,"topics":["aws-lambda","ftp-client","ftp-server","http-server","orm-framework","python-3","s3-client","sftp-client","sftp-server","utilities","web-server"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/painebenjamin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-28T19:40:43.000Z","updated_at":"2025-02-15T22:13:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"98f4933a-5683-4fd2-8eab-7b3d552d6f9e","html_url":"https://github.com/painebenjamin/fruition","commit_stats":null,"previous_names":["painebenjamin/pibble","painebenjamin/fruition"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/painebenjamin%2Ffruition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/painebenjamin%2Ffruition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/painebenjamin%2Ffruition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/painebenjamin%2Ffruition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/painebenjamin","download_url":"https://codeload.github.com/painebenjamin/fruition/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248768379,"owners_count":21158627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","ftp-client","ftp-server","http-server","orm-framework","python-3","s3-client","sftp-client","sftp-server","utilities","web-server"],"created_at":"2024-10-11T18:56:47.307Z","updated_at":"2025-04-13T19:34:28.501Z","avatar_url":"https://github.com/painebenjamin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fruition\n\nThe Fruition framework turbocharges Python web applications with a huge array of features and easy-to-use interface.\n\n# Installation\n\nThe `fruition` package is available on PYPI. Simply run:\n\n```\npip install fruition\n```\n# Features\n## API Integration Layer\n\nAPIs are broken up into server and client modules.\n\n### Server\n\nAll web server APIs should be extended from `fruition.api.server.webservice.base.WebServiceAPIServerBase`. For the most part, each implementation must only register some handlers using the `fruition.api.server.webservice.base.WebServiceAPIHandlerRegistry`, which will handle all requests using a method and path. A class is not recommended to use the parent handler function, as this will provider handlers for all classes in this module that extend from `fruition.api.webservice.base.WebServiceAPIServerBase`, instead defining their own. For example, if we simply wanted to serve files from a directory over HTTP, we could use something like this:\n\n```python3\nimport os\nfrom typing import Optional\nfrom webob import Request, Response\nfrom fruition.api.exceptions import NotFoundError\nfrom fruition.api.server.webservice.base import (\n    WebServiceAPIServerBase,\n    WebServiceAPIHandlerRegistry\n)\n\nclass HelloWorldServer(WebServiceAPIServerBase):\n    \"\"\"\n    This class provides a single endpoint at the root URL displaying a simple message.\n    It creates a handler registry, then uses the registries decorators to configure the handler.\n    \"\"\"\n    handlers = WebServiceAPIHandlerRegistry()\n\n    @handlers.path(\"^$\")\n    @handlers.methods(\"GET\")\n    def hello_world(self, request: Request, response: Response) -\u003e None:\n        \"\"\"\n        Handles the request at the root and sends a simple message.\n  \n        :param request webob.Request: The request object.\n        :param response webob.Response: The response object.\n        \"\"\"\n        response.text = \"\u003c!DOCTYPE html\u003e\u003chtml lang='en_US'\u003e\u003cbody\u003eHello, world!\u003c/body\u003e\u003c/html\u003e\"\n\nclass SimpleFileServer(HelloWorldServer):\n    \"\"\"\n    This class creates a more complicated handler than allows for downloading files.\n\n    It also extends the class above, inheriting the handlers above.\n\n    Classes should always name their handler registry 'handlers'. If you want to name your registry\n    something else, you need to add a `get_handlers()` classmethod that returns the registry for it\n    to be recognized by the dispatcher.\n    \"\"\"\n    handlers = WebServiceAPIHandlerRegistry()\n    base_directory = \"/var/www/html\"\n\n    @handlers.path(\"(?P\u003cfile_path\u003e.*)\")\n    @handlers.methods(\"GET\")\n    def retrieve_file(self, request: Request, response: Response, file_path: Optional[str] = None) -\u003e None:\n        \"\"\"\n        Handles the request by looking for the path in ``self.base_directory``.\n  \n        :param request webob.Request: The request object.\n        :param response webob.Response: The response object.\n        :param file_path str: The file path, captured from the URI.\n        :throws: :class:`fruition.api.exceptions.NotFoundError`\n        \"\"\"\n  \n        file_path = os.path.join(self.base_directory, file_path)\n        if not os.path.isfile(file_path):\n            raise NotFoundError(\"Could not find file at {0}\".format(file_path))\n  \n        response.body = open(file_path, \"r\").read()\n```\n\nThe request and response parameters are webob.Request and webob.Response objects, respectively. See [The WebOb Documentation](https://docs.pylonsproject.org/projects/webob/en/stable/) for help with their usage. Note the method name does not matter, so use a naming schema relevant to your project.\n\nDeploying the API can be done using anything that conforms to wsgi standards. For development, we can deploy a server using werkzeug or gunicorn, binding to a local port with a configured listening host. Using the above server definition, we can do this with::\n\n```python\nserver = SimpleFileServer()\nserver.configure(server = {\"driver\": \"werkzeug\", \"host\": \"0.0.0.0\", \"port\": 9090})\n\n# Serve synchronously\nserver.serve()\n\n# Serve asynchronously\nserver.start()\n# Use the server\nserver.stop()\n```\n\nFor production, most servers will simply import a file and look for a globally-available `application` that conforms to WSGI standards. The easiest way to configure this is thusly:\n\n```python\n# wsgi.py\nfrom mypackage.server import SimpleFileServer\nserver = SimpleFileServer()\napplication = server.wsgi()\n```\n\nPointing something like Apache's `mod_wsgi` to this `wsgi.py` file will allow Fruition to be ran through Apache.\n\n#### RPC\n\nUsing one of the RPC servers is as simple as defining functions and registering them to the server:\n\n```python\nfrom fruition.api.server.webservice.rpc.xml.server import XMLRPCServer\n\nserver = XMLRPCServer()\n\n@server.register\n@server.sign_request(int, int)\n@server.sign_response(int)\ndef add(x, y):\n    return x + y\n\n@server.register\n@server.sign_request(int, int)\n@server.sign_response(int)\ndef subtract(x, y):\n    return x - y\n\n@server.register\n@server.sign_request(int, int)\n@server.sign_response(int)\ndef multiply(x, y):\n    return x * y\n\n@server.register\n@server.sign_request(int, int)\n@server.sign_response(float)\ndef divide(x, y):\n    return x / y\n\nserver.configure(server = {\"driver\": \"werkzeug\", \"host\": \"0.0.0.0\", \"port\": 9090})\nprint(\"Running server, listening on 0.0.0.0:9090. Hit Ctrl+C to exit.\")\nserver.serve()\n```\n\nThe base server defines methods for registration and dispatching of requests. The two implementations (XML and JSON) are responsible for parsing and formatting of requests and responses.\n\n### Client\n\nThe simplest client possible is one that simply communicates with a webserver, and doesn't need to parse the response in any meaningful way. Unlike with servers, the base webservice API client is instantiable.\n\n```python\nfrom fruition.api.client.webservice.base import WebServiceAPIClientBase\n\nbase = WebServiceAPIClientBase(\"google.com\")\nprint(base.get().text)\n```\nWhen executing any methods via .get(), .post(), etc., you will receive a `requests.models.Response` object. See the the requests documentation for assistance with these objects. Clients use a session (r`equests.models.Session`) object to maintain some state (cookies, etc.), but should generally assume themselves to be stateless.\n\n#### RPC\n\nUsing an XML RPC Client is very simple. Once a client is instantiated, it will queue up a call to system.listMethods, a built-in RPC function that will list the methods of a client. After that, calling them is as simple as calling the method with the appropriate variables\n\n```python\nfrom fruition.api.client.webservice.rpc.xml.client import XMLRPCClient\nfrom fruition.api.exceptions import (\n    BadRequestError,\n    UnsupportedMethodError\n)\n\nclient = XMLRPCClient(\"127.0.0.1\")\n\n# Use a method with reserved characters\nmethods = client[\"system.listMethods\"]()\n\nfor method in methods:\n    # Get method signature - note this is automatically retrieved and checked when calling any function, but you can retrieve it for yourself if you need to.\n    signature = client[\"system.methodSignature\"](method)\n    return_type, parameter_types = signature[0], signature[1:] # RPC specification\n    print(\"Method {0} takes ({1}) and returns ({2})\".format(method, \", \".join(parameter_types), return_type))\n\ntry:\n    method.pow(1, 2, 3)\nexcept BadRequestError:\n    # Wrong parameters\nexcept BadResponseError:\n    # Wrong response time\nexcept UnsupportedMethodError:\n    # Method does not exist\n```\n\nThe base client has handlers for introspection and dispatching requests. Implementations are responsible for formatting requests and parsing responses.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpainebenjamin%2Ffruition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpainebenjamin%2Ffruition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpainebenjamin%2Ffruition/lists"}