Dmitry Maslennikov · Aug 17, 2016 go to post

As I see you a talking about Ensemble REST service. In this case I am not 100% sure, I think pInput only contains some binary data, or json. But forms data any should be available with %request.

Dmitry Maslennikov · Aug 17, 2016 go to post

So, you had to start with such explanation.

Well, does not matter what do you set in Accept header, if you don't use it by yourself. Like, you should check incoming content type and send an error if it is not accepted. This Header change nothing in incoming data,  if data was sent in another format.

To read data, you should know that %request has three different ways for getting data. You have already known in %request.Content, which usually contains binary streams. Then %request.MimeData, and %request.Data, it is a Multidimensional properties, and %request has some getters for them, %request.GetMimeData and %request.Get. MimeData, needs when client send data in multipart mime format, such as several files or so on. And %request.Data, in all most cases, and you should look at this property and method %request.Get("somename")

Dmitry Maslennikov · Aug 17, 2016 go to post

Well, in this case you should set Header Accept, with needed one or more formats, more info in wiki

set %response.SetHeader("Accept","text/plain")
Dmitry Maslennikov · Aug 17, 2016 go to post

If you use %CSP.REST, you can set needed ContentType in any called method

XData UrlMap
{
<Routes>
  <Route Url="/text" Method="GET" Call="GetText" Cors="false" />
</Routes>
}

ClassMethod GetText() 
{
    set %response.ContentType="text/plain"
    
    write "test"
    
    quit $$$OK
}

and test

➜  ~ curl -v http://localhost:57774/api/app/text
*   Trying ::1...
* Connected to localhost (::1) port 57774 (#0)
> GET /api/ambulance/text HTTP/1.1
> Host: localhost:57774
> User-Agent: curl/7.49.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Wed, 17 Aug 2016 17:54:28 GMT
< Server: Apache
< CACHE-CONTROL: no-cache
< EXPIRES: Thu, 29 Oct 1998 17:04:19 GMT
< PRAGMA: no-cache
< CONTENT-LENGTH: 4
< Content-Type: text/plain; charset=utf-8
<
* Connection #0 to host localhost left intact
test%
Dmitry Maslennikov · Aug 17, 2016 go to post

if you need add a string, you should concatenate it with operator _

+ converts all types to number, and doing arithmetical operator add

7_"" became "7"
+"5apples" became 5

Dmitry Maslennikov · Aug 17, 2016 go to post

because + is an operation for numbers, and yes, answer is correct, because 5 + 7 is 12

if you expected to see "5apples7 orange", in this case you should use concatenate operator "_"
write "5apples" _ "7 orange"

Dmitry Maslennikov · Aug 17, 2016 go to post

Macro is $$$. Anyway, a little excerpt from documentation  

$
 

Dollar sign (36): Intrinsic (system) function prefix: $name(parameters).

Special variable prefix: $name.

$Znnn (a name beginning with $Z) can be a user-defined function or special variable defined using %ZLANG language extension library. It can also be an intrinsic (InterSystems supplied) function or special variable.

Regular expression end of string anchor; for example, (USA)$.

In ZBREAK debugging, a single-step breakpoint.

As first character at terminal prompt, load interactive subshell.

$$
 

Double dollar sign: Extrinsic (user-written) function prefix: $$name(parameters). $$ is returned by $STACK when context was established by an extrinsic function reference.

Prefix to a routine name to directly invoke that routine.

$$$  Triple dollar sign: Macro invocation prefix.
Dmitry Maslennikov · Aug 16, 2016 go to post

What do you mean by dynamic sessions ?
Web sessions in Caché only two types, preserve or not. Preserve just keep working in the same process, for all request in this session, and keeps every locks. By default sessions, instead, only keeps data in %session.Data, and release locks after end of request.

Dmitry Maslennikov · Aug 10, 2016 go to post

You can do it as in any CSP page/class. With %request, which is object of class %CSP.Request

And headers available in property CgiEnvs, where every http header appear with a prefix HTTP_

So, you may try this code.

set ipCountry=%request.GetCgiEnv("HTTP_CF-IPCOUNTRY")

Unfortunately in times when web-applications prevail other types of applications this approach is cannot be widely used. This way can't be used directly in CSP, because of by default any session could be joined to any process, but Procces-private globals is not session-provite globals. And If you need to have such functionality with CSP, you should use Preserve sessions or use something like Sessions-private global, something like this

^CacheTemp.SomeTableD($select($isobject($get(%session)):%session.SessionId,1:$job))

Good article, but unfortunately I don't see the answer for last part for the question "How can I minimize the phenomena?"

So, in my practise, such behavior, in most cases related with some application's buffer globals, or logging globals. And mostly  we don't need in this journal, because it is not important part of our data, and we should not spend important resources for doing this. And we can cut off journalling for such globals. There are some ways to do it: 

  • Remap such globals to another database with disabled journaling. But this way has some exceptions, any changes in transactions, should be journaled in any way.
  • Use ENABLE^%NOJRN to disable journaling non-transact changes, and return back with DISABLE^%NORJN.
  • Remap to database CACHETEMP, which disabled for all changes, even in transaction.

As you have not showed full example of your code, I suggest that you use wrong class for fileStream.

For any text's you should use Character's stream, such as %Stream.FileCharacter, %Stream.GlobalCharacter

In this case you can use windows tool SC, to get information about services. 

and to work with SC, you can use $zf(-1), and it will looks something like this

set result=$zf(-1,"sc query messenger | FIND ""STATE"" | FIND ""RUNNING""")
if result'=0 write "Service messenger is not running"

GlobalsDB, no more developing, thats why this site has some issues.

You may find you answer in this exactly the same question, asked few days ago

All replacements for different $zu you can find here

so, in case with $zu(49), you can get such information with class SYS.Database, and it's not delimited now, and has properties

In this case, for $match you should define regex which match full given string, so it could looks like

write $Match("Find String ABC",".*(abc|ABC).*")
1

or you can use $locate, which returns position for first matched string

write $locate("Find String ABC","abc|ABC")>0
1
Dmitry Maslennikov · Jul 26, 2016 go to post

You should know, that namespace it is a just definition in which databases stored some types of data, and how it mapped.

So, you can only check in which database package stored

write ##class(%SYS.Namespace).GetPackageDest("SAMPLES","%Activate.Enum")
^/opt/cache/mgr/cachelib/

delimited output, first part is a system like in ECP-configuration, and second part is a database path

you can compare this path with default path for packages in this namespace.

w ##class(%SYS.Namespace).GetPackageDest("SAMPLES","")
^/opt/cache/mgr/samples/
Dmitry Maslennikov · Jul 26, 2016 go to post

Sure, thats needs because this variable should be available in any place for this process, just because this code executes in context where works any output commands like write

Dmitry Maslennikov · Jul 22, 2016 go to post

You have two cases, you change storage definition or you can use calculated value. But in case with calculated value, you have two options. It's an object's access and sql access, and such getter it is just only for object's access. For SQL you should define SqlComputeCode. Something like this.

Property Invalid As %Library.Boolean [Calculated, SqlComputed, SqlComputeCode = { s {*}={+$G(^GLOBAL({Code},"INVALID"))} }];

more details in documentation

Dmitry Maslennikov · Jul 22, 2016 go to post

$zhex
hex to dec

write $zhex("99")
​153

and back, dec to hex

write $zhex(153)
​99

be careful, hexadecimal should be a string and decimal should be a number

Dmitry Maslennikov · Jul 21, 2016 go to post

There are no particular recommended SourceControl systems. Everything depends on your choice.

Some time ago, with versions cache less then 2016.2 and before Atelier was appeared, we could use nothing except Studio. And in this case to work with particular SourceControl we should write own addon for Studio as a wrapper for this SourceControl. You can find one as a good example here on github, which works with GIT

Now, when we have Atelier, we could forget about this part, and use lots of available plugins for different SourceControl systems.

BTW, I prefer git, but most of time used SVN at work, and git for my own projects.

Dmitry Maslennikov · Jul 20, 2016 go to post

In case when you try to load this file via %Compiler.UDL.TextServices you should know this classname, and you can parse original file. But if it possible, better to use $system.OBJ.Load(), in this case you should not pass classname, only lodaded filename.

Dmitry Maslennikov · Jul 15, 2016 go to post

It's a right way, but don't you think, that you forgot to save your changes ? something like this

w rtn.%Save()

or you can just use $system.OBJ.Load("les.mac") or $system.OBJ.Load("some.class.cls") in versions 2016.2+
if you have less version but not less then 2014.1, you can load class with %Compiler.UDL.TextServices  as I've already offered to use it for export on stackoverflow

Dmitry Maslennikov · Jul 13, 2016 go to post

Every routines stores directly in database, so, you can't just open it as any file on your filesystem as well as you do it with csp files.

but you can open it with %RoutineMgr class, something like this

USER>zn "samples"

SAMPLES>set rtn=##class(%RoutineMgr).%OpenId("hello.mac")

SAMPLES>while 'rtn.Code.AtEnd { write !,rtn.Code.ReadLine()}
 
hello ; hello world routine
 write !, "hello world"
 write !, "bye"
end quit  ; end
 

if you also need to get list of such files, you can use query StudioOpenDialog in %RoutineMgr class

SAMPLES>set st=##class(%SQL.Statement).%New()
 
SAMPLES>set sc=st.%PrepareClassQuery("%RoutineMgr","StudioOpenDialog")
 
SAMPLES>set rs=st.%Execute("*.mac")
 
SAMPLES>do rs.%Display()
 
 
Dumping result #1
Name    IsDirectory     Type    Size    Date    Description     IconType
DocBook .       9                               0
badroutine.mac          0       62      2004-09-28 13:05:45             0
CinemaData.mac          0       10258   2016-05-10 22:32:04             0
compareloop.mac         0       1201    2004-12-02 18:23:57             0
datent.mac              0       3089    2002-01-03 12:05:01             0
datentobj.mac           0       2627    2002-09-06 00:15:23             0
dbconvert.mac           0       1532    2002-01-03 12:05:52             0
fibonacci.mac           0       365     2002-01-03 12:06:03             0
forexample.mac          0       502     2004-11-30 16:00:08             0
funcexample.mac         0       333     2002-01-03 12:06:30             0
hello.mac               0       251     2016-07-13 12:07:04.520803              0
LDAP.mac                0       68720   2013-12-16 11:48:09.962335              0
lookup.mac              0       8484    2008-08-21 19:17:48             0
lookup1.mac             0       1465    2002-01-03 12:07:15             0
lookup2.mac             0       5984    2002-01-07 18:08:46             0
lookupobj.mac           0       7857    2008-08-21 21:58:25             0
loopend.mac             0       242     2002-01-03 12:08:12             0
loopstart.mac           0       217     2002-01-03 12:08:21             0
nameloop.mac            0       552     2002-01-03 12:08:33             0
passbyref.mac           0       604     2002-01-07 12:01:47             0
postcond.mac            0       341     2002-01-03 12:08:51             0
procexample.mac         0       423     2002-01-03 12:08:59             0
publicvarsexample.mac           0       357     2002-01-03 12:09:09             0
RightTriangle.mac               0       1836    2011-02-24 18:56:29             0
root.mac                0       149     2004-11-30 15:57:29             0
simpleloop.mac          0       161     2002-01-03 12:09:59             0
SQLGatewayTest.mac              0       2480    2016-05-10 22:32:04             0
survivor.mac            0       179     2002-01-03 12:10:32             0
ZAUTHENTICATE.mac               0       37302   2015-03-10 10:48:43.589807              0
ZAUTHORIZE.mac          0       12120   2016-05-10 22:32:04             0
 
30 Rows(s) Affected