<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anton Shcherbatov</title>
    <description>The latest articles on DEV Community by Anton Shcherbatov (@storvus).</description>
    <link>https://dev.to/storvus</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1091925%2F1235b56d-8d46-4677-abc4-2e8aa9670d6b.jpeg</url>
      <title>DEV Community: Anton Shcherbatov</title>
      <link>https://dev.to/storvus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/storvus"/>
    <language>en</language>
    <item>
      <title>What Really Happens When You Write x = 10</title>
      <dc:creator>Anton Shcherbatov</dc:creator>
      <pubDate>Tue, 30 Jun 2026 19:20:16 +0000</pubDate>
      <link>https://dev.to/storvus/what-really-happens-when-you-write-x-10-p0b</link>
      <guid>https://dev.to/storvus/what-really-happens-when-you-write-x-10-p0b</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;We assume you already know how to write simple Python programs and understand basic syntax (if, for, functions, lists). Here, we're not discussing how to use the language, but why it works the way it does.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you ask a beginner what this line of code does:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the answer is usually something like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The number 10 is stored in the variable x."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;At first glance, that sounds perfectly reasonable. We're used to thinking of a variable as a box or a memory cell that can hold a value. First the box is empty, then we put a number, a string, or a list into it.&lt;/p&gt;

&lt;p&gt;The problem is that Python doesn't actually work that way.&lt;/p&gt;

&lt;p&gt;To understand many of Python's behaviors, it's helpful to stop thinking of variables as containers for data. Instead, think of a variable as a &lt;strong&gt;name&lt;/strong&gt; that refers to an &lt;strong&gt;object&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When Python executes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it doesn't start with the variable - it starts with the object &lt;code&gt;10&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The number &lt;code&gt;10&lt;/code&gt; is an object. Once that object exists, the name &lt;code&gt;x&lt;/code&gt; is bound to it.&lt;/p&gt;

&lt;p&gt;Visually, you can think of it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x ───► 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The arrow indicates that the name &lt;code&gt;x&lt;/code&gt; refers to the object whose value is &lt;code&gt;10&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;At first, this distinction may seem unimportant. What difference does it make whether the number is stored inside the variable or the variable simply points to it?&lt;/p&gt;

&lt;p&gt;As it turns out, the difference is enormous, and it explains many of Python's most important behaviors.&lt;/p&gt;

&lt;p&gt;Now suppose we add another line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Many people expect Python to create a second copy of the number and store it in another variable.&lt;/p&gt;

&lt;p&gt;That's not what happens.&lt;/p&gt;

&lt;p&gt;Instead, the name &lt;code&gt;y&lt;/code&gt; is simply bound to the very same object that &lt;code&gt;x&lt;/code&gt; already refers to.&lt;/p&gt;

&lt;p&gt;Now the picture looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x ─┐
   ├──► 10
y ─┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There's still only one object, but now there are two names that refer to it.&lt;/p&gt;

&lt;p&gt;That's why Python makes a clear distinction between &lt;strong&gt;objects&lt;/strong&gt; and &lt;strong&gt;names&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Objects hold data.&lt;/p&gt;

&lt;p&gt;Names allow you to access those objects.&lt;/p&gt;

&lt;p&gt;Things become even more interesting when a variable appears to "change."&lt;/p&gt;

&lt;p&gt;Consider this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you think of variables as boxes, it's natural to imagine that the number &lt;code&gt;10&lt;/code&gt; inside the box has somehow been replaced with &lt;code&gt;20&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;But that's not what Python does.&lt;/p&gt;

&lt;p&gt;Initially, the name &lt;code&gt;x&lt;/code&gt; refers to the object &lt;code&gt;10&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="err"&gt;───►&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the second assignment, the name refers to a different object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="err"&gt;───►&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The object &lt;code&gt;10&lt;/code&gt; hasn't changed, disappeared, or turned into &lt;code&gt;20&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The name &lt;code&gt;x&lt;/code&gt; has simply been rebound to another object.&lt;/p&gt;

&lt;p&gt;This may seem like a subtle detail, but it's one of the fundamental ideas behind Python's execution model.&lt;/p&gt;

&lt;p&gt;Later, we'll see that it explains many things that often confuse beginners:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;why modifying a list can unexpectedly affect another variable;&lt;/li&gt;
&lt;li&gt;why &lt;code&gt;is&lt;/code&gt; and &lt;code&gt;==&lt;/code&gt; are not the same;&lt;/li&gt;
&lt;li&gt;why strings behave differently from lists;&lt;/li&gt;
&lt;li&gt;and how Python passes arguments to functions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For now, remember just one idea.&lt;/p&gt;

&lt;p&gt;When you write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python doesn't put the number into a variable.&lt;/p&gt;

&lt;p&gt;It binds the name &lt;code&gt;x&lt;/code&gt; to the object &lt;code&gt;10&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That's why experienced Python developers usually don't say that &lt;em&gt;a variable stores a value&lt;/em&gt;. Instead, they say that &lt;em&gt;a name refers to an object&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;It may sound a little less intuitive at first, but it's much closer to how Python actually works.&lt;/p&gt;

</description>
      <category>python</category>
      <category>objects</category>
      <category>types</category>
    </item>
    <item>
      <title>More abbreviations to the abbreviation's God</title>
      <dc:creator>Anton Shcherbatov</dc:creator>
      <pubDate>Sun, 11 Jun 2023 19:54:17 +0000</pubDate>
      <link>https://dev.to/storvus/more-abbreviations-to-the-abbreviations-god-1lek</link>
      <guid>https://dev.to/storvus/more-abbreviations-to-the-abbreviations-god-1lek</guid>
      <description>&lt;p&gt;At the work I meet a lot of different abbreviations. Some of them are insignificant, some of them are pretty useful, but most of them you're already know. Nevertheless, they describe the developing process in a way it should be and can help to build a real robust applications. There is a list of the most common of them. Which ones would you like to add?&lt;/p&gt;

&lt;p&gt;SOLID Principles&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;S (Single Responsibility)&lt;/strong&gt; Every class is responsible for the on operation only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;O (Open Closed)&lt;/strong&gt; The classes have to be open for extending and closed for modification&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;L (Liskov substitution)&lt;/strong&gt; It should be possible to use a child class (type) instead of a parent without negative consequences&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;I (Interface Segregation)&lt;/strong&gt; You shouldn't force a class to implement an interface, which doesn't relate to the class&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;D (Dependency Inversion)&lt;/strong&gt; Abstractions don't depend on the details, but details do depend on the abstractions&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;YAGNI (You're not gonna need it)&lt;/strong&gt; If you're writing the code, ensure you're gonna use it. &lt;strong&gt;Don't&lt;/strong&gt; add the code if you think it'll be useful later&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DRY (Don't repeat yourself)&lt;/strong&gt; Pretty obvious. Don't hurry to write the code - look around. Likely, someone already wrote it. This is why I love pull requests for - somebody can remember that your functional already exists and we don't actually need. Seriously?! Where have you been during the sprint planning?!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;KISS (Keep it simple, stupid)&lt;/strong&gt; Well, just be simpler. The simpler code, the better it works. If a task doesn't require over-complicated solution, just use the solution. It supposes that you have multiple solution of the task. Haha :\&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BDUF (Big design up front)&lt;/strong&gt; This is what I'm lack in. No time to think, just write the &lt;del&gt;f..&lt;/del&gt; code. It's incorrect. Before starting coding, ensure that everything is well thought out&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;APO (Avoid Premature Optimization)&lt;/strong&gt; Don't force the code optimization until it's really necessary.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;There are much more abbreviations in a programming world. Which one is your favourite? My favourite is LGTM in the comments of pull requests!&lt;/p&gt;

</description>
      <category>solidity</category>
      <category>learning</category>
      <category>yagni</category>
      <category>dry</category>
    </item>
    <item>
      <title>Bottle+Sqlite</title>
      <dc:creator>Anton Shcherbatov</dc:creator>
      <pubDate>Thu, 01 Jun 2023 19:10:50 +0000</pubDate>
      <link>https://dev.to/storvus/bottlesqlite-4off</link>
      <guid>https://dev.to/storvus/bottlesqlite-4off</guid>
      <description>&lt;p&gt;A few more words about Bottle. After enabling a sqlite extension, you can easily include a specified keyword as a view argument. Like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bottle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Bottle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;db_plugin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bottle_sqlite&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Plugin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dbfile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;./test.db&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;keyword&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;db&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;install&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db_plugin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="bp"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It works perfect... Until you decide to show the view for authorized users only. And this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@bottle.auth_basic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;save_post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;will cause&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TypeError("main() missing 1 required positional argument: 'db'")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a &lt;a href="https://github.com/bottlepy/bottle-sqlite/issues/21" rel="noopener noreferrer"&gt;known issue&lt;/a&gt;, which still wasn't solved on the plugin level. So, again &lt;a href="https://github.com/storvus/effective-pancake/blob/bottle/db/bottle_sqlite.py" rel="noopener noreferrer"&gt;workarounds&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The only change here is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;inspect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signature&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_callback&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;parameters&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;keyword&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;callback&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;instead of&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;argspec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;inspect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getargspec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_callback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Bottle</title>
      <dc:creator>Anton Shcherbatov</dc:creator>
      <pubDate>Tue, 30 May 2023 09:02:48 +0000</pubDate>
      <link>https://dev.to/storvus/bottle-4e33</link>
      <guid>https://dev.to/storvus/bottle-4e33</guid>
      <description>&lt;p&gt;Bottle is a really small python-based framework. The whole its code takes 1 file with ~4000 rows. Meanwhile, Bottle is pretty self-sufficient - it supports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;wsgi-server&lt;/li&gt;
&lt;li&gt;routing&lt;/li&gt;
&lt;li&gt;authorization&lt;/li&gt;
&lt;li&gt;plugins&lt;/li&gt;
&lt;li&gt;own templates language&lt;/li&gt;
&lt;li&gt;a lot of extensions (mostly one-paged too)&lt;/li&gt;
&lt;li&gt;custom error pages&lt;/li&gt;
&lt;li&gt;and much more!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I was excited trying to write my blog using Bottle. The first issue I faced - you can login, but you can't logout :D&lt;/p&gt;

&lt;p&gt;Bottle supports basic auth mechanism, so you can do something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;auth_callback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;  &lt;span class="c1"&gt;# or any check you want
&lt;/span&gt;
&lt;span class="nd"&gt;@bottle.auth_basic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auth_callback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;edit_post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;post_id&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="bp"&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;But there is no way to logout. The only workaround I found is to return 401 status as a response. It allows to force logout the user. It's not quite correct, because user doesn't expect to get 401Error on logout, but this is why it's called workaround.&lt;/p&gt;

&lt;p&gt;To make the solution to look more pretty I also customized 401 Error page, by adding an html-template with link to login.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;logout&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;bottle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@app.error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;error_401&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;bottle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;template&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;errors/401&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/logout/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GET&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;logout&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;As alternative, there is an extension for bottle, called bottle-login, which has been archived few years ago.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/klen" rel="noopener noreferrer"&gt;
        klen
      &lt;/a&gt; / &lt;a href="https://github.com/klen/bottle-login" rel="noopener noreferrer"&gt;
        bottle-login
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Implement users' sessions in Bottle framework
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="rst"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Bottle Login&lt;/h1&gt;

&lt;/div&gt;

&lt;p id="user-content-description"&gt;Bottle Login -- Implement users' sessions in Bottle web framework.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://travis-ci.org/klen/bottle-login" id="user-content-badges" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Build Status" src="https://camo.githubusercontent.com/b6631928b2ef707bd7532d03bfa24c36c16f804f0bcea213aa2e1a9967b6c51d/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f6b6c656e2f626f74746c652d6c6f67696e2e7376673f7374796c653d666c61742d737175617265"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://coveralls.io/r/klen/bottle-login" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Coverals" src="https://camo.githubusercontent.com/b2f5d575b13188b567aa56d46613baacaa9d015b8c15732a4cd8e79e0a1269c7/687474703a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6b6c656e2f626f74746c652d6c6f67696e2e7376673f7374796c653d666c61742d737175617265"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://pypi.python.org/pypi/bottle-login" rel="nofollow noopener noreferrer"&gt;&lt;img alt="http://img.shields.io/pypi/v/bottle-login.svg?style=flat-square" src="https://camo.githubusercontent.com/6feed94429eb82c2b8194d67888529018e24f29d994f867c371254288a29cb46/687474703a2f2f696d672e736869656c64732e696f2f707970692f762f626f74746c652d6c6f67696e2e7376673f7374796c653d666c61742d737175617265"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://pypi.python.org/pypi/bottle-login" rel="nofollow noopener noreferrer"&gt;&lt;img alt="http://img.shields.io/pypi/dm/bottle-login.svg?style=flat-square" src="https://camo.githubusercontent.com/ccb4f25b00c499f65a1bfad7d41adad8599fa06c9c873745d902e8c4c9e583c0/687474703a2f2f696d672e736869656c64732e696f2f707970692f646d2f626f74746c652d6c6f67696e2e7376673f7374796c653d666c61742d737175617265"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.gratipay.com/klen/" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Donate" src="https://camo.githubusercontent.com/11eb7ecb0a50ebc5e95e6b7f2580c67924cf18a3ee900e0551fdd1307eb6d658/687474703a2f2f696d672e736869656c64732e696f2f67726174697061792f6b6c656e2e7376673f7374796c653d666c61742d737175617265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div id="user-content-id1"&gt;
&lt;p&gt;Contents&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/klen/bottle-login#id2" id="user-content-id7" rel="noopener noreferrer"&gt;Requirements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/klen/bottle-login#id3" id="user-content-id8" rel="noopener noreferrer"&gt;Installation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/klen/bottle-login#id4" id="user-content-id9" rel="noopener noreferrer"&gt;Usage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/klen/bottle-login#bug-tracker" id="user-content-id10" rel="noopener noreferrer"&gt;Bug tracker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/klen/bottle-login#id5" id="user-content-id11" rel="noopener noreferrer"&gt;Contributing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/klen/bottle-login#contributors" id="user-content-id12" rel="noopener noreferrer"&gt;Contributors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/klen/bottle-login#id6" id="user-content-id13" rel="noopener noreferrer"&gt;License&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;&lt;a href="https://github.com/klen/bottle-login#id7" rel="noopener noreferrer"&gt;Requirements&lt;/a&gt;&lt;/h2&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;python &amp;gt;= 2.6&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;&lt;a href="https://github.com/klen/bottle-login#id8" rel="noopener noreferrer"&gt;Installation&lt;/a&gt;&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Bottle Login&lt;/strong&gt; should be installed using pip:&lt;/p&gt;

&lt;pre&gt;pip install bottle-login
&lt;/pre&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;&lt;a href="https://github.com/klen/bottle-login#id9" rel="noopener noreferrer"&gt;Usage&lt;/a&gt;&lt;/h2&gt;

&lt;/div&gt;

&lt;pre&gt;from bottle import Bottle, request, redirect
from bottle_login import LoginPlugin

app = Bottle()
app.config['SECRET_KEY'] = 'secret'

login = app.install(LoginPlugin())

&lt;a class="mentioned-user" href="https://dev.to/login"&gt;@login&lt;/a&gt;.load_user
def load_user_by_id(user_id):
    # Load user by id here


# Some application views

@app.route('/')
def index():
    current_user = login.get_user()
    return current_user.name

@app.route('/signout')
def signout():
    # Implement logout
    login.logout_user()
    return redirect('/')

@app.route('/signin')
def signin():
    # Implement login (you can check passwords here or etc)
    user_id = int(request.GET.get('user_id'))
    login.login_user(user_id)
    return redirect('/')
&lt;/pre&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;&lt;a href="https://github.com/klen/bottle-login#id10" rel="noopener noreferrer"&gt;Bug tracker&lt;/a&gt;&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;If you have any suggestions, bug reports or
annoyances please report them to the issue tracker
at &lt;a href="https://github.com/klen/bottle-login/issues" rel="noopener noreferrer"&gt;https://github.com/klen/bottle-login/issues&lt;/a&gt;&lt;/p&gt;


&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;&lt;a href="https://github.com/klen/bottle-login#id11" rel="noopener noreferrer"&gt;Contributing&lt;/a&gt;&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;Development of Bottle Login happens at: &lt;a href="https://github.com/klen/bottle-login" rel="noopener noreferrer"&gt;https://github.com/klen/bottle-login&lt;/a&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;&lt;a href="https://github.com/klen/bottle-login#id12" rel="noopener noreferrer"&gt;Contributors&lt;/a&gt;&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/klen" rel="noopener noreferrer"&gt;klen&lt;/a&gt; (Kirill Klenov)&lt;/li&gt;
&lt;/ul&gt;


&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;&lt;a href="https://github.com/klen/bottle-login#id13" rel="noopener noreferrer"&gt;License&lt;/a&gt;&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;Licensed under a &lt;a href="http://www.linfo.org/bsdlicense.html" rel="nofollow noopener noreferrer"&gt;BSD license&lt;/a&gt;.&lt;/p&gt;

&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/klen/bottle-login" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


</description>
      <category>bottle</category>
      <category>python</category>
      <category>auth</category>
    </item>
    <item>
      <title>First post</title>
      <dc:creator>Anton Shcherbatov</dc:creator>
      <pubDate>Mon, 29 May 2023 21:01:16 +0000</pubDate>
      <link>https://dev.to/storvus/first-post-4b6</link>
      <guid>https://dev.to/storvus/first-post-4b6</guid>
      <description>&lt;p&gt;Well, this is probably the first time when I use this title not for testing purposes. Although, this is still gonna be a part of experiment, where I'm trying different kind of frameworks, technologies, skills and share all the useful (for me) and interesting (again, for me) information.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
