Exemplo n.º 1
0
 def _get_bin(self):
     name = self.request.path.replace('/', '')
     bin = Bin.all().filter('name =', name).get()
     if bin:
         return bin
     else:
         self.redirect('/')
Exemplo n.º 2
0
 def _get_bin(self, path):
     name = path[1:].split('/')[0]
     bin = Bin.all().filter('name =', name).get()
     if bin:
         return bin
     else:
         raise NotFound()
Exemplo n.º 3
0
 def _get_bin(self, path):
     name = path[1:].split('/')[0]
     bin = Bin.all().filter('name =', name).get()
     if bin:
         return bin
     else:
         raise NotFound()
Exemplo n.º 4
0
 def post(self):
     name = self.request.path.split('/')[-1]
     if is_valid_postbin_name( name ):
         bin = Bin.all().filter( 'name =', name ).get() # FIX: is this expensive?
         if bin and check_postbin_access( self, bin ):
             if bin.post_set:
                 [p.delete() for p in bin.post_set]
             bin.delete()
     self.redirect( '/' )
Exemplo n.º 5
0
 def post(self):
     binname = self.request.path.split('/')[-2]
     postname = self.request.path.split('/')[-1]
     deleteall = postname == 'all'
     if deleteall or is_valid_postbin_name( binname ):
         bin = Bin.all().filter( 'name =', binname ).get() # FIX: is this expensive?
         if bin and bin.post_set and check_postbin_access( self, bin ):
             theremustbeabetterway = True
             offset = 0
             while theremustbeabetterway:
                 post = bin.post_set.fetch( 1, offset ) # FIX: there must be a better way
                 offset += 1
                 if post:
                     if deleteall:
                         post[0].delete()
                         offset = 0
                     elif post[0].id() == postname:
                         post[0].delete()
                         theremustbeabetterway = False
                 else:
                     theremustbeabetterway = False
         self.redirect( '/%s' % (binname) )
     else:
         self.redirect( '/' )
Exemplo n.º 6
0
def is_valid_postbin_name( name, badchars = None ):
    if not badchars:
        badchars = re.compile( '\W' ) # \W is anything that is NOT a letter, number, or underscore
    bin = Bin.all().filter( 'name =', name ).get() # FIX: is this expensive?
    return name and bin and not badchars.search( name )
Exemplo n.º 7
0
 def get_by_name(cls, name):
     return Bin.all().filter('name =', name).get()