what is the current state of user authentication? is it good to go with openid or another alternative, or we still have to write our own user/password?
Is there a way to test the html from the response of:
response = self.client.get('/user/login/')
I want a detailed check like input ids, and other attributes. Also, how about sessions that has been set? is it possible to check their values in the test?
Hi,
I want to store a number of url patterns in my django model which a user can provide parameters to which will create a url.
For example I might store these 3 urls in my db where %s is the variable parameter provided by the user:
www.thisissomewebsite.com?param=%s
www.anotherurl/%s/
www.lastexample.co.uk?param1=%s&fixedparam=2
As you can see from these examples the parameter can appear anywhere in the string and not in a fixed position.
I have 2 models, one holds the urls and one holds the variables:
class URLPatterns(models.Model):
pattern = models.CharField(max_length=255)
class URLVariables(models.Model):
pattern = models.ForeignKey(URLPatterns)
param = models.CharField(max_length=255)
What would be the best way to generate these urls by replacing the %s with the variable in the database.
would it just be a simple replace on the string e.g:
urlvariable = URLVariable.objects.get(pk=1)
pattern = url.pattern
url = pattern.replace("%s", urlvariable.param)
or is there a better way?
Thanks
im using sqlalchemy, and i have a few polymorphic tables, and i want to sort by a column in one of the relationship.
i have tables a,b,c,d, with relationship a to b, b to c, c to d.
a to b is one-to-many
b to c and c to d are one-to-one, but polymorphic.
given an item in table a, i will have a list of items b, c, d (all one to one). how do i use sqlalchemy to sort them by a column in table d?
I want to rewrite TCP/IP streams. Ettercap's etterfilter command lets you perform simple live replacements of TCP/IP data based on fixed strings or regexes. Example:
if (ip.proto == TCP && tcp.dst == 80) {
if (search(DATA.data, "gzip")) {
replace("gzip", " ");
msg("whited out gzip\n");
}
}
if (ip.proto == TCP && tcp.dst == 80) {
if (search(DATA.data, "deflate")) {
replace("deflate", " ");
msg("whited out deflate\n");
}
}
http://ettercap.sourceforge.net/forum/viewtopic.php?t=2833
I would like to rewrite streams based on my own filter program instead of just simple string replacements.
Anyone have an idea of how to do this? Is there anything other than Ettercap that can do live replacement like this, maybe as a plugin to a VPN software or something?
The rewriting should occur at the transport layer (Layer 4) as it does in this example, instead of a lower layer packet-based approach.
Thanks!
Using Tastypie and GeoDjango, I'm trying to return results of buildings located within 1 mile of a point.
The TastyPie documentation states that distance lookups are not yet supported, but I am finding examples of people getting it work, such as this discussion and this discussion on StackOverflow, but no working code examples that can be applied.
The idea that I am trying to work with is if I append a GET command to the end of a URL, then nearby locations are returned, for example:
http://website.com/api/?format=json&building_point__distance_lte=[{"type": "Point", "coordinates": [153.09537, -27.52618]},{"type": "D", "m" : 1}]
But when I try that, all I get back is:
{"error": "Invalid resource lookup data provided (mismatched type)."}
I've been pouring over the Tastypie document for days now and just can't figure out how to implement this.
I'd provide more examples, but I know they'd be all terrible. All advice is appreciated, thank you!
i am raising exception using
if UserId == '' and Password == '':
raise Exception.MyException , "wrong userId or password"
but i want print the error message on same page
class MyException(Exception):
def __init__(self,msg):
Exception.__init__(self,msg)
Write an iterative program that finds the largest number of McNuggets that cannot be bought in exact quantity. Your program should print the answer in the following format (where the correct number is provided in place of n):
"Largest number of McNuggets that cannot be bought in exact quantity: n"
I am trying some simple c API, where I am using PyCapsule_New to encapsulate a pointer. I am running into segment violation, can some body help me.
mystruct *func1(int streamno, char mode,unsigned int options)
{
char * s;
s=malloc(100);
return s;
}
PyObject *Wrapper_func1(PyObject *self, PyObject *args)
{
int streamno;
char mode;
unsigned int options;
mystruct* result;
if (!PyArg_ParseTuple(args,"icI",&streamno,&mode,&options))
return NULL;
result = func1(streamno,mode,options);
return PyCapsule_New( result,NULL,NULL);
}
This is a module named XYZ.
def func(x)
.....
.....
if __name__=="__main__":
print func(sys.argv[1])
Now I have imported this module in another code and want to use the func. How can i use it?
import XYZ
After this, where to give the argument, and syntax on how to call it, please?
MYMESSAGE = "<div>Hello</div><p></p>Hello"
send_mail("testing",MYMESSAGE,"[email protected]",['[email protected]'],fail_silently=False)
However, this message doesn't get the HTML mime type when it is sent. In my outlook, I see the code...
I am working on large numpy arrays, and some native numpy operations are too slow for my needs (for example simple operations such as "bitwise" A&B).
I started looking into writing C extensions to try and improve performance. As a test case, I tried the example given here, implementing a simple trace calculation. I was able to get it to work, but was surprised by the performance: for a (1000,1000) numpy array, numpy.trace() was about 1000 times faster than the C extension!
This happens whether I run it once or many times. Is this expected? Is the C extension overhead that bad? Any ideas how to speed things up?
The title says it all. The objective is to have two simple ways to source some code, say func.R, containing a function. Calling R CMD BATCH func.R initializes the function and evaluates is. Within a session, issuing source("func.R") simply initializes the function.
Any idea?
I am the create_user() function that Django provides to create my users. Also I want to store additional information about the users. So I tried following the instructions given at
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
but I cannot get it to work for me. Is there a step-by-step guide that I can follow to get this to work for me?
Also, once I have added these custom fields, I would obviously need to add / edit / delete data from them. I cannot seem to find any instructions on how to do this.
A minimal example:
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent = None):
QtGui.QMainWindow.__init__(self, parent)
winWidth = 683
winHeight = 784
screen = QtGui.QDesktopWidget().availableGeometry()
screenCenterX = (screen.width() - winWidth) / 2
screenCenterY = (screen.height() - winHeight) / 2
self.setGeometry(screenCenterX, screenCenterY, winWidth, winHeight)
layout = QtGui.QVBoxLayout()
layout.addWidget(FormA())
mainWidget = QtGui.QWidget()
mainWidget.setLayout(layout)
self.setCentralWidget(mainWidget)
FormA is a QFrame with a VBoxLayout that can expand to an arbitrary number of entries.
In the code posted above, if the entries in the forms can't fit in the window then the window itself grows. I'd prefer for the window to become scrollable. I've also tried the following...
replacing
mainWidget = QtGui.QWidget()
mainWidget.setLayout(layout)
self.setCentralWidget(mainWidget)
with
mainWidget = QtGui.QScrollArea()
mainWidget.setLayout(layout)
self.setCentralWidget(mainWidget)
results in the forms and entries shrinking if they can't fit in the window.
Replacing it with
mainWidget = QtGui.QWidget()
mainWidget.setLayout(layout)
scrollWidget = QtGui.QScrollArea()
scrollWidget.setWidget(mainWidget)
self.setCentralWidget(scrollWidget)
results in the mainwidget (composed of the forms) being scrunched in the top left corner of the window, leaving large blank areas on the right and bottom of it, and still isn't scrollable.
I can't set a limit on the size of the window because I wish for it to be resizable.
How can I make this window scrollable?
How to identify which server side script language was used with a web site?
Asp.Net? PHP? RoR? Java? or other?
For example, Which server side script language was used with stackoverflow.com?
I have written the following script. It opens a file, reads each line from it splitting by new line character and deleting first character in line. If line exists it's being added to array. Next each element of array is splitted by whitespace, sorted alphabetically and joined again. Every line is printed because script is fired from console and writes everything to file using standard output. I'd like to optimize this code to be more pythonic. Any ideas ?
import sys
def main():
filename = sys.argv[1]
file = open(filename)
arr = []
for line in file:
line = line[1:].replace("\n", "")
if line:
arr.append(line)
for line in arr:
lines = line.split(" ")
lines.sort(key=str.lower)
line = ''.join(lines)
print line
if __name__ == '__main__':
main()
I've searched around other threads with similar questions, but I'm not finding the answer. Basically, I have a class:
import Android_Class
class Android_Revision(object):
def __init__(self):
# dict for storing the classes in this revision
# (format {name : classObject}):
self.Classes = {}
self.WorkingClass = Android_Class()
self.RevisionNumber = ''
def __call__(self):
print "Called"
def make_Class(self, name):
newClass = Android_Class(name)
self.Classes.update({name : newClass})
self.WorkingClass = newClass
def set_Class(self, name):
if not(self.Classes.has_key(name)):
newClass = Android_Class(name)
self.Classes.update({name : newClass})
self.WorkingClass = self.Classes.get(name)
I'm trying to make an instance of this class:
Revision = Android_Revision()
and that's when I'm getting the error. I'm confused because I have another situation where I'm doing almost the exact same thing, and it's working fine. I can't figure out what differences between the two would lead to this error. Thanks.
Hey,
I'm running a function which evaluates commands passed in using stdin and another function which runs a bunch of jobs. I need to make the latter function sleep at regular intervals but that seems to be blocking the stdin. Any advice on how to resolve this would be appreciated.
The source code for the functions is
def runJobs(comps, jobQueue, numRunning, limit, lock):
while len(jobQueue) >= 0:
print(len(jobQueue));
if len(jobQueue) > 0:
comp, tasks = find_computer(comps, 0);
#do something
time.sleep(5);
def manageStdin():
print "Global Stdin Begins Now"
for line in fileinput.input():
try:
print(eval(line));
except Exception, e:
print e;
--Thanks
hi people, i wanna make change in css class every 3 loop. In the first three i want to use the CSS class A, in the next three i want to use the CSS class B, in the next three i want to use the CSS class A again and so on.
can anyone help? Thanks
On example, i have 2 apps: alpha and beta
in alpha/models.py import of model from beta.models
and in beta/models.py import of model from alpha.models
manage.py validate says that ImportError: cannot import name ModelName
how to solve this problem?
Hello,
I'm making a toolbar using wxpython and I want to put the Quit button on the right side of it, I don't want to put them sequencially.
Is it possible to define this position?
Thanks in advance!