Using IoC container in a multi-site environment - sitecore

I am setting up a architecture for a new project. For this project we are using Sitecore 7 CMS. As you may know, Sitecore supports a multi-site environement. This means that 1 IIS instance can be used for multiple sites because Sitecore resolves them to use the right code and content.
For this project I will have the following hierarchy:
Core (generic, site unspecific logic)
Website A
Website B
We should be able to add as many sites as we want. Every site has a Data, Business and Presentation layer.
I also want to use a IoC container such as Castle Windsor, Ninject or Unity. I want a generic container/kernel for the core and then I would like to be able to register class for specific sites. So the classes I register for Website A should not be resolved for Website B
In Unity I guess you could child containers. I did not find a good way to force the application to use the child container when the Sitecore Context meets a certain requirement.
In Ninject I found stuff on contextual bindings, named scopes and modules which I liked very much. I thought I create a NinjectModule with Contextual Bindings and on resolving I would check the context. I did not find a nice and generic way of doing this.
However, after hours of googling I did not find a good example or tutorial on how this could be achieved and how this should be done in the best way.
For now I do not have a preference for which framework I want to use.
Hope some one would shed some light for my problem so that I can make some progress.
Thanks in advance

Look in to Windsor's Handler Selectors. They're a nice solution to multi-tenant applications. Also, Mike Hadlow has a couple of posts about using Handler Selectors in a multi-tenant environment.

I resolved it by using Multi-tenancy in Autofac: https://code.google.com/p/autofac/wiki/MultitenantIntegration

Related

Looking for the right Tools for developing a website with SPA components in Django

i am a new Webdeveloper and im struggeling to find the right tools and frameworks to use for the specific site i am building.
Its a site for managing all kind of information and documents about clients my firm cares for.
It consists of general information (like statistics etc.) that should be served synchronously and a client specific part that should be a SPA (mainly because i want to have a list of all clients on the side, so that the main part of the page updates when you click one).
My problem is , that there is so much information about that kind of stuff (but not specificly a project comparable to mine), so that i can't decide what the best approach would be.
I found those options so far:
Just serve everything with django and update reactive parts of the page with Ajax
building a dedicated Frontend and with Frameworks like Svelte or React and using Django as API.
Using these Frameworks just for the critical components that have to be reactive and serving everything with django
If i understand correctly, the cleanest way would be Nr. 2, but i would lose access to djangos form rendering with crispy_forms (which, for a website consisting mainly of forms, would kinda suck).
The same is kinda true for Option 3 i think, since the critical Elements are mostly forms. And as far is i know you cant render django forms as react components.
I was discouraged from using Option 1, cause it seems to very error-prone to build a SPA without a framework.
I would really appreciate some input from more experienced People like me to help me with the decicion which path to go down.
Greetings!
There are many options, but it all depends on your knowledge and deadline.
Don't try to make everything perfect at once. Make an MVP using the technologies that you are familiar with and show the working version to the management. I'm sure there will be many edits and improvements that they will want to implement.
If you need an advise about stack, then you can look at Django + DRF + Vue.js

Architect admin interface for single page app

I have a single page app built with emberjs with an a rails backend. Is it a common pattern to build an admin interface on rails serverside on a subdomain. What is the right approach for this?
Your question is vague but I will try to answer it my best. I have done this with a Node and a Go backend combined with Ember.js.
No, there is technically nothing to prevent you from doing a single page application for an admin interface.
Rails is a good choice for this, and generally you should stick with the backend framework/language you and your team master the most.
As for what would be the right approach, there is no magic recipes. Document your code, write test and follow best practices for the tools you are using.
One key element though will be the communication between your frontend and your backend. Ember chose to follow the JSON API specification (http://jsonapi.org/) and comes out of the box with an adapter to talk with these kind of API. Using such adapter will help you save a lot of time.
Here are some implementation of JSON API for Ruby : http://jsonapi.org/implementations/#server-libraries-ruby
One more thing about your frontend code structure. You haven't say how big your app will be. If it gets big, you may want to take the pod approach in ember-cli (http://ember-cli.com/user-guide/#pod-structure). It basically changes the structure of the code so it's easier to maintain a lot of files.

Settting up or creating Mobile layouts on an exisiting site with ASPX+Portal Templates

We are currently on Kentico EMS V.7 but when our site(s) was created there was not any mobile device layouts setup. an out entire site is build around ASPX+Portal templates so we don't have the edit layout option on our pages. What would you recommend an origination like ours do in this case? Is there an import or migration tool that can be used to move the pages into a responsive design template (are these available out of the box or do they all need to be built?)
has anyone else come against this challenge with their site when trying to a mobile accessible site, if so what approach did you take to move your site(s) over?
I know Stackoverflow doesn't like to answer broad questions, but I'll save you some trouble and hopefully at least point you in the right direction. I use to be in your shoes and I remember how frustrating it was trying to find resources to learn all of this.
You've got some options, but unfortunately none of them are magic bullets. All of these options involve design and development time. If you haven't already done the research to consider if optimizing your site for mobile users is a good business decision, then I would suggest starting there first.
Mobile Device Detection
Kentico offers device layouts that allow you to change the layout of your site depending on which device a user is browsing your site with. The technique it uses is called device detection, which relies on reading the incoming user agent string of the user's http request on your server and using that information to determine what to send back to the user's browser.
This process happens on the server side of your application and also relies on comparing the user agent string against a list of known user agent strings. Kentico in particular uses the 51degrees library to accomplish this. This has the drawback of not always having the most up-to-date user agent strings, so new devices won't be included in your list unless you keep it updated.
A big problem with this approach is that you wind up maintaining multiple sites and/or layouts. If you uses Kentico's mobile device detection, then any time you need to make changes to a page template you will also have to change each of the different layouts for that template.
You don't have to utilize Kentico's device layouts functionality to do mobile device detection. You could just redirect users to a different site entirely. In which case you can still very easily run into the problem of redundant maintenance.
Yes, there are ways of mitigating these issues, but most web devs agree that responsive design is usually the way to go if you want to cater to mobile users.
Responsive Design
This is a client-side design paradigm that relies on CSS media queries. I'm not going to explain how it works since googling "responsive design" will net you plenty of research material. The short version is your user's browser handles the adjustment of the layout by interpreting the CSS of your site. This means you maintain one CSS file for one site and the client handles the adjustments for you.
Now the down side to this is that it takes a takes a talented web designer to do it properly. There are many responsive frameworks out there that can help you out with this, but their appearance is pretty generic and will likely still require customization to fit your particular brand requirements. Some more popular ones are bootstrap, semantic-ui, and foundation.
I recently helped convert a large website in Kentico with a static design into a responsive design by rebuilding all of the page templates using Bootstrap and merging their stylesheets together so that the desktop version still looked the same and the mobile versions had a consistent appearance with the desktop version. This process took about two months and required a lot of UX and content strategy in addition to visual design and coding skills to accomplish correctly. It's not the hardest job in the world, but requires quite a bit of skill and time to do.
In my humble opinion there is no tool which will make (magically) your site responsive. AFAIK the only way is to redesign your site manually (new CSSs - maybe any UI framework, JS etc...)
Maybe you can still use out of the box features like device profiles and mobile pages. (But I am not sure how it works and if it is supported while using ASPX + Portal templates development models).

Suggestion for Approachs to Develop Multi tenant Django Proj on Google App Engine

I was hoping to get some suggestions on some best approaches to develop a multi tenant Django project on Google AppEngine.
Some Thoughts to Consider.
I would assume using djnago.contrib.sites is a must.
I would like to use existing applications such as django-profiles and django-registration, I know their models would need porting.
Can multiple domains be pointed to the GAE App and the site be automatically chosen from the request headers?
IF not multiple domains, is there a way to say take a request say to www.example.com/tenantA/login and www.example.com/tenantB/login and push them to one view but with knowledge tennant without changing all the views, maybe using custom managers to hide the complexity from the views.
Generally hoping this will be a discussion of any approaches you have taken in the past or plan to take.
Looking forward to any Comments/Answers.
Regards
Mark
I can answer the App Engine questions for you, though I don't know the Django ones:
Yes, anyone can point a domain to your app using Google Apps, with the 'add services' option, entering your App ID when prompted. You can then check the 'Host' header to determine what site you want to use.
You can hide information per-tenant by using hooks to automatically insert the host in entities and queries: http://code.google.com/appengine/articles/hooks.html
Today Google released SDK 1.3.6, which includes multi-tenancy baked right into the solution.
http://googleappengine.blogspot.com/2010/08/multi-tenancy-support-high-performance_17.html

Web technology for a first small web project

I'm a C++ developer with basic Python skills. Here's the task, a friend of mine is running a small company and he asked me if I can make a website for him. I have no real deadline so I think it's a perfect opportunity to try sth new and do some web development.
User has to be able to add photos, change texts ect.
Do you think that Django would be an overkill for this kind of project? I have no experience with it. Perhaps I should try to customize some blog engine or Google Sites?
You may be interested in Google App Engine (http://code.google.com/appengine) which recently exhibited a rise in popularity. The application runs on Google's servers, eliminating the need to maintain Apache and worry about up-time. You basically get a Django-based solution with a data store, with an SDK which allows you to conveniently develop an application on your desktop and then upload it to appspot.com for everyone to use.
The documentation is great, and even if you eventually decide not to use it, the tutorial is excellent for getting you up to speed on Python and webapp design. There is also a codelab which contains a simple Wiki example.
If you need to set up quickly a very simple website, Wordpress can be the perfect choice.
Wordpress is born as a blogging platform, but in the newer version you can manage pages, contact form and so on. And you can find good plugins to expand its capabilities.
The administration interface of wordpress is clean and easy to use, the page or article editor is simple and powerful. Add an image in a post or in a page is easy and intuitive as in no other opensource CMS I've seen.
Django is a pretty flexible framework, it tends to scale well both up and down. It may be overkill to have to learn the whole API for just a simple site, but if you're looking to learn something new, and have some time to spare, then it's a fun platform to learn and work from. My suggestion would be to install the API and have a play around with it, read the Django book and see how you get on.
Maybe before diving into Joomla or Django a first step should be working with the technologies in a raw, pure way. Create a simple web page that excutes some server side script (python? php?) that retrieves data from a mySQL database and displays it. Throw in a little javascript too. Just so that you feel comfortable with the bare-bones fundamentals.
Then when you dive into the big frameworks and libraries, they won't seem so magical.
If you're really asking what the best tool for the job is, then you are going to have to give a little more detail than "first small web project." If what you are asking is more along the lines of you want to learn web application development and what you already know is C++ and python so what would be a good web application stack where you can leverage your current skillset, then here are some more suggestions.
Django is pretty cool. Every one has already talked about it here. As mentioned earlier, the google app engine is sort of based on Django.
Also, consider zope which is another python based web application container.
If you wanted to leverage your C++ knowledge instead, then consider Wt.
Why don't you take a look at the hello world examples for all three and decide which one looks the most interesting to you?
There are a multitude of website frameworks and kits that you could go with as opposed to starting development work from the ground up. It really depends on what kind of technology you want to go with, and how comfortable you feel with the language's potential. As mentioned above, there are things like Joomla, and If you want to stick to PhP frameworks, you could also use Drupal, which has a ton of documentation and support, and is relatively easy to understand.
If you want to venture into the Microsoft realm, you could look into DotNetNuke. It too is much like Drupal and Joomla, so it's a nice CMS framework, which you might feel more comfortable with since ASP.Net is based off of a programming language as opposed to a a scripting language, unlike Classic ASP or PhP. If you're going to go the Microsoft route, I also recommend taking a look at their BizSpark developer program - but that's more dependent on how serious your friend is on running his site as a business.
Then you also have a lot of things offered up by Google, such as their charts and visualizations -- which doesn't seems like something you're looking for, but for future reference, or cool little things like a map mashup.
It really depends on how much you're willing to learn and how much time you have and sometimes not having a rough deadline is the worst possible thing that could happen. Naturally everything starts to take longer. By the time you're done, the tech is either out of date, or you've taken so long that the business plan has changed.
using django it is easy, there is already an application for photo albums available at http://code.google.com/p/django-photologue/ it becomes with tagging too and maybe you just need to add some jquery effects to get done your site.
To get this done you just create a django project, add the applications to your settings, configure your urls and templates, and thats it.
Also i f you need a small version you can just use this code as a base of your new app.
have fun with django!!
sergio
Pylons is an excellent Python web framework based on WSGI standard. It has ported many of the features of Ruby on Rails so is great for rapid development.
I've been using it for a few years now combined with SQLAlchemy for my database layer and I've found it perfect for development of all my web sites.
It is easily good enough for production sites too.
The one downside I've found is slight complications getting it deployed on shared hosting but as long as you have shell access to your host, you should be fine.
You may try to install and customize Joomla (http://www.joomla.org/) It's full of stuff, easy to use and easy to customize also.
Everybody reaches for a framework, but, assuming this is running on Apache, why not just server side includes, and, since you have Python experience, Python CGI scripts that emit JSON for use in the UI by Javascript. By going with CGI/SSI you defer your decisions about framework and/or templating system until later, when you have more experience under your belt, but you should be able to get a reasonable amount of re-use of whatever Python code you write.
I'll cast my vote for Drupal (http://www.drupal.org)
I think LOVDbyLess might do exactly what you want. If all you need is basic blog and photo upload and a simple SNS, then check out this Ruby-on-Rails open-source thing. It's been evolving with new features and is pretty easy to set up.