Django and Pyjamas - Django and Pyjamas mariage as an
Transkrypt
Django and Pyjamas - Django and Pyjamas mariage as an
Ecosystem Django Pyjamas Django+Pyjamas Summary Django and Pyjamas Django and Pyjamas mariage as an alternative way to create Web Applications Pawel Prokop [email protected] November 24, 2011 c Copyright Pawel Prokop <[email protected]> Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction I’ll tell a story about some mariage... ...Django ...Pyjamas Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Part I: Introduction but first... Ecosystem Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary ECOSYSTEM hosting applications Database systems Mantaining Web application architecture . Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary ECOSYSTEM hosting applications Database systems Mantaining Web application architecture Hosted on server... Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary ECOSYSTEM hosting applications Database systems Mantaining Web application architecture ...and accessed from clients Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary ECOSYSTEM hosting applications Database systems Mantaining Web application architecture ...from many browsers Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary ECOSYSTEM hosting applications Database systems Mantaining Web application architecture ...and many operating systems Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary ECOSYSTEM hosting applications Database systems Mantaining Hosting applications (servers & frameworks) Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary ECOSYSTEM hosting applications Database systems Mantaining Database systems Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary ECOSYSTEM hosting applications Database systems Mantaining Upgrading... ...the server ...client not involved Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Part II: Django Django Ecosystem Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Who the hell is... framework written in python talks: python HTTP JSONRPC Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Philosophy Model - database objects Template - html rendering mechanism Viewer - bussiness rules Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Django installation Get latest official - stable version 1 2 3 4 wget h t t p : / / www. d j a n g o p r o j e c t . com / download / 1 . 3 . 1 / t a r b a l l / t a r x z v f Django −1.3.1. t a r . gz cd Django −1.3.1 sudo python setup . py i n s t a l l Get latest from repository 1 svn co h t t p : / / code . d j a n g o p r o j e c t . com / svn / django / t r u n k / d j a n g o _ t r u n k Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Verification Verify installation (from python console) 1 2 i m p o r t django django . g e t _ v e r s i o n ( ) Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Project creation Create project filesystem 1 django−admin . py s t a r t p r o j e c t m y p o r t a l Files created: ./manage.py ./myportal ./myportal/urls.py ./myportal/settings.py Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Create application Create application structure 1 python manage . py s t a r t a p p myapp Files created: ./models.py ./views.py ./tests.py Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Pawel Prokop Introduction Installation Model Templates Viewer Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Database create database manualy let django to generate database from django model Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Django model models.py 1 2 3 4 5 6 7 8 from django . db i m p o r t models c l a s s Users ( models . Model ) : l o g i n = models . C h a r F i e l d ( max_length =32) name = models . C h a r F i e l d ( max_length =256) a c t i v i t y = models . B o o l e a n F i e l d ( d e f a u l t = False ) e x p i r e = models . D a t e F i e l d ( n u l l =True , b l a n k =True ) passwd = models . C h a r F i e l d ( max_length =256) Built-in field classes: AutoField,BigIntegerField,BooleanField, CharField,DateField,DateTimeField, DecimalField,EmailField,FileField, FloatField,ImageField,IntegerField, IPAddressField,SmallIntegerField,TextField, TimeField,URLField,XMLField ...and more... Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Field arguments null - field can be null blank - field can be blank choices - choices will be displayed for field on admin panel db_column - customize column name db_index - create index for this field db_tablespace - defines name of tablespace default - default value for this field editable - specifies if field is editable via admin panel error_messages - allows to override default error message Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer ...field arguments, cont. help_text - specifies text that will be displayed next to field on admin panel primary_key - specifies if the field is primary key unique - specifies if the field is unique for the table unique_for_date - specifies DateField within this field should be unique unique_for_month - specifies month field within this field should be unique unique_for_year - specifies year field within this field should be unique verbose_name - defines verbose field name validators - allows to append custom validation method (this method should raise ValidationError) Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Populate model to database Populate model to database 1 python manage . py syncdb Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Customize model validate model 1 python manage . py v a l i d a t e display customized sql 1 python manage . py sqlcustom myapp display all drops 1 python manage . py s q l c l e a r myapp display indexes 1 python manage . py s q l i n d e x e s myapp display all 1 python manage . py s q l a l l myapp Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Adding custom sql Create ./myapp/sql/users.sql file that contains: 1 2 3 i n s e r t i n t o myapp_users ( l o g i n , name , a c t i v i t y , passwd ) v a l u e s ( ’ pablo ’ , ’ Pawel Prokop ’ , ’ t ’ , ’ ec222c5f42458e0b3e7505a689e223ba624aeb84 ’ ) ; Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Pawel Prokop Introduction Installation Model Templates Viewer Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Forms In application directory create file: credential_forms.py 1 2 3 4 5 6 from django i m p o r t forms c l a s s LoginForm ( forms . Form ) : l o g i n = forms . C h a r F i e l d ( ) password = forms . C h a r F i e l d ( w i d g e t =forms . PasswordInput ) Built-in field classes: BooleanField,CharField, ChoiceField,DateField,DecimalField, EmailField,FileField,IPAddressField, FloatField,IntegerField, MultipleChoiceField,ComboField, and more... Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Field arguments required - field is required and validation will fail label - defines display for the field initial - defines initial value widget - specifies a class to render this field help_text - text that will be displayed next to the field error_messages - allows to override default error messages validators - allows to append custom validation method (this method should raise ValidationError) localize - enables localization of form rendering Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Templates Create directory templates and put there all template files Let credential_template.html be like follow: 1 2 3 4 5 6 7 8 9 <html> <form a c t i o n = " / m y p o r t a l / l o g i n " method= " p o s t " > {% c s r f _ t o k e n %} { { loginForm } } < i n p u t t y p e = " submit " v a l u e = " Login " / > < / form> < / html> Update TEMPLATE_DIRS in settings.py Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Pawel Prokop Introduction Installation Model Templates Viewer Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Spin Model and Template with Viewer Create file views.py as follows: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 from from from from django . t e m p l a t e i m p o r t RequestContext , Context , l o a d e r django . h t t p i m p o r t HttpResponse django . core . c o n t e x t _ p r o c e s s o r s i m p o r t c s r f django . s h o r t c u t s i m p o r t render_to_response import credential_forms def index ( request ) : loginForm = c r e d e n t i a l _ f o r m s . LoginForm ( ) params = { ’ loginForm ’ : loginForm } r e t u r n render_to_response ( ’ c r e d e n t i a l _ t e m p l a t e . h t m l ’ , params , c o n t e x t _ i n s t a n c e =RequestContext ( r e q u e s t ) ) Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Append bussiness rule for login feature To views.py append implementation of login logic: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 def l o g i n ( request ) : params = { } i f r e q u e s t . method == ’POST ’ : loginForm = c r e d e n t i a l _ f o r m s . LoginForm ( r e q u e s t .POST) username = ’ Unknown ’ i m p o r t models user = models . Users . o b j e c t s \ . f i l t e r ( l o g i n = loginForm [ ’ l o g i n ’ ] . v a l u e ( ) ) \ . f i l t e r ( passwd= e n c r y p t ( loginForm [ ’ passwd ’ ] . v a l u e ( ) ) ) i f l e n ( user ) == 1 : username = user [ 0 ] . name params = { ’ name ’ : username } r e t u r n render_to_response ( ’ u s e r _ i n f o . h t m l ’ , params , c o n t e x t _ i n s t a n c e =RequestContext ( r e q u e s t ) ) Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer ...and one convenience method 1 2 3 4 5 def encrypt ( s t r i n g ) : import hashlib s = h a s h l i b . sha1 ( ) s . update ( s t r ( s t r i n g ) ) return s . hexdigest ( ) Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer ...and one more template Create template file: user_info.html in templates directory 1 2 3 4 5 6 7 8 9 <html> {% c s r f _ t o k e n %} <p> H e l l o : { { name } } <p> <a h r e f = " / m y p o r t a l " >Go Back< / a> < / html> Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer ...and create interface Add the following to myportal/urls.py 1 2 ( r ’ ^ m y p o r t a l / $ ’ , ’ myapp . views . i n d e x ’ ) , ( r ’ ^ m y p o r t a l / l o g i n $ ’ , ’ myapp . views . l o g i n ’ ) , Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Model-Template-Viewer Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Installation Model Templates Viewer Let’s Rock Launch django server 1 python manage . py r u n s e r v e r Launch the browser and type: http://127.0.0.1:8000/myportal Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets Part III: Pyjamas Django Ecosystem Pyjamas Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets Who the hell is Pyjamas? API compatibile with GWT python implementation of java script compiler java script generator talks python javascript JSONRPC Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets What Pyjamas gives? dynamic and reusable UI components python types simulated in JavaScript RPC mechanism handles cross-browser issues allows mix .js code with .py code design of application in python object oriented fashion itself for free Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets Supported modules from python base64.py random.py binascii.py re.py csv.py sets.py datetime.py struct.py math.py sys.py md5.py time.py os.py urllib.py Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets Supported built-in types dict long frozenset object int set list tuple Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets Requirements pyjamas 1 2 3 g i t c l o n e g i t : / / p y j s . org / g i t / pyjamas . g i t cd pyjamas python b o o t s t r a p . py libcommondjango (for JSONRPCService and jsonremote) 1 2 3 svn checkout h t t p : / / svn . pimentech . org / pimentech / libcommonDjango cd libcommonDjango make i n s t a l l Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets Create pyjamas application Create file: MyApp.py in myapp directory: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 from pyjamas . u i . RootPanel i m p o r t RootPanel i m p o r t LoginPanel c l a s s MyApp : def _ _ i n i t _ _ ( s e l f ) : s e l f . mainPanel = LoginPanel . LoginPanel ( ) d e f onModuleLoad ( s e l f ) : RootPanel ( ) . add ( s e l f . mainPanel ) i f __name__ == ’ __main__ ’ : app = MyApp ( ) app . onModuleLoad ( ) Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets Create a panel Create file: LoginPanel.py in myapp directory: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 from pyjamas . u i . TextBox i m p o r t TextBox from pyjamas . u i . Label i m p o r t Label from pyjamas . u i . H o r i z o n t a l P a n e l i m p o r t H o r i z o n t a l P a n e l c l a s s LoginPanel ( H o r i z o n t a l P a n e l ) : def _ _ i n i t _ _ ( s e l f ) : HorizontalPanel . __init__ ( s e l f ) s e l f . se tB o rd er W id th ( 0 ) self . layout ( ) def l a y o u t ( s e l f ) : s e l f . l o g i n L a b e l = Label ( ’ Login ’ ) s e l f . l o g i n L a b e l . s e t H e i g h t ( " 20px " ) s e l f . l o g i n T e x t = TextBox ( ) s e l f . l o g i n T e x t . s e t H e i g h t ( " 20px " ) s e l f . l o g i n T e x t . s e t W i d t h ( " 60px " ) s e l f . add ( s e l f . l o g i n L a b e l ) s e l f . add ( s e l f . l o g i n T e x t ) Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets Widgets Pyjamas offers a lot of widgets in package: pyjamas.ui.widgets Button HorizontalPanel PasswordTextBox Calendar HorizontalSlider PushButton CheckBox Hyperlink RadioButton DialogBox Image ScrollPanel DockPanel Label TextArea FlowPanel ListBox TextBox FormPanel MenuBar Tooltip Frame MenuItem Tree HTML Panel TreeItem Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets Add more controls Add password control to LoginPanel class 1 2 3 4 5 6 7 8 9 10 11 12 s e l f . l o g i n T e x t . addKeyboardListener ( s e l f ) s e l f . passwdLabel = Label ( ’ Password ’ ) s e l f . passwdLabel . s e t H e i g h t ( " 20px " ) self self self self . passwdText = PasswordTextBox ( ) . passwdText . s e t H e i g h t ( " 20px " ) . passwdText . s e t W i d t h ( " 60px " ) . passwdText . addKeyboardListener ( s e l f ) s e l f . add ( s e l f . passwdLabel ) s e l f . add ( s e l f . passwdText ) Do not forget imports 1 2 from pyjamas . u i i m p o r t K e y b o a r d L i s t e n e r from pyjamas . u i . PasswordTextBox i m p o r t PasswordTextBox Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets Listeners ClickListener FocusListener KeyboardListener MouseListener MultiListener Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets Compile to javascript Use pyjsbuild: 1 2 p y j s b u i l d MyApp . py p y j s b u i l d LoginPanel . py to generate output/ directory containing html files with javascript Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets Update urls.py to see Pyjamas application Add the following line to urls.py 1 2 3 4 5 ( r ’ ^ m y p o r t a l / myapp / ( ? P<path > . ∗ ) $ ’ , ’ django . views . s t a t i c . serve ’ , { ’ document_root ’ : s t r ( os . path . j o i n ( os . path . dirname ( _ _ f i l e _ _ ) , ’ . . / myapp / o u t p u t ’ ) . r e p l a c e ( ’ \ \ ’ , ’ / ’ ) ) } ) , Do not forget to: 1 i m p o r t os Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction From python Widgets Implement KeyboarListener methods add the following code to LoginPanel 1 2 3 4 5 6 7 8 9 10 11 12 13 d e f onKeyPress ( s e l f , sender , keyCode , m o d i f i e r s ) : i f keyCode == K e y b o a r d L i s t e n e r . KEY_ENTER : i f sender == s e l f . l o g i n T e x t : i f s e l f . passwdText . g e t T e x t ( ) == " " : s e l f . passwdText . setFocus ( ) else : s e l f . doLogin ( s e l f . l o g i n T e x t . g e t T e x t ( ) , s e l f . passwdText . g e t T e x t ( ) ) e l i f sender == s e l f . passwdText : s e l f . doLogin ( s e l f . l o g i n T e x t . g e t T e x t ( ) , s e l f . passwdText . g e t T e x t ( ) ) add method to send login request 1 2 d e f doLogin ( s e l f , l o g i n , passwd ) : r e t = s e l f . s e r v i c e . Login ( l o g i n , passwd , s e l f ) Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Part IV: Django+Pyjamas Django Ecosystem Pyjamas Django+Pyjamas Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Connect LoginPanel to django application create connection point in LoginPanel.py 1 2 3 4 c l a s s DataService ( JSONProxy ) : def _ _ i n i t _ _ ( s e l f ) : JSONProxy . _ _ i n i t _ _ ( s e l f , " / l o g i n _ s e r v i c e / " , [ " Login " ] , headers= { ’ X−CSRFToken ’ : Cookies . getCookie ( ’ c s r f t o k e n ’ ) } ) do not forget imports 1 2 from pyjamas . JSONService i m p o r t JSONProxy from pyjamas i m p o r t Cookies add member to LoginPanel constructor 1 s e l f . s e r v i c e = DataService ( ) update urls.py 1 ( r ’ ^ l o g i n _ s e r v i c e / $ ’ , ’ myapp . views . s e r v i c e ’ ) , Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Handle response from server add response method to LoginPanel class 1 2 3 4 5 d e f onRemoteResponse ( s e l f , response , r e q u e s t _ i n f o ) : self . layout ( ) i f response [ ’ name ’ ] : s e l f . add ( Label ( response [ ’ name ’ ] ) ) Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Implement Login method on server-side 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 from django . pimentech . network i m p o r t JSONRPCService , jsonremote s e r v i c e = JSONRPCService ( ) @jsonremote ( s e r v i c e ) d e f Login ( request , l o g i n , passwd ) : i m p o r t models username = ’ Unknown ’ user = models . Users . o b j e c t s \ . f i l t e r ( l o g i n = l o g i n ) . f i l t e r ( passwd= e n c r y p t ( passwd ) ) i f l e n ( user ) == 1 : username = user [ 0 ] . name response = { ’ name ’ : username } r e t u r n response Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Let’s Rock! Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Part IV: Pyjamas+Tuning Django Ecosystem Pyjamas+Tuning Pyjamas Django+Pyjamas Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Tune up with CSS (Cascade Style Sheet) in myapp create directory public for CSS and overriden htmls use generated MyApp.html 1 2 3 4 5 6 7 8 9 10 11 12 13 14 <html> < !−− auto−generated h t m l − you should c o n s i d e r e d i t i n g and a d a p t i n g t h i s t o s u i t your r e q u i r e m e n t s −−> <head> <meta name= " pygwt : module " c o n t e n t = " Login " > < l i n k h r e f = " MyApp . css " r e l = " s t y l e s h e e t " > < t i t l e >Login module< / t i t l e > < / head> <body b g c o l o r = " w h i t e " > < s c r i p t language= " j a v a s c r i p t " s r c = " b o o t s t r a p . j s " >< / s c r i p t > < i f r a m e i d = ’ __pygwt_historyFrame ’ s t y l e = ’ w i d t h : 0 ; h e i g h t : 0 ; b o r d e r : 0 ’ >< / i f r a m e > < / body> < / html> Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Create MyApp.css 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 . graybutton { f o n t−s i z e : 1 1 px ; f o n t−f a m i l y : Verdana , sans−s e r i f ; f o n t−w e i g h t : b o l d ; c o l o r :#888888; w i d t h :100 px ; background−c o l o r : # eeeeee ; border−s t y l e : s o l i d ; border−c o l o r : #BBBBBB ; border−w i d t h : 1 px ; } . graybuttonlight { f o n t−s i z e : 1 1 px ; f o n t−f a m i l y : Verdana , sans−s e r i f ; f o n t−w e i g h t : b o l d ; c o l o r :#66 aaaa ; w i d t h :100 px ; background−c o l o r : # eeeef4 ; border−s t y l e : s o l i d ; border−c o l o r :#9999 dd ; border−w i d t h : 1 px ; } Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Create custom highlight button 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 from pyjamas . u i . B u t t o n i m p o r t B u t t o n class H i g h l i g h t B u t t o n ( Button ) : d e f _ _ i n i t _ _ ( s e l f , h t m l =None , l i s t e n e r =None , ∗∗kwargs ) : B u t t o n . _ _ i n i t _ _ ( s e l f , html , l i s t e n e r , ∗∗kwargs ) s e l f . n o r m a l S t y l e = s e l f . getStyleName ( ) s e l f . h i g h l i g h t S t y l e = s e l f . getStyleName ( ) s e l f . addMouseListener ( s e l f ) def setNormalStyle ( s e l f , s t y l e ) : s e l f . normalStyle = s t y l e def s e t H i g h l i g h t S t y l e ( s e l f , s t y l e ) : self . highlightStyle = style d e f onMouseEnter ( s e l f , sender , event ) : B u t t o n . onMouseEnter ( s e l f , sender , event ) s e l f . setStyleName ( ’ g r a y b u t t o n l i g h t ’ ) d e f onMouseLeave ( s e l f , sender , event ) : B u t t o n . onMouseLeave ( s e l f , sender , event ) s e l f . setStyleName ( ’ g r a y b u t t o n ’ ) Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Logout functionality JSONProxy (same as Login) button on GUI method on service Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Introduction Let’s Rock! Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Summary complex technology advanced object oriented all with python open and free Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Part VI: Questions Django Ecosystem Questions Pyjamas+Tuning Pyjamas Django+Pyjamas Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Usefull links http://djangoproject.com http://pyjs.org http://pyjs.org/api/ Pawel Prokop Django and Pyjamas Ecosystem Django Pyjamas Django+Pyjamas Summary Credits 1. flickr/python/raym5 2. flickr/server upgrade/msarturlr 3. flickr/drinks/kdinuraj Pawel Prokop Django and Pyjamas