Does that actually allocate the memory? If it does, I assume each entry only contains garbage.
It does allocate the memory, and if I recall, it should contain garbage when compiled without debug info. With debug info usually initializes your values.
Global variables are default-initialized, but I'm not sure if that carries through to members of global variables.
He specified C, so it's zeroed, not default initialized. Either way though, I believe the result should be all elements of all structures being zeroed.
It should be easy enough to verify whether it's being zeroed properly.
Global variables are default-initialized, but I'm not sure if that carries through to members of global variables.
He specified C, so it's zeroed, not default initialized. Either way though, I believe the result should be all elements of all structures being zeroed.
It should be easy enough to verify whether it's being zeroed properly.
I just looked up the standard, and members are recursively zeroed/default-initialized (semantics) according to section 6.7.8.10
The execution environment includes several environment variables useful to the application. Some of these are special to App Engine, while others are part of the CGI standard. Python code can access these variables using the os.environ dictionary.
Either way, I'm only using the URL, browser string, and IP variables. I don't think those would depend on the environment.
Wait, they're using webob now?
And django templates?
That's weird. Or maybe they're just letting you choose parts?
Okay, anyway, there's two problems with using os.environ:
It's a CGI thing, so if you take your code out of a CGI environment, your code won't work. I'm sort of surprised that google would be using CGI, since it follows the fork and execute once style. It's not portable, such as if you wrote some code and wanted it to work under mod_wsgi (the usual method of hosting python code in the while) or some other similar mechanism (I've actually been working on a FastCGI process manager that deals with WSGI).
It's low level. That's still a problem with using the environ dict (which is a copy of os.environ when we're using CGI) passed to a WSGI application callback though. There's some corner cases you might miss, and you may have to do things by hand.
So yeah, use whatever request object you're given. If they give you nothing, I guess you're best just passing os.environ to webob.Request(), since at least you won't have os.environ scattered everywhere, and then that way you also won't have to parse that shit out by hand.
Anyway, django is usual MVC web framework. All of django's parts are custom, from the database abstraction layer to the templating engine.
And then you have a framework like pylons. Pylons itself is basically just trying to tie a bunch of libraries together into a coherent framework, but basically you have parts like: webob, sqlalchemy or sqlobject, and mako or Genshi or whatever.
So webob is just webob, it mostly just implements your request and response objects, but django doesn't actually use webob.
End on
I wish that someway, somehow, that I could save every one of us
I think Google's webapp framework is supposed to be a mashup of Google's own stuff and pieces of other frameworks. Everything I'm using is in webapp. That means some non-Google docs get confusing, but it means everything you use is built to run just right on their platform.
The bonus of doing it entirely with Google's thing is that I can be the amateur that I am and still produce a simple, functional, secure, and efficient web application. I can't imagine ever getting interested enough in this to do it better than Google's engineers.
Since all I want to do is create an easy way to add, change, and display content, this works out great for me. :rotate:
Im trying that program that I mentioned a few pages back, for making a mini-database for the dog rescue program my moms a part of. So far I have how the stored data (a txt file) is gonna be formatted. I also have a working example of what everything in the program will look like when it returns the searched dog entry.
Im using a string vector for the output, with the idea being, when im done, to be able to change the size of the vector rather 1 dog is returned in a search, or 10, as it returns 11 strings for each dog.
My problem right now is searching for the dog. I'd like for it to work where if they typed in Pete, it would do a search in the file for pete, then start the string returns from there. It would also return anything that said Petey or Peter or Petenski or whatever. I tried doing a string compare, but it wouldnt run for a variety of reasons, the most of which is likely my own idiocy.
This is the last stable/somewhat working version I have. Its not too clean, and Im gonna be changing pretty much everything by the time this is done.
Stupid txt file is wordwrapping instead of breaking hscroll. Each line should begin with a dog name and end with *No notes
Schipperke rescue project
Beginner project to created a database of dogs currently in the rescue system of CSC
WIP
Features:
Catergorizes dogs by gender, Spay/Neuter, Name, Region, status (foster, adopted,) dates they need to be moved?
*/
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int i= 0, last, v;
vector <string> dbo(11); //dbo=database output, going to eventually change the 11 to a variable
ifstream records("skipdb.txt");
if(! records)
{
cout<<"Unable to open records database" <<endl;
return -1;
}
while (i<11) //will eventually be a variable
{
if ((i+1)==11) getline(records, dbo[i++]); //
else getline(records, dbo[i++], '*'); //asterick is used as a delimiter
dbo.resize(i+1); /*this may be unnecesarry at this point, dont have time to reread everything and double check. i may have left it in from when I was messing with the integer for the vector*/
}
last=i;
i=0;
while (i<last)
{
cout<<"\nName:\t\t" <<dbo[i++] <<endl;
cout<<"DOB:\t\t" <<dbo[i++] <<endl;
cout<<"Source:\t\t" <<dbo[i++] <<endl;
cout<<"Gender\t\t" <<dbo[i++] <<endl;
cout<<"Spay/Neutred? \t" <<dbo[i++] <<endl;
cout<<"Age: \t\t" <<dbo[i++] <<endl;
cout<<"Foster?: \t" <<dbo[i++] <<endl;
cout<<"Status: \t" <<dbo[i++] <<endl;
cout<<"Completion: \t" <<dbo[i++] <<endl;
cout<<"Assignment: \t" <<dbo[i++] <<endl;
cout<<"Notes:\t \t" <<dbo[i++] <<endl;
}
records.close();
return 0;
}
There's loads of free DB engines that plug right in and can follow the program around easily. The only reason I could see making your own would be if you needed to do some low-level processing that wasn't provided by an existing DB engine.
CouchDB seems to be a popular choice these days, though there's some issue with it that affects certain use cases. I just can't think of what it is right now.
Because im new and dumb and didnt know there were alternatives or how they would possibly work.
Ill look at couchDB tonight though.
It looks like CouchDB requires setting up a server. However, as long as you have sufficient control over the environment, I don't think that would be an issue. If you ever wanted to distribute this, you might want to give greater weight to the amount of work a user needs to do to get it running.
I see SQLite in a few very high profile applications and never had to install a server for them, so that might be a good alternative.
This will probably have a distribution rate of between 1 and 0. Really alot of this functionalty that I need could probably be done in excel. I just wanted to see if I could do it/how much I could
As far as user ease, I was going to have adding/removing entries be done while using the program, editting/appending/deleting strings using fstream.
A lot of things are done in spreadsheets that are better done in databases, and a lot of things are done in databases that are better done in spreadsheets. A lot of things are done in flat files that would be better done in either.
Here's what I use to decide: I think about what's going in, and how it'll be to manage the data.
Will I need to process it? You can do processing in a spreadsheet, but if you need to generate a report, you're either limited to the program's reporting mechanisms, or you're in for a world of pain.
Will it contain weird strings? Writing a parser can be pretty hard, and weird things can happen to delimiters if the wrong character gets input. You're responsible for making sure the data is sane, and data can be weird. People who make and distribute DB engines tend to think about that a lot more, and will be better at it.
Is it a few columns with simple text or numbers? It's easier to dump a database to a text file than the other way around, so you may regret a flat file even if it makes sense.
Keep asking questions like that until you run out of things to ask, and you'll be better prepared to decide on a storage method.
The thing you're doing doesn't seem complex enough for a more complicated DB. And there seem to be a lot of people who use SQLite in here, so you'll get help fast if you need it.
MKR on
0
GnomeTankWhat the what?Portland, OregonRegistered Userregular
edited September 2010
Just seconding (thirding? fourthing?) SQLite, it's pretty awesome.
I'd probably recommend Postgre for a "server" based database if you ever need one. Compiling your shit from source is okay for the generic nerdguy at home for his bbs, but for us guys (maybe just me) doing that every day, for every update, for every system, for every package is a fucking nightmare.
bowen on
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
0
GnomeTankWhat the what?Portland, OregonRegistered Userregular
edited September 2010
I prefer MySQL over Postgre, but it's really personal preference.
Obviously, we should do everything in Visual FoxPro. It's up to v 9.0. That means it's super good. It's a database and a programming language.
I fucking hate you.
You know why? Because I'm in the process of converting VFP7 to SQL... and I guess you could say c# for the logic bits.
It did do some really weird shit with databases though. Like to fill a combo box apparently all you've got to do is "USE somefile.dbf" and then set the control source to a column in that table.
If anything it's like access++.
bowen on
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
Posts
Does django have something that makes doing this easier?
I thought it was just a template system. I've been using it for that purpose.
edit: It looks like getting that to work on App Engine is more trouble that I want to deal with.
#define MAP_SIZE 100000; typedef struct me{ char *word; LetInv inv; struct me *next; } MapEntry; MapEntry map[MAP_SIZE];Does that actually allocate the memory? If it does, I assume each entry only contains garbage.
DAMN YOU BRAIN AND YOUR MORTAL LIMITATIONS
I'm giving up on it for tonight though, ty.
He specified C, so it's zeroed, not default initialized. Either way though, I believe the result should be all elements of all structures being zeroed.
It should be easy enough to verify whether it's being zeroed properly.
def db_loadpage( name ): try: page = loaded_page thedb = PageDB.all().filter("name = ", name).get() if thedb is not None: page.content = thedb.content page.name = thedb.name page.type = thedb.type page.createdate = thedb.createdate page.breadcrumb = thedb.breadcrumb page.publishstatus = thedb.publishstatus page.title = thedb.title return page else: page.content = "test" page.name = "test" page.type = "test" page.createdate = "test" page.breadcrumb = "test" page.publishstatus = "test" page.monetization = "test" page.title = "test" return page except DBDLoadFail as err: #to be logged to the DB later print("Caught exception; code %s, message %s" % (err.code, err.message))PageDB represents the model used by App Engine to access the datastore.
Wait, they're using webob now?
And django templates?
That's weird. Or maybe they're just letting you choose parts?
Okay, anyway, there's two problems with using os.environ:
So yeah, use whatever request object you're given. If they give you nothing, I guess you're best just passing os.environ to webob.Request(), since at least you won't have os.environ scattered everywhere, and then that way you also won't have to parse that shit out by hand.
Anyway, django is usual MVC web framework. All of django's parts are custom, from the database abstraction layer to the templating engine.
And then you have a framework like pylons. Pylons itself is basically just trying to tie a bunch of libraries together into a coherent framework, but basically you have parts like: webob, sqlalchemy or sqlobject, and mako or Genshi or whatever.
So webob is just webob, it mostly just implements your request and response objects, but django doesn't actually use webob.
Since all I want to do is create an easy way to add, change, and display content, this works out great for me. :rotate:
Im using a string vector for the output, with the idea being, when im done, to be able to change the size of the vector rather 1 dog is returned in a search, or 10, as it returns 11 strings for each dog.
My problem right now is searching for the dog. I'd like for it to work where if they typed in Pete, it would do a search in the file for pete, then start the string returns from there. It would also return anything that said Petey or Peter or Petenski or whatever. I tried doing a string compare, but it wouldnt run for a variety of reasons, the most of which is likely my own idiocy.
This is the last stable/somewhat working version I have. Its not too clean, and Im gonna be changing pretty much everything by the time this is done.
Stupid txt file is wordwrapping instead of breaking hscroll. Each line should begin with a dog name and end with *No notes
Schipperke rescue project Beginner project to created a database of dogs currently in the rescue system of CSC WIP Features: Catergorizes dogs by gender, Spay/Neuter, Name, Region, status (foster, adopted,) dates they need to be moved? */ #include <string> #include <vector> #include <iostream> #include <fstream> using namespace std; int main() { int i= 0, last, v; vector <string> dbo(11); //dbo=database output, going to eventually change the 11 to a variable ifstream records("skipdb.txt"); if(! records) { cout<<"Unable to open records database" <<endl; return -1; } while (i<11) //will eventually be a variable { if ((i+1)==11) getline(records, dbo[i++]); // else getline(records, dbo[i++], '*'); //asterick is used as a delimiter dbo.resize(i+1); /*this may be unnecesarry at this point, dont have time to reread everything and double check. i may have left it in from when I was messing with the integer for the vector*/ } last=i; i=0; while (i<last) { cout<<"\nName:\t\t" <<dbo[i++] <<endl; cout<<"DOB:\t\t" <<dbo[i++] <<endl; cout<<"Source:\t\t" <<dbo[i++] <<endl; cout<<"Gender\t\t" <<dbo[i++] <<endl; cout<<"Spay/Neutred? \t" <<dbo[i++] <<endl; cout<<"Age: \t\t" <<dbo[i++] <<endl; cout<<"Foster?: \t" <<dbo[i++] <<endl; cout<<"Status: \t" <<dbo[i++] <<endl; cout<<"Completion: \t" <<dbo[i++] <<endl; cout<<"Assignment: \t" <<dbo[i++] <<endl; cout<<"Notes:\t \t" <<dbo[i++] <<endl; } records.close(); return 0; }There's loads of free DB engines that plug right in and can follow the program around easily. The only reason I could see making your own would be if you needed to do some low-level processing that wasn't provided by an existing DB engine.
CouchDB seems to be a popular choice these days, though there's some issue with it that affects certain use cases. I just can't think of what it is right now.
Because im new and dumb and didnt know there were alternatives or how they would possibly work.
Ill look at couchDB tonight though.
It looks like CouchDB requires setting up a server. However, as long as you have sufficient control over the environment, I don't think that would be an issue. If you ever wanted to distribute this, you might want to give greater weight to the amount of work a user needs to do to get it running.
I see SQLite in a few very high profile applications and never had to install a server for them, so that might be a good alternative.
As far as user ease, I was going to have adding/removing entries be done while using the program, editting/appending/deleting strings using fstream.
Here's what I use to decide: I think about what's going in, and how it'll be to manage the data.
Will I need to process it? You can do processing in a spreadsheet, but if you need to generate a report, you're either limited to the program's reporting mechanisms, or you're in for a world of pain.
Will it contain weird strings? Writing a parser can be pretty hard, and weird things can happen to delimiters if the wrong character gets input. You're responsible for making sure the data is sane, and data can be weird. People who make and distribute DB engines tend to think about that a lot more, and will be better at it.
Is it a few columns with simple text or numbers? It's easier to dump a database to a text file than the other way around, so you may regret a flat file even if it makes sense.
Keep asking questions like that until you run out of things to ask, and you'll be better prepared to decide on a storage method.
CouchDB is more for distributed database/map-reduce architectures and has a pretty steep learning curve for some things.
The thing you're doing doesn't seem complex enough for a more complicated DB. And there seem to be a lot of people who use SQLite in here, so you'll get help fast if you need it.
This is a programming thread!
nthing
Unless you're on Oracle and have 9 billion dollars.
choices are available
I fucking hate you.
You know why? Because I'm in the process of converting VFP7 to SQL... and I guess you could say c# for the logic bits.
It did do some really weird shit with databases though. Like to fill a combo box apparently all you've got to do is "USE somefile.dbf" and then set the control source to a column in that table.
If anything it's like access++.
I hate them. But it's OK, because they apparently hate me too!
It has the best error messages ever: "Optional feature not implemented."
What...that still exists?
Jesus.