Richard Baxter's Profile

Member since Apr 12, 2007, follows 0 people, 0 public groups, 391 public bookmarks (439 total).

More »
Tags

Recent Tags:
Top Tags:

More »
Recent Bookmarks and Annotations

  • Chapter 8: Starting the SimpleSite Tutorial — Pylons Book v1.1 documentation on 2009-11-22
    • Pylons looks for resources in the order applications are specified in the cascade object in config/middleware.py. You’ll learn more about the cascade object in Chapter 17, but it causes static files such as the introduction page to be served in preference to content generated by your Pylons controllers for the same URL. You will want the SimpleSite controllers to handle the site’s home page, so remove the welcome page HTML file:
    • Calling an action wrapped by @validate using a GET request will bypass the validation and call the action anyway. You need to make sure this doesn’t pose a security risk in your application. You could prevent this by testing whether a GET or a POST is being used in the body of the action. You can determine the request method using request.method, or Pylons provides another decorator called @restrict that you can use.
  • Chapter 7: Introducing the Model and SQLAlchemy — Pylons Book v1.1 documentation on 2009-11-21
    • This is described in Chapter 20.
    • Once you have generated a select object, you can still add extra clauses to it. For example, if you wanted to add an ORDER_BY clause, you could write this:


      s = select([page_table], and_(page_table.c.id<=10, page_table.c.name.like(u't%')))
      s = s.order_by(page_table.c.title.desc(), page_table.c.id)


    • 1 more annotations...
  • Chapter 7: Introducing the Model and SQLAlchemy — Pylons Book v1.1 documentation on 2009-11-21
    • Tip


      It is worth being aware that you can have SQLAlchemy automatically convert all string types to handle Unicode automatically if you set up the engine like this:


      create_engine('sqlite:///:memory:', convert_unicode=True)


      In this book, you will instead use the Unicode type explicitly when you want to work with Unicode strings, but some Pylons developers prefer to take this shortcut.

    • In this case, the opening/closing of the connection is handled by the metadata object associated with the page_table object. It is usually better to execute SQL Expression objects like ins via connection.execute() so that you always know precisely which connection is being used. This becomes particularly important when you are using the Object-Relational API within Pylons with a scoped session when you probably want to use the connection used by the session rather than letting the metadata object create a connection for you. You’ll see how this works in Chapter 8.
  • Chapter 6: Working with Forms and Validators — Pylons Book v1.1 documentation on 2009-11-21
    • Now you can test the controller. In this case, once the form is submitted, the data is saved, and an HTTP redirect occurs so that the browser redirects to http://localhost:5000/formtest/result. If the user then refreshes the page, it simply redisplays the message rather than reperforming the action.


      One issue with this approach is that if you want to display some of the submitted data, you will need to load it again in the result() action because the request that calls that action doesn’t contain any of the submitted data. In Chapter 8, I’ll cover how these sorts of messages can be displayed by storing information in a session store.

    • One common use for this functionality is to specify the CSS class the field should have. The problem is that class is a reserved word in Python, so to specify the class attribute, you need to pass in the parameter class_ with a trailing _ character.
    • 1 more annotations...
  • Chapter 5: Using View Templates — Pylons Book v1.1 documentation on 2009-11-19
    • The two important things to realize are that writing output with context.write() has the same effect as using ${} and that any variables that can be used in a template can be accessed with context.get().
    • If you want to actually capture the output of a def to a variable rather than to the output buffer, you have to use capture().
    • 1 more annotations...
  • Chapter 5: Using View Templates — Pylons Book v1.1 documentation on 2009-11-18
    • Create a new controller in your TemplateDemo project named greeting:


      $ cd TemplateDemo
      $ paster controller greeting
  • Investing in the 'New Normal': In this age of diminished expectations, how should you invest? on 2009-06-29
  • Four investment 'rules' to ignore: Disregard these chestnuts when managing your portfolio on 2009-06-29
    • Looking at consistency of absolute returns--that is, a fund's ability to
      avoid real losses--is a more worthwhile exercise, particularly for
      investors who are close to tapping their assets.
    • Simply put, you would've been
      paying attention to the market's opinion without bothering to consider
      the underlying attributes of the stocks or funds you were selling.
    • 2 more annotations...
  • Watch Your Web Site Users With Clixpy on 2009-05-28
  • Color Scheme Designer 3 on 2009-05-19

More »
Bookmark Lists

Diigo is about better ways to research, share and collaborate on information. Learn more »

Join Diigo