F01.justanswer.com



COMP249 Assignment:?Psst?Microblog Web ApplicationThis semester we will be writing a simple micro-blogging application called Psst that allows users to post short messages. Unlike the competition, which limit messages to 140 characters, Psst allows a full 150 characters in each message. We hope that this will give us the edge in this very competitive market.To give you an idea of what the application does, there is a demonstration version at? this is your first significant web application, we've cut down the features a bit to make it manageable. However we maintain the core of the application and what you write could be extended to something like a real product. Your application will support logging in users, posting messages, posting replies and viewing messages in various ways. We don't require you to be able to register new users or handle user profile changes etc.You are given a 'starter kit' which contains the bare outline of the application. From this starting point, you will implement the full site in phases according to a detailed set of functional requirements. At the end of each phase, a set of automated tests will be used to see if you have met the criteria for that phase. Some of the marks for this assignment will be based on your passing these automated tests.While this task may seem quite daunting, it should be achievable if you work through the examples we have provided and work on the problem bit by bit. We have run similar tasks in the past in COMP249 and most students have succeeded in getting a working system going.Level 1The first phase of the project involves writing a basic web application that can serve two pages.RequirementsLevel 2In this phase you will interface to a backend database and provide views that list all posts and those for a given user.RequirementsLevel 3The next phase of development adds the ability to login to the application and post messages.RequirementsGoing FurtherThe final phase of development is more open ended. You are free to add new features to the application as you see fit. In doing so you should try to follow the same development process and properly document the functional and unit tests that will give you assurance that you have achieved your desired functionality. Functional tests can be optionally implemented using WebTest but should at least be expressed as a user story ('As a user, when I...').Starter KitThe starter kit is a zip file containing a set of Python files to get you started on this project. These files provide a framework for you to work within, you will need to add more code of your own and possibly more modules (Python files, templates) to complete the implementation.You can download the starter pack here:?comp249-2017-psst-starter. It is also available as a Bitbucket project?comp249-2017-psst-starter, if you are a git user you could fork the repository from there -?please be sure to keep your own version private if you keep your work on Bitbucket (or Github).The contents of the starter pack are as follows:database.py?- python page templating modulemain.py?- main application script with a simple exampleinterface.py?- stubs for the level 2 required functionsusers.py?- stubs for the level 3 required functionslevel1_functional.py?- functional tests for Level 1level2_functional.py?- functional tests for Level 2level2_unit.py?- unit tests for Level 2level3_functional.py?- functional tests for Level 3level3_unit.py?- unit tests for Level 3static?- directory containing a sample CSS fileThe?database.py?module contains code to create an interface to the database, you should use it to create a database connection rather than using raw SQLite calls. It ensures that you are using the right database file and contains code to generate test data for you to use in development. An example of how you would use this is as follows:from database import COMP249Dbdb = COMP249Db()cursor = db.cursor()cursor.execute("SELECT nick FROM users")for row in cursor: print(row) The database contains the following tables:users: fields?nick?(user nickname),?password,?avatar?(URL of an avatar image)sessions: fields?sessionid,?usernick, where usernick is a reference to the nick field in the users tableposts: fields?id,?timestamp,?usernick,?contentThere are also two other tables?votes?and?follows?that are not used in the core requirements but that you can use if you wish to implement further features.Each user is identified by a nickname that is stored in the?nick?field in the?users?table. This field is used as a foreign key in other tables to refer to the user. To select data from both tables you will need to do a query with a join.The?posts?table deserves further comment. The?id?field is an auto-incremented integer id for each post, you don't need to give this a value, it will automatically get a new unique value when you insert a row. The?timestamp?field will also default to the current time and date in the format '2015-02-20 01:45:06' if you don't provide a value when you add a row. So, to add a row to the?posts?table you just need:sql = "INSERT INTO posts (usernick, content) VALUES (?, ?)"cursor.execute(sql, ['steve', 'this is my post'])mit() The code as provided includes a sample Bottle application which you can run. It doesn't do much other than generate a static page that links to a copy of these notes. This is your starting point for development and you should write your code so that?main.py?is the main application (when I run your code, this is what I'll look for).You can run the functional and unit tests (level1_functional.py?level2_unit.py) to check that you have met the requirements at each level. To do this, open the file in PyCharm and click 'Run', choose to run as "Python unit-test". Alternately, run them from the command line eg.?python level1_functional.py.Note that if you follow the written requirements set out in the pages linked above, you should pass the functional tests. A reasonable way to work would be to read and implement each functional requirement in turn and then run the functional tests when you are done as a check.SubmissionYou will submit this work in two parts: after you have completed Level 2, and after you have completed Level 3 or above. The Level 2 submission is intended to check on your progress with the assignment so that we can provide you with feedback and identify anyone who needs support. See iLearn for the dates of these submissions.For each submission you should submit a zip file with the same structure as the starter pack. We will expect to run?main.py?to see your application. Include any support files that you need for your application to work. A good idea would be to unpack your zip file at a new location and try to run it yourself.Grading the AssignmentThis assignment is worth 30% of the final marks for COMP249. A total of 18 marks will be entirely based on achieving the stated functional and unit-test requirements and passing the automated tests. The remaining 12 marks will be based on the quality of the code and documentation that you provide, and any additional work that you do beyond the basic requirements. The breakdown of marks for the automated tests is as follows:LevelFunctional TestsUnit TestsCumulative Marks12-22441034418The remaining?12 marks?will decide whether you get a Credit or Distinction/High Distinction for the assignment. The criteria are:FeaturesThe extra features that you have implemented in the project. For a Credit you don't need to add any extra features, for D/HD you will have added at least one new feature that is well integrated into the application and is well thought out.Code QualityYour code is readable and well structured. For a Credit, we should not have any trouble working out how you implemented a given feature. For a D/HD, you will have thought hard about how the application as a whole fits together and made good use of modules.DocumentationYou have provided appropriate documentation. For a Credit, you will have used documentation strings and in-line comments where appropriate in your code. For D/HD, you will have provided documentation of your application that would be useful to a future developer, your documentation will include functional tests in the form of user stories for your new features.Your final grade will be calculated based on your performance against the above criteria. It is not necessary to get a distinction against all criteria to get full marks for the assignment.psstHomeAll PsstsUsersAboutAssignment SpecLevel 1For this level you must write a simple web application that generates two pages. You are given a set of requirements below, these are encoded in a set of tests (?level1_functional.pyin the starter kit) that your application must pass. The tests correspond to the functional requirements below.Functional requirementsWelcome to PsstAs a visitor to the site, when I load the home page I see the title text?"Welcome to Psst".About Page LinkAs a visitor to the site, when I load the home page I see a link to another page with the link text?"About".About PageAs a visitor to the site, when I click on the link?"About"?I am taken to a page that contains the site manifesto, including the words?"Psst is a new, exciting, messaging service like nothing you've seen before!".Consistent DesignAs a visitor to the site, I notice that all the pages on the site have the same design with the same colours and fonts used throughout.Each page will have a similar structure and will link to a common CSS stylesheet.List of PostsAs a visitor to the site, when I load the home page I see a list of messages from different users.The list of messages is generated by the function?post_list(). This is a dummy function that we will replace later with a version that queries the database. The function returns a list of tuples representing messages, each tuple contains:?(id, timestamp, usernick, avatar, content).Unit TestsThere are no unit tests for this level.Your TaskTo achieve these requirements you will need to build a bottle web application that is able to serve the two HTML pages (Home and About) and the associated stylesheet. The techniques to do this are covered here:Python Web Applications.Generating HTML Pages?looks at the Bottle page templating system.Testing Python Programs?covers running unit tests.Getting StartedYou should be able to unpack the starter kit and run?main.py?to see a very simple single page web application that is the starting point for your work. You need to extend this to meet the requirements above. This application is very similar to others that you will have written in tutorials and so should not present any new problems for you to solve; you just need to apply the techniques you've already learned.The functional requirements have been laid out in a suggested ordering. Start by writing code to meet the first requirement before moving on to the second. Treat each requirement as a sub-problem. Understand what is asked of you and design a solution, then implement it. These requirements may seem too trivial to work like this but as they get more complicated you will benefit from this approach.Run the functional tests before and after you implement each requirement. You should see the test fail before, and when you see it pass you know you have a correct solution. This is known as?Test Driven Development?- normally you would write the tests yourself to encode your understanding of the users requirements.Psst is a class project for COMP249 at Macquarie UniversityPsst uses?Twitter BootstrapCopyright ??Steve Cassidy, 2017LEVEL 2psstHomeAll PsstsUsersAboutAssignment SpecLevel 2In this phase you will write a basic version of the web application that can display but not create posts. This means we don't yet have to worry about login and sessions but that you must interface to the database to lists posts.Following the model-view-controller architecture, the first thing that you'll implement is the database model. This is contained in a module?interface.py?with all of the code to retrieve and store posts in the database. You will then implement the views (templates) and controllers for the web application that makes use of the models present the data on the web.All of the work you do will be tested using unit tests. For the database interface, there are straightforward unit tests of the functions that you will write. To test the behaviour of the web application we'll use functional testing that requests your pages and checks that they have certain contents, and that we can login and post messages. We will do this using a module called?WebTest?that is designed specifically for functional testing of Python web applications.Unit TestsAll procedures will be implemented in the module?interface.py. A version has been supplied that contains the procedure stubs only.When we refer to a database connection below we mean the connection returned by?COMP249Db?from the?database?module that we provide. This is just a regular SQLite database connection, but the code we provide ensures we can control which database you are using for testing purposes.post_listThere is a function?post_list(db, usernick=None, limit=50).?db?is a database connection, the optional argument?usernick?is a user name and the optional argument limit is an integer. The function returns a list of tuples representing messages, each tuple contains:?(id, timestamp, usernick, avatar, content). If?usernick?is specified then only messages from that user are returned. At most?limit?messages are returned. Messages are returned in reverse order of the timestamp, most recent first.post_list_mentionsThere is a function?post_list_mentions(db, usernick, limit=50).?db?is a database connection, the argument?usernick?is a user name and the optional argument limit is an integer. The function returns a list of tuples representing messages that contain the '@' character followed by?usernick, each tuple contains:?(id, timestamp, usernick, avatar, content). If?usernick?is specified then only messages from that user are returned. At most?limit?messages are returned. Messages are returned in reverse order of the timestamp, most recent first.post_addThere is a function?post_add(db, usernick, message).?db?is a database connection, the argument?usernick?is a user name and?message?is the text of a new message. The function adds the new post to the database and returns the ID of the post. The length of the message must be less than or equal to 150 characters - if not, the new post is not created and the function returns?None.post_to_htmlThere is a function?post_to_html(message)?which takes a message text and converts it to HTML suitable for display.Any HTML special characters (<, > &) are converted to entities (&lt;, &gt; &amp;).Any URL in the message is converted to a link to that URL.Any user mentions ('@' character followed by a sequence of letters, numbers or periods) are turned into links to the URL?/users/xxxxx?where xxxxx is the text following the @ character.Any hashtags in the text ('#' followed by a sequence of letters, numbers or periods) are enclosed by a?<strong class='hashtag'>?tag. Eg.?<strong class='hashtag'>#whatever</strong>Functional requirementsThe functional requirements describe what a user should be able to see and do on the web application. They describe what happens when you load a particular URL or submit a form in a page. There are automated tests to check that you have implemented this functionality correctly.Home Page List of PostsAs a visitor to the site, when I load the home page (URL /) I see a list of up to 50 posts from all users in order of time, most recent first. Each post must include the post date, author and the text of the message suitably converted to HTML.The list of posts that appears should be the result of a call to?post_list?which will extract the most recent 50 posts from the database.User PageAs a visitor to the site, when I load the page for a user (URL /users/user) I see their name and avatar and a list of their posts in order, newest first. The requirements for display of posts is the same as for the home page.The list of posts that appears should be the result of a call to?post_list?with the?usernick?argument specified to limit the list to posts from this user.User Mentions PageAs a visitor to the site, when I load the mentions page for a user (URL /mentions/user, eg. /mentions/Bobalooba), I see a list of all posts that contain the @ character followed by the user name.The list of posts that appears should be the result of a call to?post_list_mentions.Your TaskTo achieve these requirements you need to write code in?interface.py?to implement the different functions to interface to the database. Run the unit tests in?level2_unit.py?to check whether you have met the requirements.Once you have a working version of?interface.py?you can move on to write the application itself in?main.py. Take each required page in turn and write the code to generate the content using the functions you have written. You can check the functional requirements yourself and run the unit tests in?level2_functional.py?to validate that you've met the requirements.Python Web Applications.Python and SQLite?describes the way to send queries to SQLite and get results back.Generating HTML Pages?looks at the Bottle page templating system.Testing Python Programs?covers running unit tests.Psst is a class project for COMP249 at Macquarie UniversityPsst uses?Twitter BootstrapCopyright ??Steve Cassidy, 2015 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download