[newbie]apache authentication questions

2006-06-12 Thread nuffnough
I have an apache 1.3.29 server that is running my website.  I have
written a bunch of scripts to generate the pages from csv files which
work great.

My next thing to learn is how to get user authentication functioning
the way I need it.

I understand the steps required to make .htpaccess files work,  but
this won't be enough for my purposes.  I want the site to remember that
a visitor has logged in or not,  and also to read a bunch of personal
info from a csv file dedicated to the userbase.  (A later project will
be to convert my csv files into databases,  but I am into baby steps at
the moment, so just focussing on python webiste authentication)

Ideally I would like this authentication to not be in the form of a
popup,  but rather via a username/password pair of fields at some place
on the page.  After authentication,  this should be reaplced by some
generic "have a nice day" kinda message,  or perhaps simply removed
altogether.  Additionally, they will be able to alter their personal
information and doing stuff like filling in the feedback form should
mean that they don't have to enter any personal info, just fill in the
details and click the send buttopn.  My experience with .htaccess files
is that they make an authentication popup,  which is not what I am
aiming at.

How can I incorporate this sort of user info in the apache
authentication stuff using python?

TIA!

Nuffnnough.

-- 
http://mail.python.org/mailman/listinfo/python-list


a n00b regex qestion

2007-12-03 Thread nuffnough
I am doing a string.replace in a simple table generation app I wrote,
and I can't figure out how to match whitespace with /s,  so  I thought
I would see if osmeone where would be kind enough to tell me what I am
getting wrong.


This works:

string = string.replace('\n  Field One
\n  %FieldOneValue%\n', '')


You can see I had to actually put in space characters and linefeeds
exactly as they are in the string.

I tried these this:

string = string.replace('\s*Field One\s*
%FieldOneValue%\s*', '')


But this doesn't work.  The doco for Python's regex suggests that \s
should match any whitespace including newlines which is what I
wanted,  but just in case,  I also tried this:

string = string.replace('\n\s*Field One\n
\s*%FieldOneValue%\n\s*', '')


Any help explaining why these are not working would be greatly
appreciated.

TIA

nuffi
-- 
http://mail.python.org/mailman/listinfo/python-list


Need help removing list elements.

2006-04-29 Thread nuffnough
This is python 2.4.3 on WinXP under PythonWin.

I have a config file with many blank lines and many other lines that I
don't need.

read the file in,  splitlines to make a list, then run a loop that
looks like this:



config_file = open("lines.txt", "rb")
returned_lines = config_file.read().splitlines()

i = len(returned_lines)


for i in range(i):
if returned_lines[i].find("Value") == -1:
if returned_lines[i].find("Name") == -1:
print "read in this useless line ..."
print returned_lines[i]
print "Removing line ..."
returned_lines[i] = ""




This blanks out all the lines I don't want.  I did originally try 'del
returned_lines[i]' but I got list index out of range, so I made a loop
to delete the empty elements.

for i in range(i):
if returned_lines[i] == "":

del returned_lines[i]



But this gives me "IndexError: list out of range

After much experimentation and dumping of the list, I have figured out
that it doesn't like removing multiple empty elements in a row.  In
other words, if there are 4 empty lines,  it will remove one of them,
and seems to behave as though that was one element instead of 3.  if I
make i = i - *number of groups of empty elements* it works without an
error,  but leaves many empty elements behind.

Obviously I can iterate over it time and again,  but that isn't how the
world should work.

Is this something obvious that I am doing wrong, or something more
complicated?

Any help will be gratefully appreciated!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need help removing list elements.

2006-04-29 Thread nuffnough
Thanks to all those who responded.  It has all helped immensely.  :-)

I didn't know about list comprehensions before I started.

very warm regards to all.

-- 
http://mail.python.org/mailman/listinfo/python-list


wxpython - new line in radiobutton's label?

2006-04-29 Thread nuffnough
Hi.

I am creating a small gui using wxGlade and wxPython.  I am using a
radio button, and the text next to the options needs to be over two
lines.  I tried using a \n character,  but it seems to get ignored.

Looking around in the various wikis and the example code also didn't
turn up anything.


TIA

-- 
http://mail.python.org/mailman/listinfo/python-list


Can I collapse a Panel in wxPython?

2006-04-30 Thread nuffnough
Hi.

I have a gui with one frame and 5 panels.  The second panel will only
be required in some cases,  so I am wondering if there is some way I
can only create this panel in the circumstances where it is required,
confirmed by a simple len(list) > 1

If it is possible, I am wondering how I might go about it  I am not
sure where to put an if statement as there are many different referrals
to panel_2

Letting me know or just pointing me to an example of such a thing would
be fabulous.

TIA

-- 
http://mail.python.org/mailman/listinfo/python-list


noob help request - how to make a list of defined class?

2008-09-09 Thread nuffnough


I have defined two classes with one common field (called code) and
several different fields.
In class A there is only one instance of any given code as all items
are individual.
In class B, there may be none, one or many instances of each code, as
there can be any number of Bs referring to a single A.

I need to make a list of Bs, remove dupes, and then create a list of
As that have Bs.

(I hope this makes sense!)

with much research and reading of my book I managed to get this
working,  but at one stage I had errors that talked about being unable
to concatenate type A.  So I converted my As to string, and then did a
split on commas to make a list.  This worked fine for all the As that
didn't have a comma in a field (about 85%) but I can't help feeling
that this is a kludge, and that if Icould find a way to get a proper
list of As instead of a list of lists created by converting to string
and splitting, then my app would work properly.

So I am hoping some of the nice folk here will help me out.

The relevent function looks like this:


def gen_B_A_list():
Bcodes = get_codes()
all_As = read_A("A.csv")
B_A = []
for i in range(len(codes)):
Bcode = Bcodes[i]
for A in all_As:
filename = getattr(A, 'code')
if filename == Bcode:
BA = str(A)
BA = string.split(BA, ',')
B_A.append(BA)
return B_A




The element in question is after if filename == Bcode.   How do I
construct a list of my defined class A objects here instead of this?
( I can post the full code if needed,  just thought it was better
netiquette not to)

TIA

nuffi
--
http://mail.python.org/mailman/listinfo/python-list


Newbie wxPython questions.

2006-04-07 Thread nuffnough
I am running through the wxPython guide and docs and extrapolating
enough to get confused.

BAsed on the tute in the getting started wiki I created a panel that
has most of the elements I want; some check boxes and a couple of
buttons.   The button I have is a simple thing that is supposed to just
close (destroy) the app.  Only thing is,  it destroys the panel and
leaves the app behind.   I have attempted to place this on teh frame by
defining a frame;  the button works great and closes the app,  but
because it isn't part of the panel, the panel is all squished up into
the very top left corner and all you can see is the first checkbox,
which you can't even check.  Can I make a button on the panel destroy
the frame?

The next question I have is about adding a second button to the panel
(or frame, I guess) that will then execute a bunch of things depending
on which checkboxes are ticked.  My attempts to add the button have
been wrong so far,  as you'll see with my code.

The first code block is my panel only app.  The second is how it looks
after I defined the Frame first and then moved the Cancel button.

TIA

Nuffnough



--

import wx, sys, os
class Form1(wx.Panel):
def __init__(self, parent, id):
wx.Panel.__init__(self, parent, id)
self.quote = wx.StaticText(self, -1, "Launching
:",wx.Point(20,30))

st = wx.StaticText(self, -1, "Select the applications you need
to launch:")#, (10, 10)

cb1 = wx.CheckBox(self, -1, "Read Calander, Check
Email")#,(65,40), (150, 20), wx.NO_BORDER)
cb2 = wx.CheckBox(self, -1, "Internet Browser")

self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb1)
self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb2)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.AddMany( [ cb1,
 cb2,
  ])

border = wx.BoxSizer(wx.VERTICAL)
border.Add(st, 0, wx.ALL, 15)
border.Add(sizer, 0, wx.LEFT, 50)
self.SetSizer(border)

pos = cb2.GetPosition().x + cb2.GetSize().width + 25
btn0 = wx.Button(self, -1, "Cancel", (pos, 150))
self.Bind(wx.EVT_BUTTON, self.OnCloseMe, btn0)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

'''  Commented out btn1 cause I couldn't make it work
btn1 = wx.Button(self, -1, "Open Apps", (pos + 60, 150))
self.Bind(wx.EVT_BUTTON, self.OnTestButton, btn1)
'''

def EvtCheckBox(self, event):
self.log.write('EvtCheckBox: %d\n' % event.IsChecked())
cb = event.GetEventObject()
if cb.Is3State():
self.log.write("\t3StateValue: %s\n" % cb.Get3StateValue())


def OnTestButton(self, evt):
self.cb1.SetString(1, "FUBAR")

def OnCloseMe(self, event):
self.Close(True)

def OnCloseWindow(self, event):
self.Destroy()



app = wx.PySimpleApp()
frame = wx.Frame(None, -1, "An application launcher")
Form1(frame, -1)
frame.Show(1)
app.MainLoop()





--




import wx, sys, os

ID_ABOUT = 101
ID_EXIT = 110

class Frame1(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,wx.ID_ANY, title, size =
(300, 400), style=wx.DEFAULT_FRAME_STYLE)
#self.control = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)
self.CreateStatusBar() # A Statusbar in the bottom of the
window
# Setting up the menu.
filemenu= wx.Menu()
filemenu.Append(ID_ABOUT, "&About"," Information about this
program")
filemenu.AppendSeparator()
filemenu.Append(ID_EXIT,"E&xit"," Terminate the program")
# Creating the menubar.
menuBar = wx.MenuBar()
menuBar.Append(filemenu,"&File") # Adding the "filemenu" to
the MenuBar
self.SetMenuBar(menuBar)  # Adding the MenuBar to the Frame
content.

pos = 20
btn0 = wx.Button(self, -1, "Button Text", (pos, 220))
self.Bind(wx.EVT_BUTTON, self.OnCloseMe, btn0)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)


#def OnTestButton(self, evt):
#Run some code that checks which boxes are ticked
#Then perform a function for each ticked box

def OnCloseMe(self, event):
self.Close(True)

def OnCloseWindow(self, event):
self.Destroy()

self.Show(True)


class Form1(wx.Panel):
def __init__(self, parent, id):
wx.Panel.__init__(self, parent, id)
self.quote = wx.StaticText(self, -1, "Choose Applications
:",wx.Point(20,30))

st = wx.StaticText(self, -1, "Select the application(s) you
need to open:")#, (10, 10)

cb1 = wx.CheckBox(self, -1, "Email, Calender")#,(65,4