Difference between revisions of "Python Module"

From Lianjapedia
Jump to: navigation, search
Line 1: Line 1:
'''**Under Development**'''
+
Node.js is an open-source and cross-platform JavaScript runtime environment. It is a popular tool for almost any kind of project!
 +
 
 +
Node.js runs the V8 JavaScript engine, the core of Google Chrome, outside of the browser. This allows Node.js to be very performant.
 +
 
 +
A Node.js app runs in a single process, without creating a new thread for every request. Node.js provides a set of asynchronous I/O primitives in its standard library that prevent JavaScript code from blocking and generally, libraries in Node.js are written using non-blocking paradigms, making blocking behavior the exception rather than the norm.
 +
 
 +
==Lianja Cloud Data Services Python module==
 +
 
 +
Lianja Cloud Server includes a Python module '''lianjaclouddataservices''' enabling Python applications to connect to a local or remote Lianja Cloud Server and perform a variety of operations.
 +
 
 +
==Installing the Lianja Cloud Data Services Python module==
 +
 
 +
On Windows:
 +
 
 +
<code lang='bash'>
 +
cd C:\lianja\cloudserver\tenants\public\wwwroot\library\LianjaWebFramework\LianjaCloudDataServices\python\
 +
pip install -r requirements.txt
 +
</code>
 +
 
 +
On Linux:
 +
 
 +
<code lang='bash'>
 +
cd /opt/lianja/cloudserver/tenants/public/wwwroot/library/LianjaWebFramework/LianjaCloudDataServices/python/
 +
pip install -r requirements.txt
 +
</code>
 +
 
 +
Testing the installation:
 +
 
 +
On Windows:
 +
 
 +
<code lang='bash'>
 +
cd C:\lianja\cloudserver\tenants\public\wwwroot\library\LianjaWebFramework\LianjaCloudDataServices\node\lianjaclouddataservices\
 +
node test.js</code>
 +
 
 +
on Linux:
 +
 
 +
<code lang='bash'>
 +
cd /opt/lianja/cloudserver/tenants/public/wwwroot/library/LianjaWebFramework/LianjaCloudDataServices/node/lianjaclouddataservices\
 +
node test.js</code>
 +
 
 +
==Using the Lianja Cloud Data Services module in Python Applications==
 +
 
 +
Load the module into your Python application
 +
 
 +
<code lang='javascript'>import Lianjaclouddataservices as Lianja</code>
 +
 
 +
Exported functions. All Python methods are asynchronous (see example usage below).
 +
 
 +
See [[OData_URIs|OData URIs]] for details of OData URIs and [[OData_Operators|OData Operators]] for all the OData operators.
 +
 
 +
==Module Methods==
 +
{| class="wikitable" width=100%
 +
!width="30%"|Function
 +
!width="70%"|Description
 +
|-
 +
|valign="top"|Lianja.login(host, user, password)
 +
|valign="top"|Login and connect to to a local or remote Cloud Server. To connect locally specify the host as http: //localhost:8001
 +
|-
 +
|valign="top"|Lianja.logout()
 +
|valign="top"|Logout from the local or remote Cloud Server.
 +
|-
 +
|valign="top"|Lianja.evaluate(expr)
 +
|valign="top"|Evaluates LianjaScript expression and returns the result asynchronously.
 +
|-
 +
|valign="top"|Lianja.evaluatePython(expr)
 +
|valign="top"|Evaluates Python expression and returns the result asynchronously.
 +
|-
 +
|valign="top"|Lianja.evaluateJavaScript(expr)
 +
|valign="top"|Evaluates JavaScript expression and returns the result asynchronously.
 +
|-
 +
|valign="top"|Lianja.fetch(url)
 +
|valign="top"|Fetches data from the server using an .rsp, .pysp or .jssp server side page. Use fetch() to retrieve custom data from the server.
 +
|-
 +
|valign="top"|Lianja.OData_Create(url, data)
 +
|valign="top"|See [[ODATA_CREATE()]]
 +
|-
 +
|valign="top"|Lianja.OData_Read(url)
 +
|valign="top"|See  [[ODATA_READ()]]
 +
|-
 +
|valign="top"|Lianja.OData_ReadHTML(url)
 +
|valign="top"|See See  [[ODATA_READ()]]
 +
|-
 +
|valign="top"|Lianja.OData_ReadJSON(url)
 +
|valign="top"|See See  [[ODATA_READ()]]
 +
|-
 +
|valign="top"|Lianja.OData_ReadImage(url)
 +
|valign="top"|See See  [[ODATA_READ()]]
 +
|-
 +
|valign="top"|Lianja.OData_Update(url, data)
 +
|valign="top"|See  [[ODATA_UPDATE()]]
 +
|-
 +
|valign="top"|Lianja.OData_UpdateHTML(url, text)
 +
|valign="top"|See  [[ODATA_UPDATE()]]
 +
|-
 +
|valign="top"|Lianja.OData_UpdateJSON(url, jsontext)
 +
|valign="top"|
 +
|-
 +
|valign="top"|Lianja.OData_Delete(url, data)
 +
|valign="top"|See  [[ODATA_DELETE()]]
 +
|-
 +
|}
 +
 
 +
Example usage:
 +
 
 +
<code lang='python'>
 +
import lianjaclouddataservices as Lianja
 +
 
 +
rc = Lianja.login("admin", "admin")
 +
print("Lianja.login() - " + ("Ok" if ok else "Nok"))
 +
 
 +
result = Lianja.evaluateSync("etos(date()) + ' ' + time()")
 +
print("Lianja.evaluateSync() - " + result)
 +
 
 +
result = Lianja.evaluate("etos(date()) + ' ' + time()")
 +
print("Lianja.evaluate() - " + result)
 +
 
 +
response = Lianja.OData_Read("/southwind/employees")
 +
print("Lianja.OData_Read()")
 +
print("count="+response.d.__count)
 +
 
 +
response = Lianja.OData_ReadHTML("/southwind/employees?$select=notes&$filter=lastname eq 'Buchanan'")
 +
print("Lianja.OData_ReadHTML()")
 +
print(response)
 +
 
 +
response = Lianja.OData_ReadImage("/southwind/employees?$select=photo&$filter=lastname eq 'Buchanan'")
 +
print("Lianja.OData_ReadImage()")
 +
print("size="+response.length)
 +
</code>
 +
 
 +
[[Category:Lianja Server]]
 +
[[Category:Lianja v9.6]]
 +
[[Category:OData Functions|* Node.js]]
 +
 
  
 
[[Category:Lianja Server]]
 
[[Category:Lianja Server]]

Revision as of 23:16, 27 April 2024

Node.js is an open-source and cross-platform JavaScript runtime environment. It is a popular tool for almost any kind of project!

Node.js runs the V8 JavaScript engine, the core of Google Chrome, outside of the browser. This allows Node.js to be very performant.

A Node.js app runs in a single process, without creating a new thread for every request. Node.js provides a set of asynchronous I/O primitives in its standard library that prevent JavaScript code from blocking and generally, libraries in Node.js are written using non-blocking paradigms, making blocking behavior the exception rather than the norm.

Lianja Cloud Data Services Python module

Lianja Cloud Server includes a Python module lianjaclouddataservices enabling Python applications to connect to a local or remote Lianja Cloud Server and perform a variety of operations.

Installing the Lianja Cloud Data Services Python module

On Windows:

cd C:\lianja\cloudserver\tenants\public\wwwroot\library\LianjaWebFramework\LianjaCloudDataServices\python\
pip install -r requirements.txt

On Linux:

cd /opt/lianja/cloudserver/tenants/public/wwwroot/library/LianjaWebFramework/LianjaCloudDataServices/python/
pip install -r requirements.txt

Testing the installation:

On Windows:

cd C:\lianja\cloudserver\tenants\public\wwwroot\library\LianjaWebFramework\LianjaCloudDataServices\node\lianjaclouddataservices\
node test.js

on Linux:

cd /opt/lianja/cloudserver/tenants/public/wwwroot/library/LianjaWebFramework/LianjaCloudDataServices/node/lianjaclouddataservices\
node test.js

Using the Lianja Cloud Data Services module in Python Applications

Load the module into your Python application

import Lianjaclouddataservices as Lianja

Exported functions. All Python methods are asynchronous (see example usage below).

See OData URIs for details of OData URIs and OData Operators for all the OData operators.

Module Methods

Function Description
Lianja.login(host, user, password) Login and connect to to a local or remote Cloud Server. To connect locally specify the host as http: //localhost:8001
Lianja.logout() Logout from the local or remote Cloud Server.
Lianja.evaluate(expr) Evaluates LianjaScript expression and returns the result asynchronously.
Lianja.evaluatePython(expr) Evaluates Python expression and returns the result asynchronously.
Lianja.evaluateJavaScript(expr) Evaluates JavaScript expression and returns the result asynchronously.
Lianja.fetch(url) Fetches data from the server using an .rsp, .pysp or .jssp server side page. Use fetch() to retrieve custom data from the server.
Lianja.OData_Create(url, data) See ODATA_CREATE()
Lianja.OData_Read(url) See ODATA_READ()
Lianja.OData_ReadHTML(url) See See ODATA_READ()
Lianja.OData_ReadJSON(url) See See ODATA_READ()
Lianja.OData_ReadImage(url) See See ODATA_READ()
Lianja.OData_Update(url, data) See ODATA_UPDATE()
Lianja.OData_UpdateHTML(url, text) See ODATA_UPDATE()
Lianja.OData_UpdateJSON(url, jsontext)
Lianja.OData_Delete(url, data) See ODATA_DELETE()

Example usage:

import lianjaclouddataservices as Lianja
 
rc = Lianja.login("admin", "admin")
print("Lianja.login() - " + ("Ok" if ok else "Nok"))
 
result = Lianja.evaluateSync("etos(date()) + ' ' + time()")
print("Lianja.evaluateSync() - " + result)
 
result = Lianja.evaluate("etos(date()) + ' ' + time()")
print("Lianja.evaluate() - " + result)
 
response = Lianja.OData_Read("/southwind/employees") 
print("Lianja.OData_Read()")
print("count="+response.d.__count)	
 
response = Lianja.OData_ReadHTML("/southwind/employees?$select=notes&$filter=lastname eq 'Buchanan'") 
print("Lianja.OData_ReadHTML()")
print(response)	
 
response = Lianja.OData_ReadImage("/southwind/employees?$select=photo&$filter=lastname eq 'Buchanan'") 
print("Lianja.OData_ReadImage()")
print("size="+response.length)