Gery Gerena · Mar 14, 2017 go to post

I have used this in order to call python code in the server, it calls bcrypt encryption in python.

Encriptar  Set password = "password"  Set tSC = ##class(EnsLib.JavaGateway.Service).RunCommandViaCPIPE("python -c 'import bcrypt; print(bcrypt.hashpw("_$c(34)_password_$c(34)_", bcrypt.gensalt(10)))'",.pDevice,.pOutput)  Write pOutput,!Quit
Gery Gerena · Mar 1, 2017 go to post

A simple example that you can follow is in the ENSDEMO namespace, the class is Demo.REST.MathService.cls
 

Gery Gerena · Mar 1, 2017 go to post

Is it possible?: Yes
Is it a good idea: No

Proof of concept of bad idea:

Class Rest.BadExample Extends %CSP.Page{Parameter CHARSET = "utf-8";Parameter CONTENTTYPE = "application/json";ClassMethod OnPage() As %Status{  Set String = "[ {code:1,description:'cat'},{code:2,description:'lyon'}]"  Write String  Quit $$$OK}}

As Eduard said, you should make your own class that inherits from %CSP.REST

Gery Gerena · Feb 24, 2017 go to post

What I finally did was use this form of $zconvert:

$ZCONVERT(tRS.%Get("description"),"O","UTF8")
Gery Gerena · Feb 23, 2017 go to post

It didn't work. I'm now investigating if the way that AngularJS handles the $http.get has to do with it.

Gery Gerena · Feb 22, 2017 go to post

Thank you very much Eduard!

The global made it work for the CSP files!

I'm outputting characters from the Rest Service. The locale I'm using is enuw however I tried changing it to espw but it didn't work.

This from System > Configuration > Locale Definitions

Gery Gerena · Feb 21, 2017 go to post

A new problem..

In my country we speak in spanish. My developing machine uses windows 8.1

I made a nice looking html mock-up using angular material (in Atom, writing in UTF-8). I just moved that mock-up to the CSP folder inside Ensemble and it shows the typical weird characters of character encoding problems.

Have you had an issue like this before?
My temporal solution for the html files: I just configured Atom to read the files in Windows 1252 encoding
However I still see weird characters on a query to the DB (I made a rest service that returns a json than in turn I use to fill a select input in the html)

Gery Gerena · Feb 10, 2017 go to post

I change the names of the files in order to do that, like this:

csp file:

<!DOCTYPE html>
<html><head><csp:include page="includes/libraries.csp"/><title></title></head>

inside the includes/libraries.csp file, rename the file as "jquery-1.11.3.min.js" instead of just use the file as "jquery.min.js" :

<script src="jquery/jquery-1.11.3.min.js"></script> 

this in order to avoid the server to load the old file

Gery Gerena · Feb 6, 2017 go to post

By the way, do you use a modern WYSIWYG editor? I used to use Microsoft Frontpage ages ago, and a bit of dreamweaver too

Gery Gerena · Feb 6, 2017 go to post

Thank you very much Sergey!

I have made a few examples with both Angular 1 and 2 and the final decision is: AngularJS (1) , because my team sees it more "mature".

However I want to use the component approach and also Material (https://material.angularjs.org/latest/)

Gery Gerena · Feb 3, 2017 go to post

Recently I stumbled upon the same problem, the need to use bcrypt from within caché. I did the following:

1. Install pip, the python package manager:
http://sharadchhetri.com/2014/05/30/install-pip-centos-rhel-ubuntu-debi…

2. Install bcrypt with pip

sudo pip install bcrypt

3. Call bcrypt from Caché Code. The Encrypted String is pOutput

BCrypt
    Set password = "password"
    set tSC = ##class(EnsLib.JavaGateway.Service).RunCommandViaCPIPE("python -c 'import bcrypt; print(bcrypt.hashpw("_$c(34)_password_$c(34)_", bcrypt.gensalt()))'",.pDevice,.pOutput)
    Write pOutput,!
    Quit
Gery Gerena · Dec 13, 2016 go to post

Thank you Sean,

I tried that, however the user still needs a couple of roles in order the Web Service to work:

%DB_ENSDEMO
%EnsRole_Developer

And with those roles, the user has access to Management Portal.

I need that it doesn't happen. I need that the user can't get into the management portal.