Saturday, December 25, 2010

Installing Django on IIS 7 Using PyISAPIe

  1. PyISAPIe is an ISAPI extension which can be downlod from here . Download the latest extension according to installed python version.
  2. Just make sure that ISAPI and ISAPI filters has been installed on IIS (During IIS installation these two component should have checked).
  3. Copy PyISAPIe.dll file and Http folder into your Django website project.Example:
    • Suppose your website folder path is: "C:\Python25\Lib\site-packages\MySite"
    • "C:\Python25\Lib\site-packages\MySite\PyISAPIe.dll" and "C:\Python25\Lib\site-packages\MySite\Http" will be the result.
  4. Copy and replace the isap.py from "PyISAPIe\Examples\Django" folder to "C:\Python25\Lib\site-packages\MySite\Http"
  5. IIS need to have access to your project folder and also django folder. so you need to give access "Network Service" to these folder.
    • Right click on site folder "C:\Python25\Lib\site-packages\MySite"  click on properties. On properties window choose the security tab then click on Edit then Add and choose the "Network Service"
    • Do the same procedure for the Django folder: "C:\Python25\Lib\site-packages\django"
  6. Edit the "isapi.py" file and set the DJANGO_SETTINGS_MODULE to your site settings file.
    • If  the setting file is"C:\Python25\Lib\site-packages\MySite\settings.py"  and site-packages is on your path then you should set: os.environ["DJANGO_SETTINGS_MODULE"] = "MySite.settings"
  7. Open the IIS Manager.
  8. Right click on "Sites" then choose "Add Web Site..."
  9. On "Add web Site" window fill the "site name" (an application pool with the same name will be created automatically).Set the "Physical Path" to your website folder in this example it will be "C:\Python25\Lib\site-packages\MySite". Set the Host Name an IP address then click "OK"
  10. On IIS manager at left tree click on "Application Pools" there is an application pool with the name of your site name. Right click on it and then choose "Advance Settings...". On this window just make sure that "Enable 32-Bit Application" has been set to "true" and also "Identity" property has been set to "Network Service". Click "OK".
  11. On IIS manager at left tree under "Sites"click on your website and on the center panel double click on "Handler Mappings". 
  12. On the right panel choose "Add Script Map..." a new window will be open.
  13. Set the "Request Path" to "*". Set the "Executable" to "PyISAPIe.dll" file in this example it will be"C:\Python25\Lib\site-packages\MySite\PyISAPIe.dll". Choose any name like "PyISAPIe" and then click "OK". A window will appear regarding adding the "ISAPI Filters" choose "OK".
  14. On the right panel choose the "View Ordered List...". Just make sure that the recently added isapi is above the "Static File".Otherwise, move the PyISAPIe so it locate above the StaticFile.
  15. "Stop" and then "Start"  the website and its Application Pool( Recycling on application pool is not working).
  16. Browse to your website and every should be fine.
Important!
  • Current version has been compiled on x86-32-bit platform. You need to install x86 python version so this extension can work. Otherwise, you need to compile it from source for 64-bit platform.
  • "Http" folder name is case-sensitive do not change the name.
Update

  • I have compiled PyISAPIe on 64 bit python 2.7. Files are available on this post to download.
  • For deploying  the 64-bit PyISAPIe.dll on IIS and django, after downloading the file, follow these instructions.
    1. Copy the folder to drive C.
    2. Give the 'Network Service'  permission  to the folder .
    3. From Example\Django copy the Isapi.py and DjangoMap.py to Http folder
    4. Edit the Isapi.py and add your website settings
    5. Now from IIS add the PyISAPIe.dll to Handler Mapping  as Script Map. Make sure on the ordered list view it is located at the top of list.
    6. On 'Application pools' advance settings make sure that "Enable 32-Bit Aplications" is set to False and "Identity" is Network Service.
    7. Do a recycle and enjoy!
For more information you can check out PyISAPIe project HomePage.

Tuesday, July 6, 2010

Glimpse of Ext js Containers

Container layout:
  • The Container layout is the default layout for any instance of Container and simply places items on the screen, one on top of.
  • Container layout does not explicitly resize child items.
  • It also serves as the base class for all other layouts
  • Implementing a container layout is extremely simple, requiring you to just add and remove child items.
Anchor Layout:
  • The Anchor layout is similar to the Container layout
  • It adds dynamic sizing to the mix using an anchor parameter specified on each child
{title : 'Panel1',
anchor : '100%,5%',
frame : true}

Form Layout:
  • The form layout is just like the anchor layout
Absolute layout:
  • Absolute layout is by far one of the simplest to use. It fixes the position of a child by setting the CSS “position” attribute of the child’s element to “absolute” and sets the top and left attributes to the x and y parameters
Fit Layout:
  • The ‘fit’ layout forces a Container’s single child to “fit” to its body and is, by far, the simplest of the layouts to use
  • The fit layout is a great solution for a seamless look when a Container has one child.
Accordion Layout:
  • The Accordion layout, a direct descendant of the fit layout, is useful when you want to display multiple Panels vertically stacked, where only a single item can be expanded or contracted.
  • One important to note that the accordion layout can only function well with Panels and two of its descendants, GridPanel and TreePanel. This is because the Panel (and the two specified subclasses) has what is required for the accordion to function properly. If you desire anything else inside of an accordion such as a tab panel, simply wrap a panel around it and add that panel as a child of the Container that has the accordion layout.
Card Layout:
  • In order to create a wizard-like interface, we need to create a method which we can control the card flipping
Column Layout:
  • Like the Anchor layout, the Column layout allows you to set the absolute or relative width of the child Components
  • Organizing components into columns allows you to display multiple components in a Container side by side.
  • The meat of the Column layout its onLayout method, which calculates the dimensions of the Container’s body
  • it first subtracts the width of each of the absolute-width child components from the known width of the containers body
  • Now that the Column layout knows exactly how much horizontal space it has left, it can set the size of each of the child components based on the percentage
HBox and VBox layouts:
  • behavior is very similar to the Column model
  • you can change the alignment of the child items both vertically and horizontally
  • ability to allow the columns or rows to stretch to their parent’s dimensions if required
  • to properly exercise the different layout configuration parameters for which we can specify two, pack and align. Where pack means “vertical alignment” and align means “horizontal alignment”.
  • The pack parameter accepts three possible values; start, center and end.
  • The align parameter accepts four possible values: ‘top’, ‘middle’, ‘stretch’ and ‘stretchmax’.
  • The last configuration parameter that we must explore is “flex”, which is similar to the columnWidth parameter for the columnLayout and gets specified on the child items
  • Lets say for instance, you would like each of the columns to have equal widths. Simply set each column’s flex to the same value, and they will all have equal widths.
The Table layout:
  • The table layout gives you complete control over how you want to visually organize your components.
  • Building a table of Ext Components however, is different as we specify the content of the table cells in a single dimension array, which can get a little confusing.
  • we set a layoutConfig object, which sets the number of columns with "columns :" property.
  • Often we need sections of the table to span multiple rows or multiple columns. To accomplish this, we specify either the rowspan or colspan parameters explicitly on the child items.
The Border layout:
  • The Border Layout made its d├ębut in 2006, back when Ext was merely more than an extension to the YUI Library and has matured into an extremely flexible and easy to use layout that provides full control over its sub-parts or “regions”. These regions are aptly named by polar coordinates: north, south, east, west and center.
ref: Ext Js in Action