Kohana event system in Erlang? - frameworks

I want to implant a framework in Erlang that is similar to Kohana event system. Anyone know how to do that or have any idea? I really like how Kohana is structured.
EDIT
The Kohana event system have been documented here : http://docs.kohanaphp.com/general/events . If I understand it correctly, I can replicate Kohana in Erlang like this:
kohana.erl
event.erl
router.erl
profiler.erl
[system (a directory)]
ready.erl
routing.erl
execute.erl
post_routing.erl
404.erl
pre_controller.erl
post_controller_constructor.erl
post_controller.erl
send_headers.erl
display.erl
shutdown.erl
log.erl
redirect.erl
I'm not sure whether this is better than Python wsgi like Django middleware and there is already ewgi for Erlang. I just want to make a framework for fun. I'm more familiar with Kohana 2 but interested in implanting HMVC or Kohana 3 for erlang.

Basically the event system in kohana is just a collection of functions/methods to run at a future point in time. I don't know anything about Erlang, but if you can write a collection class, and put function/method callbacks into it, it should be trivial to port the event system over.

Related

angular with MongoDB and Play Framework

I am learning Angular. I am struggling to understand how to use Angular2 and MongoDB together. Some tutorials refer to using Express.js. I'll prefer to stick to 4 technologies- Angular, Play, Scala and Mongdob ( I want to avoid learning another new framework).
Without Angular, I know how to store/retrieve data in Play using Reactive Mongo (data being sent to server as JSON, backend application in Scala). However, if I make the frontend in Angular, I guess I should make a service to handle database interaction. My doubts are:
1) When should I connect to the database? It doesn't seem wise to connect to database for each service API call
2) If my connection to database drops, how would my application know?
3) the communication with the database should not be blocking. How do I handle this? I guess there would be some 'Promise' somewhere but I do exactly know how to use it
If any backend programming is required, I'll like to use Scala instead of Java

How to use a RESTful API as ORM in CakePHP 3?

In CakePHP 1.x/2.x, it was fairly simple to have a model's data come from a REST API (as opposed to a relational database), by defining a custom datasource. (Neil Crookes' CakePHP-ReST-DataSource-Plugin was a great place to start.) Slap your custom datasource on your model, and you're making calls like $this->MyModel->find() just like you were querying a MySQL table called my_models.
I'm trying to figure out how to achieve this same effect under CakePHP 3.0. That is, make find()/save()/set()/get() calls against a Table/Entity driven by a REST API.
Since 3.0's ORM system is A) fairly new, and B) a rather large departure from the old way of doing things, I haven't found any information about how to do something like this. In fact, based on this SlideShare from
José Lorenzo Rodríguez, it sounds like it might not be possible.
This means:
not going to connect to stuff that is not a relational database.
Is there someone more familiar with CakePHP 3.0 that could clarify if what I'm looking for is possible under the new ORM system? If so, could you explain what classes you'd have to extend or implement to achieve such a function?
If you want to create a complete adapter for your Rest datasource using the interfaces and classes provided by CakePHP, take a look at this early experiment fro the CakePHP team on making a datasource for Elastic Search.
Elastic Search uses a Rest API and this plugin attempts to create classes that work similar to the CakePHP ORM:
https://github.com/cakephp/elastic-search
What it implements is basically the following:
A Type class that implements the RepositoryInterface
A Document class that implements the EntityInterface
A Query class that can be used as a collection object and has similar methods
In the near future it will provide a paginator adaptor and a form helper adaptor.
If you want to save yourself this trouble, because there for you there is little value in exposing your datasource as something ORM-like, you can just use guzzle or any similar library to interface with your API and use it as a service instead of a full-blown layer.
In the year since I asked this question, UseMuffin has built a Webservice plugin that purports to "bring [...] the power of the CakePHP ORM to your favourite webservices." This sounds like exactly what I wanted at the time.

Creating a Custom Entity Framework for Unsupported System

I could be totally misunderstanding Entity Framework here. I want to use that in my latest project (how else do you learn?) The problem is that the IBM i driver doesn't have support for that built in. Is is possible to create that framework from scratch? It is worth it?
It sounds like you'd be writing your own ADO.NET data provider to connect to IBM DB2 for i. Microsoft provides documentation for creating your own provider and a sample.
The data provider would be responsible for communicating with the database, so I'm not sure how you'd accomplish that. Either you'd be implementing your own connection to the database server running on the i (maybe you can port the SQL piece of JTOpen), or you'd be delegating your calls to the IBM-provided data provider (if that's even possible) or other data access method.
I couldn't decide whether I thought this was (1) a huge pain in the butt or (2) an opportunity for an open source project. (I guess it could be both.) It seems like it'd be easier to lobby IBM to make this part of their stock provider. You might complain about it on MIDRANGE-L and see if people will take up the cause.
Disclaimer: I am a newbie in the .NET world, so maybe there's an easier way to accomplish what you're trying to do.

Need advice on removing zend framework dependency

I'm in the middle of converting an existing app built on top of zend framework to work as a plugin within wordpress as opposed to the standalone application it currently is.
I've never really used zend so I've had to learn about it in order to know where to begin. I must say that at first I didn't think much of zend, but it's funny because the more I understand how it works the more I keep questioning why I'd want to remove dependency when it's a clearly well thought out framework. Then I'm reminded that it's because of wordpress.
Now I already know there are WP plugins to make zend play nice with WP. In fact I'm aleady using a zend framework plugin just to get the app functional within the WP admin area which is allowing me to review code, modify code, refresh the browser, review changes, debug code, again and again.
Anyway, I really don't have a specific question but instead I'm looking for advice from any zend masters out there to offer advice on how to best go about a task like this one.... so any comments, advice, examples or suggestions would be super.
One area I'm a little stuck on is converting parts of zend->db calls to work as wpdb calls instead... specifically the zend->db->select.... not sure what to do with that one.
Also on how to handle all the URL routing with automatic calls to "whatverAction" within thier respective controllers files.
Any help would be great! Thanks
You're probably facing an uphill battle trying to get some of the more major components of ZF to work in harmony with Wordpress. It sounds like you've got a full MVC app that you're trying to integrate into a second app that has very different architecture.
You probably want to think about which components handle which responsibilities. Wordpress has it's own routing and controller system that revolves around posts, pages and 'The Loop'. This is entirely different from Zend's Action Controllers and routing system.
It's possible you could write a WP hook to evaluate every incoming request and decide if it should be handled by WP or a ZF controller. However, it is doubtful you would be able to replace WP's routing system outright with ZF's or vice versa.
Same idea, where Zend_Db is concerned. There's nothing stopping you from using Zend_Db to access Wordpress's database, but trying to somehow convert or adapt Zend_db calls into wpdb calls sounds painful. If you have a large model layer, you probably want to hang on to it, and find a way to translate data from those models into the posts/pages conventions that Wordpress uses.
Personally, I would use ZF to build a robust business layer that can be queried through an object model via a Wordpress plugin, and then rely on Wordpress to do the routing and handle the views.
Zend_DB_Select is simple SQL query (but created using objects) that can be used like any other query. Just turn it into string. Ex.:
mysql_query((string)$zendDbSelectObject);

Modifying Request/Response Streams in WebBrowser Control Using MSHTML

I need to find a way to get at the request/response streams inside of the webbrowser winforms control and see that it's not real intuitive. For example, I need to be able to modify post data when a user clicks a submit button. It looks like you have to register for some MSHTML COM events to do so, but am unsure which I need to subscribe to (and how). Has anyone done this in the past? Examples?
Take a look at Asynchronous Pluggable Protocols (IInternetProtocol):
http://msdn.microsoft.com/en-us/library/aa767743(VS.85).aspx
And a solution in C# that uses some of it for its own protocols in IE:
http://www.codeproject.com/KB/aspnet/AspxProtocol.aspx