go to post Timothy Leavitt · Oct 17, 2022 Not sure if this is what you're getting at, but one of the most exciting and unique things about ObjectScript is how natural it is to do metaprogramming (in the sense of writing ObjectScript that treats other ObjectScript code as data). Because all of your code is in the database, you can work with it from an object or relational perspective - see the %Dictionary package. There are to main ways of doing this: generators and projections. A generator produces the actual code that will run for a method or trigger in a class at compile time, typically based on the class definition. A projection adds side effects of compiling/recompiling/deleting the class (e.g., updating a global with metadata about the class, creating + queueing compilation of other classes). isc.rest has a lots of examples of both of these; here's a representative sample: %pkg.isc.rest.handlerProjection does a bunch of SQL/object updates to data after compilation %pkg.isc.rest.handler (which uses that projection) has a CodeMode = objectgenerator method that fails compilation of subclasses if certain methods are not overridden. %pkg.isc.rest.model.action.projection creates a separate class with dependencies on other classes properly declared and queues it to be compiled. The class created extends %pkg.isc.rest.model.action.handler which defines some methods with CodeMode = objectgenerator, though a separate class does the actual work of code generation.
go to post Timothy Leavitt · Oct 17, 2022 Here's the article: https://community.intersystems.com/post/reflection-cach%C3%A9
go to post Timothy Leavitt · Oct 6, 2022 Glad this was the first Google result for "docker required linux capability is missing"
go to post Timothy Leavitt · Oct 5, 2022 @Eduard Lebedyuk if you say zpm "install packagename" and you already have the latest version installed, it'll just reinstall the same package (rather than doing nothing, which is what Ron wants).
go to post Timothy Leavitt · Oct 5, 2022 @Ron Sweeney this seems like a good use case to define your own package with dependencies for the things you want to "install if not already installed" - installing your package will install those dependencies only if they haven't been installed. (And if the versions update, they'll be updated.) Alternatively, you could do something like: if '##class(%ZPM.PackageManager.Developer.Module).NameExists(packagename) { zpm "install "_packagename }
go to post Timothy Leavitt · Sep 19, 2022 Hard for any language to beat: ClassMethod makeComplement(d As %String) As %String { q $tr(d,"ATGC","TACG") }
go to post Timothy Leavitt · Sep 13, 2022 Not great around edge cases, but this passes the tests at least (and might beat a $find-based approach since it avoids set commands): ClassMethod findShort(s) As %Integer { f i=1:1 ret:$locate(s,"(^| )\w{"_i_"}( |$)") i }
go to post Timothy Leavitt · Sep 7, 2022 If the thing you're working with is actually some sort of configuration data then this is probably a good approach. If not then building your own integration to transmit the data is probably better.
go to post Timothy Leavitt · Sep 7, 2022 Why? This sounds like HealthShare; maybe using the Configuration Registry would be the right fit. See: https://docs.intersystems.com/hs20221/csp/docbook/DocBook.UI.Page.cls?KE...
go to post Timothy Leavitt · Aug 31, 2022 ... ended up answering my own question in less time than it took to write it up. Solution (which might just be a workaround) is to force the content-type on the response to be application/octet-stream: do inst.stream.SetAttribute("ContentDisposition","attachment; filename="""_inst.stream.GetAttribute("FileName")_"""") do inst.stream.SetAttribute("ContentType","application/octet-stream") set %response.Redirect = "%25CSP.StreamServer.cls?STREAMOID="_..Encrypt(inst.stream.GetStreamId())
go to post Timothy Leavitt · Aug 15, 2022 @Eduard Lebedyuk it depends on the caller. In a CI process I could imagine doing different error handling for failed compilation vs. failed unit tests, this would be a way to signal those different modes of failure. I've taken/seen approaches that are more shell-centric vs. more ObjectScript-centric which would be a driver for this being useful. With the package manager it's generally simpler to wrap things in <Invoke> or resource processors and then call IRIS with individual zpm commands (i.e., load then test) from CI. For some of my pre-package manager CI work we've had a big ObjectScript class that wraps all the build logic, running different sorts of tests, etc. In this case it would be useful to indicate the stage at which the failure occurred. Regardless, $System.Process.Terminate is simpler to manage than "flag files" for sure, which would be the next best alternative. (IIRC in old days, maybe just pre-IRIS, there were Windows/Linux differences in $System.Process.Terminate's behavior, and that led us to use flag files.)
go to post Timothy Leavitt · Aug 12, 2022 It's not exactly straightforward. See https://github.com/intersystems-community/zpm/blob/master/src/%25ZPM/Pac... for an example of how to work around it / get the answers you need.
go to post Timothy Leavitt · Aug 12, 2022 @Michael Davidovich , try this: Do $System.Process.Terminate($Job,<desired error code>) See e.g. https://github.com/intersystems-community/zpm/blob/master/src/%25ZPM/Pac...
go to post Timothy Leavitt · Jul 21, 2022 select 1672185599,CONVERT(TIMESTAMP,CAST(1000000 * 1672185599 + POWER(2,60) As POSIXTIME)) Quite intuitive.
go to post Timothy Leavitt · Jul 20, 2022 On further investigation, it seems that what I need just isn't in the old version I'm running.
go to post Timothy Leavitt · Jul 20, 2022 Yes - see Security.Users (class reference) in the %SYS namespace.
go to post Timothy Leavitt · Jul 6, 2022 Thank you Dan! The index/constraint distinction and SQL standard context are particularly helpful facts for this discussion. :)
go to post Timothy Leavitt · Jul 6, 2022 There would still need to be some enforcement of the super parent being the only node with a NULL parent (and the point here is that the unique index wouldn't do that). Also finding all of the top-level nodes (assuming we could have multiple independent trees) would be a slightly more complicated.