python-lastfm/docs/lastfm.decorators-module.html

334 lines
13 KiB
HTML

<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>lastfm.decorators</title>
<link rel="stylesheet" href="epydoc.css" type="text/css" />
<script type="text/javascript" src="epydoc.js"></script>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="lastfm-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Tree link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Index link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Help link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
><a class="navbar" target="_top" href="http://code.google.com/p/python-lastfm/">python-lastfm</a></th>
</tr></table></th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<span class="breadcrumbs">
<a href="lastfm-module.html">Package&nbsp;lastfm</a> ::
Module&nbsp;decorators
</span>
</td>
<td>
<table cellpadding="0" cellspacing="0">
<!-- hide/show private -->
<tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
<tr><td align="right"><span class="options"
>[<a href="frames.html" target="_top">frames</a
>]&nbsp;|&nbsp;<a href="lastfm.decorators-module.html"
target="_top">no&nbsp;frames</a>]</span></td></tr>
</table>
</td>
</tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module decorators</h1><p class="nomargin-top"><span class="codelink"><a href="lastfm.decorators-pysrc.html">source&nbsp;code</a></span></p>
<p>Module containting the decorators used in the package</p>
<hr />
<div class="fields"> <p><strong>Version:</strong>
0.2
</p>
<p><strong>Author:</strong>
Abhinav Sarkar &lt;abhinav@abhinavsarkar.net&gt;
</p>
<p><strong>License:</strong>
GNU Lesser General Public License
</p>
</div><!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td colspan="2" class="table-header">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td align="left"><span class="table-header">Functions</span></td>
<td align="right" valign="top"
><span class="options">[<a href="#section-Functions"
class="privatelink" onclick="toggle_private();"
>hide private</a>]</span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"><code class="link">property</code></span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="lastfm.decorators-module.html#top_property" class="summary-sig-name">top_property</a>(<span class="summary-sig-arg">list_property_name</span>)</span><br />
A decorator to return a property that returns the first value of list
attribute corresponding to the provided list property name.</td>
<td align="right" valign="top">
<span class="codelink"><a href="lastfm.decorators-pysrc.html#top_property">source&nbsp;code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"><code class="link">property</code></span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="lastfm.decorators-module.html#cached_property" class="summary-sig-name">cached_property</a>(<span class="summary-sig-arg">func</span>)</span><br />
A decorator to cache the atrribute of the object.</td>
<td align="right" valign="top">
<span class="codelink"><a href="lastfm.decorators-pysrc.html#cached_property">source&nbsp;code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"><code>function</code></span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="lastfm.decorators-module.html#authenticate" class="summary-sig-name">authenticate</a>(<span class="summary-sig-arg">func</span>)</span><br />
A decorator to check if the current user is authenticated or not.</td>
<td align="right" valign="top">
<span class="codelink"><a href="lastfm.decorators-pysrc.html#authenticate">source&nbsp;code</a></span>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td colspan="2" class="table-header">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td align="left"><span class="table-header">Variables</span></td>
<td align="right" valign="top"
><span class="options">[<a href="#section-Variables"
class="privatelink" onclick="toggle_private();"
>hide private</a>]</span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="__package__"></a><span class="summary-name">__package__</span> = <code title="'lastfm'"><code class="variable-quote">'</code><code class="variable-string">lastfm</code><code class="variable-quote">'</code></code>
</td>
</tr>
</table>
<p class="indent-wrapped-lines"><b>Imports:</b>
<span title="copy">copy</span>,
<a href="lastfm.error.LastfmError-class.html" title="lastfm.error.LastfmError">LastfmError</a>,
<a href="lastfm.error.AuthenticationFailedError-class.html" title="lastfm.error.AuthenticationFailedError">AuthenticationFailedError</a>
</p><br />
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td colspan="2" class="table-header">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td align="left"><span class="table-header">Function Details</span></td>
<td align="right" valign="top"
><span class="options">[<a href="#section-FunctionDetails"
class="privatelink" onclick="toggle_private();"
>hide private</a>]</span></td>
</tr>
</table>
</td>
</tr>
</table>
<a name="top_property"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">top_property</span>(<span class="sig-arg">list_property_name</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="lastfm.decorators-pysrc.html#top_property">source&nbsp;code</a></span>&nbsp;
</td>
</tr></table>
<p>A decorator to return a property that returns the first value of list
attribute corresponding to the provided list property name.</p>
<p>For example, if the list property is top_albums, then the decorator
returns a property that returns the first (top most) album.</p>
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>list_property_name</code></strong> (<code class="link">str</code>) - the name of the list property. Like 'top_albums'.</li>
</ul></dd>
<dt>Returns: <code class="link">property</code></dt>
<dd>a property that returns the first value of list attribute
corresponding to the provided list property name</dd>
</dl>
</td></tr></table>
</div>
<a name="cached_property"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">cached_property</span>(<span class="sig-arg">func</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="lastfm.decorators-pysrc.html#cached_property">source&nbsp;code</a></span>&nbsp;
</td>
</tr></table>
<p>A decorator to cache the atrribute of the object. When called for the
first time, the value of the attribute is retrived and saved in an
instance variable. Later calls return the copy of the cached value, so
that the original cached value cannot be modified.</p>
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>func</code></strong> (<code>function</code>) - the getter function of the attribute</li>
</ul></dd>
<dt>Returns: <code class="link">property</code></dt>
<dd>a property that wraps the getter function of the attribute</dd>
</dl>
</td></tr></table>
</div>
<a name="authenticate"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">authenticate</span>(<span class="sig-arg">func</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="lastfm.decorators-pysrc.html#authenticate">source&nbsp;code</a></span>&nbsp;
</td>
</tr></table>
<p>A decorator to check if the current user is authenticated or not. Used
only on the functions that need authentication. If not authenticated then
an exception is raised.</p>
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>func</code></strong> (<code>function</code>) - a function that needs to be authentication, for being called</li>
</ul></dd>
<dt>Returns: <code>function</code></dt>
<dd>a function that wraps the original function</dd>
<dt>Raises:</dt>
<dd><ul class="nomargin-top">
<li><code><strong class='fraise'><a href="lastfm.error.AuthenticationFailedError-class.html">AuthenticationFailedError</a></strong></code> - If the user is not authenticated, then an exception is raised.</li>
</ul></dd>
</dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="lastfm-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Tree link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Index link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Help link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
><a class="navbar" target="_top" href="http://code.google.com/p/python-lastfm/">python-lastfm</a></th>
</tr></table></th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Tue Mar 10 11:14:34 2009
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
>http://epydoc.sourceforge.net</a>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
// Private objects are initially displayed (because if
// javascript is turned off then we want them to be
// visible); but by default, we want to hide them. So hide
// them unless we have a cookie that says to show them.
checkCookie();
// -->
</script>
</body>
</html>