Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37034

Re: Uniquely identifying each & every html template

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'key.': 0.07; 'rewrite': 0.07; 'suppose': 0.07; 'table.': 0.07; 'python': 0.09; '(without': 0.09; 'added.': 0.09; 'filenames,': 0.09; 'identifier': 0.09; 'identifier,': 0.09; 'template': 0.11; 'files.': 0.13; 'advance.': 0.15; '(eg.': 0.16; 'creating,': 0.16; 'index.html': 0.16; 'order?': 0.16; 'rewriting': 0.16; 'sources,': 0.16; 'string': 0.17; 'wrote:': 0.17; 'supposed': 0.21; 'embedding': 0.22; 'modifying': 0.22; 'skip:% 10': 0.22; 'insert': 0.23; 'external': 0.24; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; '(e.g.': 0.27; 'checking': 0.27; 'separate': 0.27; 'question': 0.27; 'have,': 0.27; 'embed': 0.29; 'hash': 0.29; 'key,': 0.29; 'case,': 0.29; 'words': 0.29; 'normally': 0.30; 'figure': 0.30; 'stuff': 0.30; 'problem.': 0.32; 'file': 0.32; 'not.': 0.32; "skip:' 20": 0.32; 'sources': 0.32; 'could': 0.32; 'directory,': 0.33; 'like:': 0.33; 'problem': 0.33; 'to:addr :python-list': 0.33; 'list': 0.35; 'desirable': 0.35; 'path': 0.35; 'replaced': 0.35; 'requiring': 0.35; 'so,': 0.35; 'open': 0.35; 'expected': 0.35; 'pm,': 0.35; 'there': 0.35; 'created': 0.36; 'but': 0.36; "didn't": 0.36; 'thank': 0.36; 'enough': 0.36; 'ones': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'files': 0.38; 'mean': 0.38; 'some': 0.38; 'page': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'list,': 0.39; 'received:192.168': 0.40; 'help': 0.40; 'your': 0.60; 'real': 0.61; 'containing': 0.61; 'identify': 0.61; 'first': 0.61; 'back': 0.62; 'information': 0.63; 'contents.': 0.65; 'pin': 0.65; 'webpage': 0.65; 'cms': 0.66; 'subject: & ': 0.67; 'received:74.208': 0.71; 'again?': 0.84; 'choices:': 0.84; 'dreamweaver': 0.84; 'situations,': 0.84; 'skip:/ 30': 0.91; 'task,': 0.91; 'joomla': 0.93; 'have.': 0.95
Date Fri, 18 Jan 2013 17:09:28 -0500
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2
MIME-Version 1.0
To python-list@python.org
Subject Re: Uniquely identifying each & every html template
References <8deb6f5d-ff10-4b36-bdd6-36f9eed58e1e@googlegroups.com>
In-Reply-To <8deb6f5d-ff10-4b36-bdd6-36f9eed58e1e@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:IXWpviusoWpDtcdlIM2GfFKTKvJ/OdQyPfmQ7ucV/hm 7LSHw2+gFlERqRA39cxm68aKwyxaAxzIY7wyCpGEGmvMgDzDdc KUckM6+Ri8NMl4okHvuOCBkByt0WGjwMhD6Ik13oCkXRmDOgVW xROhBmuYXcQsbRdB3h8X9C2rP5akzjlZK0VGguT+bFtjutbzae H+zGSk5z+ebqfdkuaD3ABllwcax2Fw0xVON62DL0TOgeTslTcO DF2DOh/sMabxowfn3nM+OwpOpRhPBbqQlytiZqmr54yJv0MYeU 4yvwTvJK0TR55RYlXVKL5JNrLAoP9WKxIfahNa4WEAD3Tu4/g= =
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.655.1358546994.2939.python-list@python.org> (permalink)
Lines 73
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1358546994 news.xs4all.nl 6919 [2001:888:2000:d::a6]:35438
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:37034

Show key headers only | View raw


On 01/18/2013 03:48 PM, Ferrous Cranus wrote:
> I use this .htaccess file to rewrite every .html request to counter.py
>
> # =================================================================================================================
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} -f
> RewriteRule ^/?(.+\.html) /cgi-bin/counter.py?htmlpage=$1 [L,PT,QSA]
> # =================================================================================================================
>
>
>
> counter.py script is created for creating, storing, increasing, displaying a counter for each webpage for every website i have.
> It's supposed to identify each webpage by a <!-- Number --> and then do it's database stuff from there
>
> # =================================================================================================================
> # open current html template and get the page ID number
> # =================================================================================================================
> f = open( '/home/nikos/public_html/' + page )
>
> # read first line of the file
> firstline = f.readline()
>
> # find the ID of the file and store it
> pin = re.match( r'<!-- (\d+) -->', firstline ).group(1)
> # =================================================================================================================
>
> It works as expected and you can see it works normally by viewing: http//superhost.gr (bottom down its the counter)
>
> What is the problem you ask?!
> Problem is that i have to insert at the very first line of every .html template of mine, a unique string containing a number like:
>
> index.html      <!-- 1 -->
> somefile.html   <!-- 2-->
> other.html      <!-- 3 -->
> nikos.html      <!-- 4 -->
> cool.html       <!-- 5 -->
>
> to HELP counter.py identify each webpage at a unique way.
>
> Well.... its about 1000 .html files inside my DocumentRoot and i cannot edit ALL of them of course!
> Some of them created by Notepad++, some with the use of Dreamweaver and some others with Joomla CMS
> Even if i could embed a number to every html page, it would have been a very tedious task, and what if a change was in order? Edit them ALL back again? Of course not.
>
> My question is HOW am i suppose to identify each and every html webpage i have, without the need of editing and embedding a string containing a number for them. In other words by not altering their contents.
>
> or perhaps by modifying them a bit..... but in an automatic way....?
>
> Thank you ALL in advance.
>
>

I don't understand the problem.  A trivial Python script could scan 
through all the files in the directory, checking which ones are missing 
the identifier, and rewriting the file with the identifier added.

So, since you didn't come to that conclusion, there must be some other 
reason you don't want to edit the files.  Is it that the real sources 
are elsewhere (e.g. Dreamweaver), and whenever one recompiles those 
sources, these files get replaced (without identifiers)?

If that's the case, then I figure you have about 3 choices:

1) use the file path as your key, instead of requiring a number
2) use a hash of the page  (eg. md5) as your key.  of course this could 
mean that you get a new value whenever the page is updated.  That's good 
in many situations, but you don't give enough information to know if 
that's desirable for you or not.
3) Keep an external list of filenames, and their associated id numbers. 
  The database would be a good place to store such a list, in a separate 
table.

-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-18 12:48 -0800
  Re: Uniquely identifying each & every html template John Gordon <gordon@panix.com> - 2013-01-18 20:59 +0000
    Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-18 14:12 -0800
  Re: Uniquely identifying each & every html template Dave Angel <d@davea.name> - 2013-01-18 17:09 -0500
    Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-19 00:39 -0800
      Re: Uniquely identifying each & every html template Dave Angel <d@davea.name> - 2013-01-19 04:00 -0500
        Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-20 23:08 -0800
          Re: Uniquely identifying each & every html template Chris Angelico <rosuav@gmail.com> - 2013-01-21 18:20 +1100
            Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 01:19 -0800
              Re: Uniquely identifying each & every html template Chris Angelico <rosuav@gmail.com> - 2013-01-21 20:31 +1100
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 04:06 -0800
                Re: Uniquely identifying each & every html template Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-21 12:39 +0000
                Re: Uniquely identifying each & every html template alex23 <wuwei23@gmail.com> - 2013-01-21 04:55 -0800
                Re: Uniquely identifying each & every html template rusi <rustompmody@gmail.com> - 2013-01-21 19:24 -0800
                Re: Uniquely identifying each & every html template Chris Angelico <rosuav@gmail.com> - 2013-01-22 15:39 +1100
                Re: Uniquely identifying each & every html template Tom P <werotizy@freent.dd> - 2013-01-22 00:01 +0100
                Re: Uniquely identifying each & every html template Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-01-21 23:43 +0000
                Re: Uniquely identifying each & every html template Chris Angelico <rosuav@gmail.com> - 2013-01-22 11:04 +1100
                Re: Uniquely identifying each & every html template alex23 <wuwei23@gmail.com> - 2013-01-22 17:36 -0800
                Re: Uniquely identifying each & every html template Joel Goldstick <joel.goldstick@gmail.com> - 2013-01-21 07:47 -0500
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 07:00 -0800
                Re: Uniquely identifying each & every html template Michael Torrie <torriem@gmail.com> - 2013-01-22 16:55 -0700
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-23 01:12 -0800
                Re: Uniquely identifying each & every html template alex23 <wuwei23@gmail.com> - 2013-01-23 01:37 -0800
                Re: Uniquely identifying each & every html template Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-01-23 09:49 +0000
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-23 02:29 -0800
                Re: Uniquely identifying each & every html template Joel Goldstick <joel.goldstick@gmail.com> - 2013-01-23 07:03 -0500
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-23 04:26 -0800
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-23 04:26 -0800
                Re: Uniquely identifying each & every html template alex23 <wuwei23@gmail.com> - 2013-01-23 06:25 -0800
                Re: Uniquely identifying each & every html template Dave Angel <d@davea.name> - 2013-01-23 07:38 -0500
                Re: Uniquely identifying each & every html template Chris Angelico <rosuav@gmail.com> - 2013-01-24 10:25 +1100
                Re: Uniquely identifying each & every html template Dave Angel <d@davea.name> - 2013-01-23 19:09 -0500
                Re: Uniquely identifying each & every html template Chris Angelico <rosuav@gmail.com> - 2013-01-24 11:39 +1100
                Re: Uniquely identifying each & every html template Dave Angel <d@davea.name> - 2013-01-23 19:53 -0500
                Re: Uniquely identifying each & every html template Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-01-23 16:01 -0500
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-23 01:12 -0800
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 07:00 -0800
                Re: Uniquely identifying each & every html template Dave Angel <d@davea.name> - 2013-01-21 17:26 -0500
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 04:06 -0800
                Re: Uniquely identifying each & every html template Tim Roberts <timr@probo.com> - 2013-01-21 19:57 -0800
              Re: Uniquely identifying each & every html template Tim Roberts <timr@probo.com> - 2013-01-21 20:04 -0800
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 22:49 -0800
                Re: Uniquely identifying each & every html template Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-01-22 16:08 -0500
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-23 01:15 -0800
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-23 01:15 -0800
            Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 01:19 -0800
              Re: Uniquely identifying each & every html template alex23 <wuwei23@gmail.com> - 2013-01-21 04:56 -0800
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 07:03 -0800
                Re: Uniquely identifying each & every html template alex23 <wuwei23@gmail.com> - 2013-01-21 15:35 -0800
              Re: Uniquely identifying each & every html template Piet van Oostrum <piet@vanoostrum.org> - 2013-01-21 21:48 +0100
                Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 22:38 -0800
            Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 07:07 -0800
              Re: Uniquely identifying each & every html template alex23 <wuwei23@gmail.com> - 2013-01-21 15:36 -0800
              Re: Uniquely identifying each & every html template rusi <rustompmody@gmail.com> - 2013-01-21 20:18 -0800
            Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 07:07 -0800
        Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-20 23:08 -0800
      Re: Uniquely identifying each & every html template Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-01-19 16:32 -0500
        Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-20 22:52 -0800
        Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-20 22:52 -0800
      Re: Uniquely identifying each & every html template John Gordon <gordon@panix.com> - 2013-01-22 16:35 +0000
    Re: Uniquely identifying each & every html template Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-19 00:39 -0800

csiph-web