User-independent session data: is it implemented anywhere outside of Embperl? - perl

Preface
Normally, a session in a web application stores data for a specific user (and its data is available across any visit of the user to the same web server/site).
Embperl (a templated web development framework in Perl) has a very interesting feature: user-independent session data stored/retrieved at the level of individual web page (%mdat hash).
QUESTION:
Does a similar feature (user-independent "session" data accessible to all users' requests) exist in any other web development environments/stacks, either in precisely the same form (perl web page data) or somewhat similar?
I am specifically asking about a feature implemented/accessible as part of a web framework, not the obvious and easily done DIY solution of "well you can easily implement your own via a $backend_database_store with a key of the page URL" .
This is a purely theoretical question borne of my trying to find non-Embperl analogue to help explain Embperl's %mdat feature. I don't care which web development stack/framework the example is from, as long as it's not something totally obscure used by 3 people in the universe :)
Background:
This came about from trying to answer a recent Embperl question about %mdat hash; I tried to explain it by comparing it to some other feature in web development. I then realized that I don't actually KNOW any other framework with a similar feature. buit I'm sure on MUST exist :)

Yes, although it called "cache".
e.g. in Mason $m->cache will return your whatever object. even a %mdat if you like to.
http://www.masonhq.com/docs/manual/Devel.html#data_caching
Your "user-idependet session data", smells like cache, looks like a cache and reads like cache. Only missing some features - e.g. you can use $m->cache at every level of your application.

Related

Fully scalable website with micro-applications

I'm in the process of designing a cloud deployed website for a new solution my company is looking to provide. I have been attempting to answer a few questions and haven't had any luck, so when in rome.
First, I don't want the website to be stuck to any one particular framework. I know there is no way to completely future proof a website, but I would rather not put all of our eggs in one basket.
Secondly, I want to have a separation between the front and back end entirely. I have a list of reasons why I'm looking to do this, don't necessarily want to get into the conversation of what they are. Server Side rendering for the most part is out of the question.
So where does that leave me?
My initial thoughts on the design are to have a REST API that can be accessed for any API calls (this may be turned to GraphQL in the future).
The design decisions that I'm mostly wresting with are for the front end. The website will be a dashboard type system, where tenants can log in and see screens for them.
I was thinking that I would have a sort of shell, that hooks on to the index.html. This would have it's own routing, that would render micro-applications that are completely separate from the shell logic.
So for example, if I load index.html, path being "/"
It has some routes that it's responsible for, lets say
"/todos"
"/account"
If I accessed the /todos route, my shell application would then render that micro app. This application would be completely separate from the shell, except some data that might be loaded via the window. Once this application is rendered via the shell application.
So my todos route, for example, could be a redux application that's independent. It could have it's own routing, etc.
Is this is a common architecture? Are there any examples of this? Is there a better way of going about this?
Thanks for any insight!
Sounds like your well and truly over engineering this beast.
You may take on such an architecture for a HUGE build with many dev teams all working separately. Small agile team, the above would create so much overhead in boilerplate and brain ache in context switching between each "app"
Micro-service architecture is seriously great. Just don't break it up too small, read your use case well and break your services up accordingly.
For example: we are a team of 3. We have a pretty large-ish app devised into:
Php API
Backend management interface (redux)
Frontend website (html, react, php)
Search service (elastic search)
Cache (redis)
Data store (mysql)
All on running in multiple docker containers across multiple hosts. Pull down the backend.. Fine the frontend website is still up and running!

Online app backend with client-friendly online CMS

There are a ton of online CMS services out there. And a ton of (new) backend-as-a-service products too. But I can't seem to find what I am looking for.
I am building an app for a client. The app contains data about shops, products, and more. The client must be able to update this data (and not just one person: each shop manager needs to be able to log in and edit the data for their own shop). And of course the app must be able to access this data.
Client edits data online
This has to be extremely user-friendly and completely online. I don't want to sell my client something where they need to install stuff on their server. I don't want to sell them something that's accessible online but looks like phpMyAdmin.
I want a shop owner to be able to go to a webpage, log in, and then see a pretty UI where they can edit the data for their shop. The back-end needs to have a pretty front-end that's auto-generated for whatever data this particular shop owner is allowed to edit.
So there are two bits: storing data in the cloud in such a way that it can be accessed by the app (which I am building with Titanium), and allowing the client to log into the backend and edit the data in a non-tech, user-friendly way.
Here's a list of things I tried...
Backend-as-a-service
Services with a great back-end, but without easy auto-generated data editing website:
Appcelerator (Titanium) Cloud Service
Amazon EC2
Stackmob
BackBeam
WebVanta
Parse
API o Mat
ShepHertz Cloud42
Kii
Online CMS
Services that provide a nice way for clients to edit data, but no easy way for apps to connect:
CloudCMS
(and many others I'm sure)
It's insane that no-one seems to be providing the cross-breed of BaaS and online CMS. So many people are building apps for clients, and so many clients are not tech-savvy and are reluctant to get a special server and host database software they don't understand. Why does this not exist? What am I missing?
With apiOmat it's easy to create your own data-editing app for e.g. with JavaScript SDK and HTML. Or you send a feature request so that they build a module for your preferred CMS.
As you mentioned, Cloud CMS is a really good option (disclaimer: I'm one of the founders). The product provides an enterprise content management backend and an API that lets you plug in some really powerful features right into your mobile apps.
This month, we released a brand new user interface which provides much of what you're asking about. Instant forms, document libraries, search and workflow all in one place.
You can check out Cloud CMS here: http://www.cloudcms.com
I completely agree with your assessment particularly with respect to the last mile (getting the final app built). It's kind of the wild west out there and the strong technologies are still proving out.
You mentioned Titanium - that's a good choice. I also quite like the Ionic Framework (http://www.drifty.com/). It's a step in the right direction.

Acessing a wordpress database from an iPhone App

I've been asked to create an app that will get data back from a database where the CMS will be Wordpress. I've never used a CMS so I'm trying to get a (overview)picture in my head of how it could all work and what each of the components would be. And what a CMS actually brings to the party.
Creating the app itself is pretty clear. I've done a few already. I've made a database before and shouldnt cause a problem.
But what is going to be in the middle between the app and the database?
Part A:
I'm guessing iphone apps typically would call some php file that's hosted on the server? The php then would make a call to the database and return the data somehow, maybe as xml. But this is really basic and wouldnt require a CMS. Just a database and a phpfile, or am I wrong?
Part B:
If i wanted to run a check on the database every minute to see if any of the data in database was no longer valid and remove it if needed, that would require somekind of program running on the server. So that program would be Wordpress, since it is managing the content, so a content management system is actually needed and is for these kind of taskes. Am i understanding the role of CMS?
Many Thanks,
-Code
Part A: Yes, that's definitely how it would normally work. Of course, you're not accessing "a" database, you're accessing the database WordPress creates, but otherwise, sure.
Part B: The role of a CMS is to provide a structured, easily-edited way of presenting information. It abstracts both the database and the user interface stuff, allowing the CMS administrator to CRUD data via the use of simple forms.
In your case, no, you wouldn't (usually) ask the WordPress software to provide information because it's not set up to provide data that's programmatically requested. Instead it's designed to display HTML pages with the data embedded. The WordPress software is specifically for humans to CRUD the data through a human-friendly interface. You'd write your own, as in Part A.
This article shows some basic PHP for retrieving blog entries and user comments, likely most of what you'd want. The WordPress database format is well-documented: here's an article that lays it out and provides more PHP examples for retrieving the information.
Have a look how the Wordpress for iOS team is doing it:
http://ios.wordpress.org/development/
I would not try to access the db directly or through some custom php-code, but use the official WordPress API (which uses xml-rpc) instead.
and this xml-rpc objective-c library might even make this a pretty straightforward exercise?

How does Perl handle sessions differently from PHP?

I'm trying to clone a commercial Student Management System which was written in Perl. I want to use PHP, as I have no experience in Perl.
I am now trying to set up the login system, which should be (has to be?) done with PHPSESSID's, right? Now, in PHP I could transmit the Session ID via GET, POST, and COOKIE.
The Perl website doesn't add parameters to the URL (GET) and does not save cookies on my computer (COOKIE). There is also no form which could contain a hidden field (which would be POST in PHP, right?)
Can someone tell me how Perl remembers the logged in user there?
Perl takes a much more "toolkit"-based approach to building web applications than PHP does, because Perl was not designed specifically for web work. So it doesn't have any built-in way of doing web app session management; rather, there are many modules on CPAN which implement session management in many different ways.
If you were to identify the Student Management System in question and provide a URL, we might be able to look at it from the outside and identify what it's doing, but, really, I question whether you actually need to use the same session management system as the existing app unless you want to implement single-sign-on between the original version and your clone[1]. Concentrate on cloning the user-visible interface and functionality rather than the implementation details behind it.
[1] ...which would be futile anyhow unless you're also planning to tap into its session database on the back end, since neither one will recognize the other's session ids if they don't share that data.
For the sake of completeness, there are OTHER, non-standard ways to store/transmit session information than the 3 methods you listed (although I seriously doubt any of them are used in your SMS). Among them:
Sending the cookie data as part of the DOM (e.g. in HTML) and having on-page JavaScript access it from DOM
Or, just store the cookied data as JavaScript's data in the first place.
AJAX calls. E.g. the session-enabled logic is all handled in AJAX URLs and not the main URLs. Yes, I know that's completely screwy. But doable.
Don't store the cookie in main cookie database (so you can't find it using standard cookie viewing methods). For details on how that's done, please google "evercookie" for a VERY cool method of persistently storing cookie info by utilizing up to 10 redundant storage options - one good intro is http://blog.depthsecurity.com/2010/09/super-persistent-cookies-evercookie.html
All that said, I completely agree with Dave's answer - just use PHP's best practices mechanism to implement the functionality instead of cloning possibly-perl-specific and possibly-weird implementation in the webapp.

Wordpress custom pages CMS

I'm considering Wordpress as my CMS platform for a client site I'm doing at the moment.
However, I need to create a couple of custom 'modules'. One of these modules is a form that people will be able to complete and have a quote, and once submitted, in a special place in the Wordpress panel (like a menu or something), there will be a listing of all the submitted quotes (just fetching it from a table in my database).
Another one is to manage a cafeteria menu, so the client can add a different meal to each day of the week.
I know perfectly how to do this kind of things using some kind of MVC framework and doing it 'by-hand', but I'm just wondering if this would be possible to do with WP and if yes, what kind of tools I'll have to use.
Thanks
Quite simply, yes, WordPress would be a more-than-capable asset to your criteria. But it's whether the learning curve in getting to know WP outweighs using a framework you're clearly already familiar with?
Personally, it sounds you like you're pretty solid with PHP, and considering the fact that, in my opinion, what you're planning on doing is relatively easy, I'd say WordPress is an excellent solution.
I'd recommend reading about WordPress 3.0's new custom post type API, and skimming the basics of hooks and filters in the Plugin API.
Submitted quotes would merely be a custom post type. You'd be better off writing the front-end code (like handling the form, UI etc.) yourself, either within a theme or plugin, then using wp_insert_post and let WordPress handle all the database administration. In fact, WP will go one step further and set up the entire admin for viewing, editing and deleting quotes.
Post meta (also known as custom fields) is also there for you if you need to store additional information about a quote that doesn't quite fit the post's table structure.
For the menu, this is even easier. I'd say just create a post category called 'Menu', and the client can publish 'dishes' to it as you would with a blog or any similar rolling format.
I've only licked the surface here. Get stuck in with the above, then check out some other goodies like meta boxes and custom taxonomies!
If you want to try a plugin instead of writing something yourself, Flutter might work. It's a little unpolished sometimes but it makes this sort of thing an absolute breeze.