{"id":1265,"date":"2010-05-02T21:55:07","date_gmt":"2010-05-03T02:55:07","guid":{"rendered":"http:\/\/mikeconley.ca\/blog\/?p=1265"},"modified":"2023-12-20T16:25:16","modified_gmt":"2023-12-20T21:25:16","slug":"reviewboard-extension-lifecycle","status":"publish","type":"post","link":"https:\/\/mikeconley.ca\/blog\/2010\/05\/02\/reviewboard-extension-lifecycle\/","title":{"rendered":"The Review Board Extension Life-Cycle"},"content":{"rendered":"<p>According to <a href=\"http:\/\/socghop.appspot.com\/document\/show\/gsoc_program\/google\/gsoc2010\/timeline\">the timeline<\/a>, I&#8217;m still in the community-bonding period for GSoC.\u00a0 Coding for <a href=\"http:\/\/mikeconley.ca\/blog\/2010\/04\/27\/my-gsoc-project-review-board-extensions\/\">my project<\/a> is supposed to start sometime towards the end of May.<\/p>\n<p>So I&#8217;m using the time to do the following:<\/p>\n<ul>\n<li>Close as many small, easy tickets as I can for the\u00a0 upcoming Review Board release.\u00a0 I&#8217;ve already posted some patches for review.\u00a0 More forthcoming.<\/li>\n<li>Get to know the tools I&#8217;ll be using.\u00a0 Review Board is hosted on Github, and I&#8217;m relatively new to the whole DVCS thing.\u00a0 I&#8217;ve been figuring out <a href=\"http:\/\/progit.org\">how to use Git<\/a>, how to post patches, merging, branching, etc.<\/li>\n<li>Get to know the area I&#8217;ll be working in.\u00a0 I&#8217;ve been figuring out how Django apps organize themselves.\u00a0 I&#8217;ve also drawn up <a href=\"http:\/\/mikeconley.ca\/blog\/2010\/04\/30\/code-spelunking-review-board-extensions-2\/\">a map of the current state of the extension framework<\/a> to help me visualize it.<\/li>\n<li>Get to know the other developers working on Review Board.\u00a0 I&#8217;ve been hanging out in the #reviewboard-soc FreeNode IRC channel.\u00a0 Very nice, and helpful people to work with.<\/li>\n<li>Develop a plan of attack for my project<\/li>\n<\/ul>\n<p>And this last point is the one I want to talk about.<\/p>\n<h3>The Review Board Extension Life-Cycle<\/h3>\n<p>An extension isn&#8217;t just some isolated piece of code that gets crammed into an application.\u00a0 When you&#8217;ve got multiple extensions already installed and running, installing and activating a new extension is like introducing a new animal into an ecosystem.\u00a0 You have to make sure that your new animal plays nice with the others, and that, in the morning, there won&#8217;t be a pile of rotting corpses where your application used to be.<\/p>\n<p>I may have gotten carried away with my metaphor.<\/p>\n<p>So let&#8217;s look at what I&#8217;m envisioning as the life-cycle for a Review Board extension.\u00a0 I&#8217;ll start right from the top.<\/p>\n<h4>Getting the Extension<\/h4>\n<p>Ideally, this will work as nicely as WordPress&#8217;s implementation:\u00a0 a Review Board administrator is given a catalog of extensions to choose from within the Administrator interface, and one click later, the desired extensions are downloaded and ready to be installed.<\/p>\n<p>For all you system administrators out there, that last idea might make your toes curl.\u00a0 A Review Board administrator is not necessarily a system administrator, and the system administrator knows what he\/she likes on their machine.\u00a0 An application that can go and download other applications can be dangerous.\u00a0 We have to ensure that the application that we&#8217;re downloading is the one we&#8217;re <em>trying <\/em>to download.\u00a0 The last thing we need is some man-in-the-middle to do something cute and bork the code review machine.\u00a0 And we want to ensure that the extension functions as advertised.\u00a0 No hidden features.\u00a0 No self-destruct mechanisms.\u00a0 No back doors.<\/p>\n<p>Do I have a plan for this part?\u00a0 Well&#8230;.no, not really.\u00a0 I don&#8217;t imagine I&#8217;ll get that far &#8211; I consider it a little out of my scope.\u00a0 So, for my project, I think it&#8217;ll satisfy if the system admin (or Review Board admin) can manually download the extension, decompress it, and place it where Review Board can work with it.\u00a0 That other stuff can come later (and I&#8217;ll try to design so that it can come later <em>easily<\/em>).<\/p>\n<h4>Installing the Extension<\/h4>\n<p>Ok, so at this point, we&#8217;ve got our extension downloaded in a place where Review Board can see it.<\/p>\n<p>So now what?<\/p>\n<p>Now we need to <em>install<\/em> the extension.\u00a0 To me, that means letting the extension put its roots into the RB install by creating database tables, preparing initial data, and generally doing everything to make conditions suitable for the extension to function.<\/p>\n<p>When an extension install begins, I imagine it will consider the following questions (in no particular order):<\/p>\n<ol>\n<li>Do I (the extension) depend on other extensions to function?\u00a0 If so, are those extensions present?\u00a0 If not, let the user know so that they can go get them.<\/li>\n<li>Are there some extensions already installed that will conflict with me, or make me behave badly?\u00a0 If so, let the user know so that they can either remove that conflict, or find an alternative extension.<\/li>\n<li>Is the user entirely aware of what I can do?\u00a0 Make sure that my capabilities, limitations, and behavioural quirks are known to the user.<\/li>\n<\/ol>\n<p>Once those 3 questions are answered, and everything is looking good for the install, the extension will create the database tables it needs (if any) in order to function.\u00a0 If anything goes wrong during this process, the database changes will be rolled back, and the user will get a full read out about what went wrong.<\/p>\n<p>If nothing goes wrong, the extension will be installed.\u00a0 The user might then be asked to set some initial operating parameters for the extension.<\/p>\n<p>Ok great &#8211; the extension is installed.\u00a0 Now what?<\/p>\n<h4>Activating the Extension<\/h4>\n<p>For something that sounds so dramatic, the explanation about what happens is pretty short:\u00a0 Review Board simply becomes aware that the extension is activated, and passes data through the necessary hooks in order for the extension to function properly.\u00a0 Upon activation, the extension should do a quick double-check to ensure that all prerequisites for the extension have been met.\u00a0 This is because we can&#8217;t trust users to activate an extension immediately after downloading them.<\/p>\n<h4>The Extension Runs<\/h4>\n<p>While it&#8217;s activated, the extension will probably react to various events that happen on Review Board.\u00a0 Tables will be updated.\u00a0 View methods will be run.\u00a0 Templates will be rendered.<\/p>\n<p>If anything, ever, goes horribly wrong with an extension, the following will happen:<\/p>\n<ol>\n<li>A log entry will be written, dumping the error, and information about what the user was trying to do<\/li>\n<li>An error message will be displayed to the user, trying to tell them what exactly happened<\/li>\n<li>The extension (and its dependents) will be deactivated.\u00a0 They will no longer react to events on Review Board.\u00a0 Their tables will still be there, the settings will still, but the extension will be, in essence, asleep.\u00a0 Dormant.\u00a0 Non-reactive.<\/li>\n<\/ol>\n<p>The administrator could try to reactivate the extension at this point.\u00a0 They might try to contact the extension developer for support.<\/p>\n<h4>The Extension is Un-installed<\/h4>\n<p>If the user wants to rid themselves of an extension, they must first deactivate it.\u00a0 This will put it (and its dependents) in the dormant state.\u00a0 It just switches them off, nothing else.<\/p>\n<p>Deactivated extensions can then be un-installed.\u00a0 If the user chooses to un-install the extension, the extension database tables and settings will be wiped out.<\/p>\n<p>The extension itself won&#8217;t be deleted though &#8211; at least, not within the scope of my project.\u00a0 The extension files will need to be removed from Review Board manually.<\/p>\n<p>At this point, any dependents that this uninstalled extension had will no longer be able to be activated.<\/p>\n<p>Anyhow, that&#8217;s how I envision the life-cycle.\u00a0 It&#8217;s my first go at it, so I&#8217;d love to hear some feedback if you have any.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>According to the timeline, I&#8217;m still in the community-bonding period for GSoC.\u00a0 Coding for my project is supposed to start sometime towards the end of May. So I&#8217;m using the time to do the following: Close as many small, easy tickets as I can for the\u00a0 upcoming Review Board release.\u00a0 I&#8217;ve already posted some patches [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[657,773],"tags":[131,664,1219,504],"class_list":["post-1265","post","type-post","status-publish","format-standard","hentry","category-extensions-review-board-code-reviews-computer-science-technology","category-gsoc-computer-science","tag-extensions","tag-life-cycle","tag-review-board","tag-reviewboard"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/prmTy-kp","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/posts\/1265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/comments?post=1265"}],"version-history":[{"count":22,"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/posts\/1265\/revisions"}],"predecessor-version":[{"id":1289,"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/posts\/1265\/revisions\/1289"}],"wp:attachment":[{"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/media?parent=1265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/categories?post=1265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/tags?post=1265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}