As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
We're funding a new Acquisitions Incorporated series on Kickstarter right now! Check it out at https://www.kickstarter.com/projects/pennyarcade/acquisitions-incorporated-the-series-2

#define THREAD_TITLE "PA Programming Thread"

1383941434462

Posts

  • MKRMKR Registered User regular
    edited September 2010
    So does anyone have ancient wisdom/tips on making an administrative interface for a web application?

    MKR on
  • Smug DucklingSmug Duckling Registered User regular
    edited September 2010
    Use django. 8-)

    Smug Duckling on
    smugduckling,pc,days.png
  • MKRMKR Registered User regular
    edited September 2010
    Use django. 8-)

    Does django have something that makes doing this easier? D:

    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.

    MKR on
  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    edited September 2010
    C question. if I do something like...
    #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.

    Monkey Ball Warrior on
    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • CangoFettCangoFett Registered User regular
    edited September 2010
    Stupid non-instant understanding of things as soon as I read them .


    DAMN YOU BRAIN AND YOUR MORTAL LIMITATIONS

    CangoFett on
  • amnesiasoftamnesiasoft Thick Creamy Furry Registered User regular
    edited September 2010
    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.

    amnesiasoft on
    steam_sig.png
  • His CorkinessHis Corkiness Registered User regular
    edited September 2010
    Global variables are default-initialized, but I'm not sure if that carries through to members of global variables.

    His Corkiness on
  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    edited September 2010
    Come to find out my problem is probably in the fact that my hash function doesn't pop out the same number given the same string.

    I'm giving up on it for tonight though, ty.

    Monkey Ball Warrior on
    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • PapillonPapillon Registered User regular
    edited September 2010
    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.

    Papillon on
  • His CorkinessHis Corkiness Registered User regular
    edited September 2010
    Papillon wrote: »
    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

    His Corkiness on
  • MKRMKR Registered User regular
    edited September 2010
    Anyone see potential issues with this way of abstracting DB access?
    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.
    returnpage = db_loadpage( "science" )
    content = returnpage.content
    title = returnpage.title
    

    MKR on
  • EndEnd Registered User regular
    edited September 2010
    MKR wrote: »
    :!:

    http://code.google.com/appengine/docs/python/tools/webapp/requestclass.html

    I guess I should just go and read the docs page-by-page until I hit the end.

    edit: Though the docs seem to recommend os.environ: http://code.google.com/appengine/docs/python/runtime.html
    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:
    1. 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).
    2. 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
    zaleiria-by-lexxy-sig.jpgsteam~tinythumb.png
  • MKRMKR Registered User regular
    edited September 2010
    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.

    MKR on
  • EndEnd Registered User regular
    edited September 2010
    Yeah, it definitely seems kinda confusing to me, since all my python web stuff is with the components is as the "vendor" supplied. :P

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpgsteam~tinythumb.png
  • MKRMKR Registered User regular
    edited September 2010
    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:

    MKR on
  • CangoFettCangoFett Registered User regular
    edited September 2010
    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
    Oscar  	*12/30/08       *Family		*Male	*Neutered	*2	*Home	*Placed	*Completed	*CSC	*No notes
    Pete   	*DD/MM/YY	*CSCRescue	*Male	*Neutered	*4	*Home	*Placed	*Completed	*CSC	*No notes
    Gizmo  	*DD/MM/YY	*PuppyMill	*Male	*Neutered	*2	*Home	*Placed	*Completed	*CSC	*No notes
    April  	*DD/MM/YY	*Shelter	*Female	*Spay		*8	*Home	*Placed	*Completed	*CSC	*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;
    }
    

    CangoFett on
  • MKRMKR Registered User regular
    edited September 2010
    Why are you using a text file? D:

    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.

    MKR on
  • CangoFettCangoFett Registered User regular
    edited September 2010
    MKR wrote: »
    Why are you using a text file?

    Because im new and dumb and didnt know there were alternatives or how they would possibly work.

    Ill look at couchDB tonight though.

    CangoFett on
  • MKRMKR Registered User regular
    edited September 2010
    CangoFett wrote: »
    MKR wrote: »
    Why are you using a text file?

    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.

    MKR on
  • CangoFettCangoFett Registered User regular
    edited September 2010
    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.

    CangoFett on
  • MKRMKR Registered User regular
    edited September 2010
    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.

    MKR on
  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited September 2010
    I believe SQLite is better for client apps. CouchDB is a server thing.

    Jasconius on
  • EtheaEthea Registered User regular
    edited September 2010
    I have enjoyed using SQLite for client apps.

    Ethea on
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    SQLite is my choice for flat file database for simple projects like this. I've also done it in similar "small scale" applications.

    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
  • KakodaimonosKakodaimonos Code fondler Helping the 1% get richerRegistered User regular
    edited September 2010
    SQLite is much better than CouchDB for small projects.

    CouchDB is more for distributed database/map-reduce architectures and has a pretty steep learning curve for some things.

    Kakodaimonos on
  • MKRMKR Registered User regular
    edited September 2010
    I believe your choice has been made. :P

    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
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited September 2010
    Just seconding (thirding? fourthing?) SQLite, it's pretty awesome.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • MKRMKR Registered User regular
    edited September 2010
    GnomeTank wrote: »
    Just seconding (thirding? fourthing?) SQLite, it's pretty awesome.

    This is a programming thread!

    nthing

    MKR on
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    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
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited September 2010
    I prefer MySQL over Postgre, but it's really personal preference.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited September 2010
    As the elders at howfuckedismydatabase.com have fortold, no option is truly wise, because lo, thou art fucked anyway.

    Unless you're on Oracle and have 9 billion dollars.

    Jasconius on
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited September 2010
    And lo the Lord looked down and said "ERROR_CYCLIC_REFERENCE, invalid foreign key relationship".

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • KakodaimonosKakodaimonos Code fondler Helping the 1% get richerRegistered User regular
    edited September 2010
    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.

    Kakodaimonos on
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited September 2010
    Lets really go down the database as a programming language and hit up old school Paradox.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited September 2010
    Or we can take a bath in a vat of bees and scorpions


    choices are available

    Jasconius on
  • KakodaimonosKakodaimonos Code fondler Helping the 1% get richerRegistered User regular
    edited September 2010
    There are a couple modern xBase derived languages out there. Even a few .Net Visual Object languages.

    Kakodaimonos on
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    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
  • iTunesIsEviliTunesIsEvil Cornfield? Cornfield.Registered User regular
    edited September 2010
    Any of you guys ever had to deal with Progress databases?

    I hate them. But it's OK, because they apparently hate me too!

    It has the best error messages ever: "Optional feature not implemented."

    iTunesIsEvil on
  • bowenbowen How you doin'? Registered User regular
    edited September 2010
    You ain't got nothing on my c-tree son.

    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
  • EndEnd Registered User regular
    edited September 2010
    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.

    What...that still exists?

    Jesus.

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpgsteam~tinythumb.png
This discussion has been closed.